aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-30 10:50:11 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-02 15:32:58 +0200
commit85dd91f27b16fabe04575bd3b01bccc44b43d43f (patch)
treee133900cf84a4f4c03d027c800edd18341b18e22 /tools
parent5296c163acb520706177807c2a12c30177046fab (diff)
qmllint: Remove ScopeTree::isVisualRootScope()
This is not a property of the ScopeTree itself, but rather a property of how qmllint sets up its scopes. Change-Id: Ifb7c0f1f841046a6ae68e246fbd706f67bedb2af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/findwarnings.cpp10
-rw-r--r--tools/shared/scopetree.cpp12
-rw-r--r--tools/shared/scopetree.h2
3 files changed, 8 insertions, 16 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 3d59259ea3..9fe3bf99bd 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -267,8 +267,14 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb)
auto expstat = cast<ExpressionStatement *>(uisb->statement);
auto identexp = cast<IdentifierExpression *>(expstat->expression);
m_qmlid2scope.insert(identexp->name.toString(), m_currentScope);
- if (m_currentScope->isVisualRootScope())
- m_rootId = identexp->name.toString();
+
+ // Figure out whether the current scope is the root scope.
+ if (auto parentScope = m_currentScope->parentScope()) {
+ if (auto grandParentScope = parentScope->parentScope()) {
+ if (!grandParentScope->parentScope())
+ m_rootId = identexp->name.toString();
+ }
+ }
} else {
const QString signal = signalName(name);
if (signal.isEmpty())
diff --git a/tools/shared/scopetree.cpp b/tools/shared/scopetree.cpp
index 73db8684ab..f55fd7d845 100644
--- a/tools/shared/scopetree.cpp
+++ b/tools/shared/scopetree.cpp
@@ -101,18 +101,6 @@ void ScopeTree::accessMember(const QString &name, const QString &parentType,
m_memberAccessChains.last().append(FieldMember {name, parentType, location });
}
-bool ScopeTree::isVisualRootScope() const
-{
- if (!m_parentScope)
- return false;
-
- const auto grandParent = parentScope()->m_parentScope.toStrongRef();
- if (!grandParent)
- return false;
-
- return grandParent->m_parentScope == nullptr;
-}
-
bool ScopeTree::isIdInCurrentQMlScopes(const QString &id) const
{
if (m_scopeType == ScopeType::QMLScope)
diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h
index 2b44a61c8b..d87422224c 100644
--- a/tools/shared/scopetree.h
+++ b/tools/shared/scopetree.h
@@ -128,8 +128,6 @@ public:
void accessMember(const QString &name, const QString &parentType,
const QQmlJS::SourceLocation &location);
- bool isVisualRootScope() const;
-
ScopeType scopeType() const { return m_scopeType; }
void addMethods(const QMultiHash<QString, MetaMethod> &methods) { m_methods.unite(methods); }