diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-02-18 10:32:53 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-02-19 13:14:16 +0100 |
commit | e59957d2c46bb52ab5fefeb91ace7e192558373a (patch) | |
tree | 30d00552dff87d66a376df7f35706c7e7ffd52ab /src/qmlcompiler/qqmljsimportvisitor.cpp | |
parent | 33937b28180d8e653e47b9e34c03972553976c6f (diff) |
qmllint: Resolve attached property scopes
Previously, all attached property scopes were just ignored.
Task-number: QTBUG-84369
Change-Id: I324becf92402eacea9d150e6e51359edae562dde
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit f34ecc8f99522b69d1aaa3d5d233add9ed9b6da9)
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index a1de41e3ca..8b57ac9b54 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -52,7 +52,7 @@ void QQmlJSImportVisitor::enterEnvironment(QQmlJSScope::ScopeType type, const QS const QQmlJS::SourceLocation &location) { m_currentScope = QQmlJSScope::create(type, m_currentScope); - if (type == QQmlJSScope::GroupedPropertyScope) + if (type == QQmlJSScope::GroupedPropertyScope || type == QQmlJSScope::AttachedPropertyScope) m_currentScope->setInternalName(name); else m_currentScope->setBaseTypeName(name); @@ -136,7 +136,6 @@ bool QQmlJSImportVisitor::visit(UiObjectDefinition *definition) void QQmlJSImportVisitor::endVisit(UiObjectDefinition *) { m_currentScope->resolveTypes(m_rootScopeImports); - m_currentScope->resolveGroupedScopes(); leaveEnvironment(); } @@ -261,16 +260,20 @@ bool QQmlJSImportVisitor::visit(UiScriptBinding *scriptBinding) for (auto group = id; group->next; group = group->next) { const QString name = group->name.toString(); - if (name.isEmpty() || name.front().isUpper()) - break; // TODO: uppercase grouped scopes are attached properties. Handle them. + if (name.isEmpty()) + break; - enterEnvironment(QQmlJSScope::GroupedPropertyScope, name, group->firstSourceLocation()); + enterEnvironment(name.front().isUpper() ? QQmlJSScope::AttachedPropertyScope + : QQmlJSScope::GroupedPropertyScope, + name, group->firstSourceLocation()); } // TODO: remember the actual binding, once we can process it. - while (m_currentScope->scopeType() == QQmlJSScope::GroupedPropertyScope) + while (m_currentScope->scopeType() == QQmlJSScope::GroupedPropertyScope + || m_currentScope->scopeType() == QQmlJSScope::AttachedPropertyScope) { leaveEnvironment(); + } if (!statement || !statement->expression->asFunctionDefinition()) { enterEnvironment(QQmlJSScope::JSFunctionScope, QStringLiteral("binding"), @@ -497,7 +500,6 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob) void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob) { m_currentScope->resolveTypes(m_rootScopeImports); - m_currentScope->resolveGroupedScopes(); const QQmlJSScope::ConstPtr childScope = m_currentScope; leaveEnvironment(); |