diff options
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; |