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>
This commit is contained in:
Ulf Hermann 2020-09-30 10:50:11 +02:00
parent 5296c163ac
commit 85dd91f27b
3 changed files with 8 additions and 16 deletions

View File

@ -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())

View File

@ -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)

View File

@ -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); }