diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-21 16:06:20 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-27 09:23:30 +0100 |
commit | ed8127cf41951a9ff1d6032c2158e49fdebe51c3 (patch) | |
tree | 12e74c92f9c9a9ee940e4bde91ba4132454c1dd8 /tools | |
parent | 23813a319898e8951645a9f9bec5813090fd3a85 (diff) |
QmlCompiler: Introduce grouped scopes
This way we can analyze the left hand part of things like
"anchors.fill: parent" in qmllint.
Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 33 | ||||
-rw-r--r-- | tools/qmllint/findwarnings.h | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index 06e647dcd5..d7880b0506 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -90,6 +90,28 @@ void FindWarningVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) } } +void FindWarningVisitor::checkGroupedScopes(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; + } + + children.append(childScope->childScopes()); + } +} + void FindWarningVisitor::flushPendingSignalParameters() { const SignalHandler handler = m_signalHandlers[m_pendingSingalHandler]; @@ -349,6 +371,14 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob) return true; } +void FindWarningVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob) +{ + QQmlJSImportVisitor::endVisit(uiob); + + if (m_warnUnqualified) + checkGroupedScopes(m_currentScope); +} + bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod) { using namespace QQmlJS::AST; @@ -433,6 +463,9 @@ void FindWarningVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *uiod) auto childScope = m_currentScope; QQmlJSImportVisitor::endVisit(uiod); + if (m_warnUnqualified) + checkGroupedScopes(childScope); + if (m_currentScope == m_globalScope || m_currentScope->baseTypeName() == QStringLiteral("Component")) { return; diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h index 7ce8b569e8..96cd0c3897 100644 --- a/tools/qmllint/findwarnings.h +++ b/tools/qmllint/findwarnings.h @@ -91,6 +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 flushPendingSignalParameters(); void throwRecursionDepthError() override; @@ -108,6 +109,7 @@ private: /* --- end block handling --- */ bool visit(QQmlJS::AST::UiObjectBinding *uiob) override; + void endVisit(QQmlJS::AST::UiObjectBinding *uiob) override; bool visit(QQmlJS::AST::UiObjectDefinition *uiod) override; void endVisit(QQmlJS::AST::UiObjectDefinition *) override; bool visit(QQmlJS::AST::UiScriptBinding *uisb) override; |