aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-01 14:23:27 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-05 14:58:36 +0200
commitd200ccf92017ebc10a4ccdb5d944e1d803b87c1d (patch)
tree1dc85350482238423143ac71740b834fa6e8d240 /tools/qmllint
parent767dd738d3de9306062707fe05d32c91ed755da3 (diff)
QmlCompiler: Rename ScopeTree to QQmlJSScope
That is a better name. Change-Id: I34a6867692a236dd16ed8e3a68866f994eab02d2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint')
-rw-r--r--tools/qmllint/checkidentifiers.cpp26
-rw-r--r--tools/qmllint/checkidentifiers.h10
-rw-r--r--tools/qmllint/findwarnings.cpp18
-rw-r--r--tools/qmllint/findwarnings.h14
4 files changed, 34 insertions, 34 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index c47a3beb36..e5337df195 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -84,12 +84,12 @@ void CheckIdentifiers::printContext(
+ QLatin1Char('\n'), Normal);
}
-static bool walkViaParentAndAttachedScopes(ScopeTree::ConstPtr rootType,
- std::function<bool(ScopeTree::ConstPtr)> visit)
+static bool walkViaParentAndAttachedScopes(QQmlJSScope::ConstPtr rootType,
+ std::function<bool(QQmlJSScope::ConstPtr)> visit)
{
if (rootType == nullptr)
return false;
- std::stack<ScopeTree::ConstPtr> stack;
+ std::stack<QQmlJSScope::ConstPtr> stack;
stack.push(rootType);
while (!stack.empty()) {
const auto type = stack.top();
@@ -108,7 +108,7 @@ static bool walkViaParentAndAttachedScopes(ScopeTree::ConstPtr rootType,
}
bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
- const ScopeTree::ConstPtr &outerScope,
+ const QQmlJSScope::ConstPtr &outerScope,
const MetaProperty *prop) const
{
@@ -121,7 +121,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
expectedNext.append(QLatin1String("length"));
}
- ScopeTree::ConstPtr scope = outerScope;
+ QQmlJSScope::ConstPtr scope = outerScope;
for (const FieldMember &access : members) {
if (scope.isNull()) {
writeWarning(m_colorOut);
@@ -206,7 +206,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
if (scopeMethodIt != methods.end())
return true; // Access to property of JS function
- auto checkEnums = [&](const ScopeTree::ConstPtr &scope) {
+ auto checkEnums = [&](const QQmlJSScope::ConstPtr &scope) {
const auto enums = scope->enums();
for (const auto &enumerator : enums) {
if (enumerator.name() == access.m_name) {
@@ -231,14 +231,14 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
if (!detectedRestrictiveName.isEmpty())
continue;
- ScopeTree::ConstPtr rootType;
+ QQmlJSScope::ConstPtr rootType;
if (!access.m_parentType.isEmpty())
rootType = m_types.value(access.m_parentType);
else
rootType = scope;
bool typeFound =
- walkViaParentAndAttachedScopes(rootType, [&](ScopeTree::ConstPtr type) {
+ walkViaParentAndAttachedScopes(rootType, [&](QQmlJSScope::ConstPtr type) {
const auto typeProperties = type->properties();
const auto typeIt = typeProperties.find(access.m_name);
if (typeIt != typeProperties.end()) {
@@ -287,18 +287,18 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
}
bool CheckIdentifiers::operator()(
- const QHash<QString, ScopeTree::ConstPtr> &qmlIDs,
+ const QHash<QString, QQmlJSScope::ConstPtr> &qmlIDs,
const QHash<QQmlJS::SourceLocation, SignalHandler> &signalHandlers,
const MemberAccessChains &memberAccessChains,
- const ScopeTree::ConstPtr &root, const QString &rootId) const
+ const QQmlJSScope::ConstPtr &root, const QString &rootId) const
{
bool noUnqualifiedIdentifier = true;
// revisit all scopes
- QQueue<ScopeTree::ConstPtr> workQueue;
+ QQueue<QQmlJSScope::ConstPtr> workQueue;
workQueue.enqueue(root);
while (!workQueue.empty()) {
- const ScopeTree::ConstPtr currentScope = workQueue.dequeue();
+ const QQmlJSScope::ConstPtr currentScope = workQueue.dequeue();
const auto scopeMemberAccessChains = memberAccessChains[currentScope];
for (auto memberAccessChain : scopeMemberAccessChains) {
@@ -333,7 +333,7 @@ bool CheckIdentifiers::operator()(
}
}
- auto qmlScope = ScopeTree::findCurrentQMLScope(currentScope);
+ auto qmlScope = QQmlJSScope::findCurrentQMLScope(currentScope);
if (qmlScope->methods().contains(memberAccessBase.m_name)) {
// a property of a JavaScript function
continue;
diff --git a/tools/qmllint/checkidentifiers.h b/tools/qmllint/checkidentifiers.h
index 181b54d290..93b6a13745 100644
--- a/tools/qmllint/checkidentifiers.h
+++ b/tools/qmllint/checkidentifiers.h
@@ -29,7 +29,7 @@
#ifndef CHECKIDENTIFIERS_H
#define CHECKIDENTIFIERS_H
-#include <QtQmlCompiler/private/scopetree_p.h>
+#include <QtQmlCompiler/private/qqmljsscope_p.h>
#include <QtQmlCompiler/private/qmljsimporter_p.h>
class ColorOutput;
@@ -46,7 +46,7 @@ struct FieldMember
QQmlJS::SourceLocation m_location;
};
-using MemberAccessChains = QHash<ScopeTree::ConstPtr, QVector<QVector<FieldMember>>>;
+using MemberAccessChains = QHash<QQmlJSScope::ConstPtr, QVector<QVector<FieldMember>>>;
class CheckIdentifiers
{
@@ -56,17 +56,17 @@ public:
m_colorOut(colorOut), m_code(code), m_types(types), m_fileName(fileName)
{}
- bool operator ()(const QHash<QString, ScopeTree::ConstPtr> &qmlIDs,
+ bool operator ()(const QHash<QString, QQmlJSScope::ConstPtr> &qmlIDs,
const QHash<QQmlJS::SourceLocation, SignalHandler> &signalHandlers,
const MemberAccessChains &memberAccessChains,
- const ScopeTree::ConstPtr &root, const QString &rootId) const;
+ const QQmlJSScope::ConstPtr &root, const QString &rootId) const;
static void printContext(const QString &code, ColorOutput *output,
const QQmlJS::SourceLocation &location);
private:
bool checkMemberAccess(const QVector<FieldMember> &members,
- const ScopeTree::ConstPtr &outerScope,
+ const QQmlJSScope::ConstPtr &outerScope,
const MetaProperty *prop = nullptr) const;
ColorOutput *m_colorOut = nullptr;
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 128e931277..c0750814a0 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -30,7 +30,7 @@
#include "checkidentifiers.h"
#include <QtQmlCompiler/private/importedmembersvisitor_p.h>
-#include <QtQmlCompiler/private/scopetree_p.h>
+#include <QtQmlCompiler/private/qqmljsscope_p.h>
#include <QtQmlCompiler/private/typedescriptionreader_p.h>
#include <QtQmlCompiler/private/qmljstypereader_p.h>
@@ -46,7 +46,7 @@
void FindWarningVisitor::enterEnvironment(ScopeType type, const QString &name)
{
- m_currentScope = ScopeTree::create(type, m_currentScope);
+ m_currentScope = QQmlJSScope::create(type, m_currentScope);
m_currentScope->setBaseTypeName(name);
m_currentScope->setIsComposite(true);
}
@@ -56,9 +56,9 @@ void FindWarningVisitor::leaveEnvironment()
m_currentScope = m_currentScope->parentScope();
}
-void FindWarningVisitor::importExportedNames(ScopeTree::ConstPtr scope)
+void FindWarningVisitor::importExportedNames(QQmlJSScope::ConstPtr scope)
{
- QList<ScopeTree::ConstPtr> scopes;
+ QList<QQmlJSScope::ConstPtr> scopes;
while (!scope.isNull()) {
if (scopes.contains(scope)) {
QString inheritenceCycle;
@@ -132,7 +132,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiProgram *)
}
// add "self" (as we only ever check the first part of a qualified identifier, we get away with
- // using an empty ScopeTree
+ // using an empty QQmlJSScope
m_rootScopeImports.insert(QFileInfo { m_filePath }.baseName(), {});
const auto imported = m_importer.importFileOrDirectory(QFileInfo(m_filePath).path());
@@ -390,7 +390,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::IdentifierExpression *idexp)
FindWarningVisitor::FindWarningVisitor(
QStringList qmlImportPaths, QStringList qmltypesFiles, QString code, QString fileName,
bool silent, bool warnUnqualified, bool warnWithStatement, bool warnInheritanceCycle)
- : m_rootScope(ScopeTree::create(ScopeType::JSFunctionScope)),
+ : m_rootScope(QQmlJSScope::create(ScopeType::JSFunctionScope)),
m_qmltypesFiles(std::move(qmltypesFiles)),
m_code(std::move(code)),
m_rootId(QLatin1String("<id>")),
@@ -446,7 +446,7 @@ bool FindWarningVisitor::check()
auto targetScope = m_qmlid2scope[outstandingConnection.targetName];
if (outstandingConnection.scope && targetScope != nullptr)
outstandingConnection.scope->addMethods(targetScope->methods());
- QScopedValueRollback<ScopeTree::Ptr> rollback(m_currentScope, outstandingConnection.scope);
+ QScopedValueRollback<QQmlJSScope::Ptr> rollback(m_currentScope, outstandingConnection.scope);
outstandingConnection.uiod->initializer->accept(this);
}
@@ -646,10 +646,10 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod)
}
member = member->next;
}
- ScopeTree::ConstPtr targetScope;
+ QQmlJSScope::ConstPtr targetScope;
if (target.isEmpty()) {
// no target set, connection comes from parentF
- ScopeTree::Ptr scope = m_currentScope;
+ QQmlJSScope::Ptr scope = m_currentScope;
do {
scope = scope->parentScope(); // TODO: rename method
} while (scope->scopeType() != ScopeType::QMLScope);
diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h
index 2f5007b124..111eb6c5b0 100644
--- a/tools/qmllint/findwarnings.h
+++ b/tools/qmllint/findwarnings.h
@@ -43,7 +43,7 @@
#include "checkidentifiers.h"
#include <QtQmlCompiler/private/typedescriptionreader_p.h>
-#include <QtQmlCompiler/private/scopetree_p.h>
+#include <QtQmlCompiler/private/qqmljsscope_p.h>
#include <QtQmlCompiler/private/qmljsimporter_p.h>
#include <QtQml/private/qqmldirparser_p.h>
@@ -70,12 +70,12 @@ private:
MemberAccessChains m_memberAccessChains;
- ScopeTree::Ptr m_rootScope;
- ScopeTree::Ptr m_currentScope;
+ QQmlJSScope::Ptr m_rootScope;
+ QQmlJSScope::Ptr m_currentScope;
QQmlJS::AST::ExpressionNode *m_fieldMemberBase = nullptr;
QStringList m_qmltypesFiles;
QString m_code;
- QHash<QString, ScopeTree::ConstPtr> m_qmlid2scope;
+ QHash<QString, QQmlJSScope::ConstPtr> m_qmlid2scope;
QString m_rootId;
QString m_filePath;
QSet<QString> m_unknownImports;
@@ -89,7 +89,7 @@ private:
struct OutstandingConnection
{
QString targetName;
- ScopeTree::Ptr scope;
+ QQmlJSScope::Ptr scope;
QQmlJS::AST::UiObjectDefinition *uiod;
};
@@ -100,10 +100,10 @@ private:
void enterEnvironment(ScopeType type, const QString &name);
void leaveEnvironment();
- void importExportedNames(ScopeTree::ConstPtr scope);
+ void importExportedNames(QQmlJSScope::ConstPtr scope);
void parseHeaders(QQmlJS::AST::UiHeaderItemList *headers);
- ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name);
+ QQmlJSScope::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name);
void flushPendingSignalParameters();
void throwRecursionDepthError() override;