diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-09 12:02:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-15 10:44:25 +0200 |
commit | 678d4ec4b68d43d0c748a8ec62a13716f83a27cf (patch) | |
tree | 863c228d5f0c46d494f2aee24e65f7ef21ee9e77 /src/qmlcompiler/qqmljstypereader.cpp | |
parent | f98c961da6d039621ae40ab6c1a79c4b06efb83f (diff) |
Unify QQmlJSImportVisitor and FindWarningsVisitor
They are both pretty much doing the same thing, except that the import
visitor is not as thorough. We need the full analysis in QtQmlCompiler,
so we successively move the code over.
Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljstypereader.cpp')
-rw-r--r-- | src/qmlcompiler/qqmljstypereader.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/src/qmlcompiler/qqmljstypereader.cpp b/src/qmlcompiler/qqmljstypereader.cpp index 0e12c8de95..578b0378c3 100644 --- a/src/qmlcompiler/qqmljstypereader.cpp +++ b/src/qmlcompiler/qqmljstypereader.cpp @@ -40,34 +40,6 @@ QT_BEGIN_NAMESPACE -static QList<QQmlJSTypeReader::Import> parseHeaders(QQmlJS::AST::UiHeaderItemList *header) -{ - using namespace QQmlJS::AST; - QList<QQmlJSTypeReader::Import> imports; - - for (; header; header = header->next) { - auto import = cast<UiImport *>(header->headerItem); - if (!import) - continue; - - QString path; - auto uri = import->importUri; - while (uri) { - path.append(uri->name); - path.append(u'.'); - uri = uri->next; - } - path.chop(1); - imports.append({ - path, - import->version ? import->version->version : QTypeRevision(), - import->asToken.isValid() ? import->importId.toString() : QString() - }); - } - - return imports; -} - static QQmlJSScope::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name) { using namespace QQmlJS::AST; @@ -126,11 +98,11 @@ QQmlJSScope::Ptr QQmlJSTypeReader::operator()() if (!isJavaScript) { QQmlJS::AST::UiProgram *program = parser.ast(); - m_imports = parseHeaders(program->headers); - QQmlJSImportVisitor membersVisitor; - program->members->accept(&membersVisitor); + QQmlJSImportVisitor membersVisitor(m_importer, QFileInfo(m_file).canonicalPath(), + m_qmltypesFiles); + program->accept(&membersVisitor); m_errors = membersVisitor.errors(); - return membersVisitor.result(scopeName); + return membersVisitor.result(); } // TODO: Anything special to do with ES modules here? |