diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-22 13:45:32 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-27 09:23:36 +0100 |
commit | 3eb705b092bed98b354025ef975e3e4a77c33e76 (patch) | |
tree | 98bbc334771f9ec452671d6236380c0a8f6d99ba /tools | |
parent | ed8127cf41951a9ff1d6032c2158e49fdebe51c3 (diff) |
QmlCompiler: Add JS scopes for script bindings
This is necessary to identify the available QML and JS scopes for the
binding, and to add any identifiers found there.
Change-Id: Ic966e7817ccd1fdc064dd433d16fa6c42c9110cc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index d7880b0506..fc90884d60 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -194,13 +194,14 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb) { using namespace QQmlJS::AST; + const auto qmlScope = m_currentScope; if (!QQmlJSImportVisitor::visit(uisb)) return false; auto name = uisb->qualifiedId->name; if (name == QLatin1String("id")) { // Figure out whether the current scope is the root scope. - if (auto parentScope = m_currentScope->parentScope()) { + if (auto parentScope = qmlScope->parentScope()) { if (!parentScope->parentScope()) { const auto expstat = cast<ExpressionStatement *>(uisb->statement); const auto identexp = cast<IdentifierExpression *>(expstat->expression); @@ -214,7 +215,8 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb) if (signal.isEmpty()) return true; - if (!m_currentScope->hasMethod(signal) && m_warnUnqualified) { + + if (!qmlScope->hasMethod(signal) && m_warnUnqualified) { m_errors.append({ QStringLiteral("no matching signal found for handler \"%1\"\n") .arg(name.toString()), @@ -234,7 +236,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb) } } - for (QQmlJSScope::ConstPtr scope = m_currentScope; scope; scope = scope->baseType()) { + for (QQmlJSScope::ConstPtr scope = qmlScope; scope; scope = scope->baseType()) { const auto methods = scope->ownMethods(); const auto methodsRange = methods.equal_range(signal); for (auto method = methodsRange.first; method != methodsRange.second; ++method) { |