From 3eb705b092bed98b354025ef975e3e4a77c33e76 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 22 Oct 2020 13:45:32 +0200 Subject: 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 --- tools/qmllint/findwarnings.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools/qmllint') 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(uisb->statement); const auto identexp = cast(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) { -- cgit v1.2.3