aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-09 12:02:22 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-15 10:44:25 +0200
commit678d4ec4b68d43d0c748a8ec62a13716f83a27cf (patch)
tree863c228d5f0c46d494f2aee24e65f7ef21ee9e77 /src/qmlcompiler/qqmljsscope.cpp
parentf98c961da6d039621ae40ab6c1a79c4b06efb83f (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/qqmljsscope.cpp')
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp
index e515431758..ed434c17e7 100644
--- a/src/qmlcompiler/qqmljsscope.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -44,13 +44,8 @@ QQmlJSScope::QQmlJSScope(ScopeType type, const QQmlJSScope::Ptr &parentScope)
QQmlJSScope::Ptr QQmlJSScope::create(ScopeType type, const QQmlJSScope::Ptr &parentScope)
{
QSharedPointer<QQmlJSScope> childScope(new QQmlJSScope{type, parentScope});
- if (parentScope) {
- Q_ASSERT(type != QQmlJSScope::QMLScope
- || !parentScope->m_parentScope
- || parentScope->parentScope()->m_scopeType == QQmlJSScope::QMLScope
- || parentScope->parentScope()->m_internalName == QLatin1String("global"));
+ if (parentScope)
parentScope->m_childScopes.push_back(childScope);
- }
return childScope;
}
@@ -188,19 +183,10 @@ bool QQmlJSScope::Export::isValid() const
QQmlJSScope QDeferredFactory<QQmlJSScope>::create() const
{
- QQmlJSTypeReader typeReader(m_filePath);
+ QQmlJSTypeReader typeReader(m_importer, m_filePath);
QQmlJSScope::Ptr result = typeReader();
-
m_importer->m_warnings.append(typeReader.errors());
-
- QQmlJSImporter::AvailableTypes types;
- types.qmlNames.insert(m_importer->importDirectory(QFileInfo(m_filePath).canonicalPath()));
-
- const auto imports = typeReader.imports();
- for (const auto &import : imports)
- m_importer->importHelper(import.module, &types, import.prefix, import.version);
-
- result->resolveTypes(types.qmlNames);
+ result->setInternalName(QFileInfo(m_filePath).baseName());
return std::move(*result);
}