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 /tools | |
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 'tools')
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 36 | ||||
-rw-r--r-- | tools/qmllint/findwarnings.h | 2 |
2 files changed, 22 insertions, 16 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index 110f6d4627..c238f874e2 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -90,25 +90,31 @@ void FindWarningVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) } } -void FindWarningVisitor::checkGroupedScopes(QQmlJSScope::ConstPtr scope) +void FindWarningVisitor::checkGroupedAndAttachedScopes(QQmlJSScope::ConstPtr scope) { auto children = scope->childScopes(); while (!children.isEmpty()) { auto childScope = children.takeFirst(); - if (childScope->scopeType() != QQmlJSScope::GroupedPropertyScope) - continue; - - if (!childScope->baseType()) { - m_errors.append({ - QStringLiteral("unknown grouped property scope %1.") - .arg(childScope->internalName()), - QtWarningMsg, - childScope->sourceLocation() - }); - m_visitFailed = true; + const auto type = childScope->scopeType(); + switch (type) { + case QQmlJSScope::GroupedPropertyScope: + case QQmlJSScope::AttachedPropertyScope: + if (!childScope->baseType()) { + m_errors.append({ + QStringLiteral("unknown %1 property scope %2.") + .arg(type == QQmlJSScope::GroupedPropertyScope + ? QStringLiteral("grouped") + : QStringLiteral("attached"), + childScope->internalName()), + QtWarningMsg, + childScope->sourceLocation() + }); + m_visitFailed = true; + } + children.append(childScope->childScopes()); + default: + break; } - - children.append(childScope->childScopes()); } } @@ -489,7 +495,7 @@ void FindWarningVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *uiod) QQmlJSImportVisitor::endVisit(uiod); if (m_warnUnqualified) - checkGroupedScopes(childScope); + checkGroupedAndAttachedScopes(childScope); if (m_currentScope == m_globalScope || m_currentScope->baseTypeName() == QStringLiteral("Component")) { diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h index 138f83098d..30ee47705e 100644 --- a/tools/qmllint/findwarnings.h +++ b/tools/qmllint/findwarnings.h @@ -91,7 +91,7 @@ private: QVarLengthArray<OutstandingConnection, 3> m_outstandingConnections; // Connections whose target we have not encountered void checkInheritanceCycle(QQmlJSScope::ConstPtr scope); - void checkGroupedScopes(QQmlJSScope::ConstPtr scope); + void checkGroupedAndAttachedScopes(QQmlJSScope::ConstPtr scope); void flushPendingSignalParameters(); void throwRecursionDepthError() override; |