aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
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 /src/qmlcompiler
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 'src/qmlcompiler')
-rw-r--r--src/qmlcompiler/CMakeLists.txt2
-rw-r--r--src/qmlcompiler/importedmembersvisitor.cpp7
-rw-r--r--src/qmlcompiler/importedmembersvisitor_p.h12
-rw-r--r--src/qmlcompiler/metatypes_p.h26
-rw-r--r--src/qmlcompiler/qmlcompiler.pro4
-rw-r--r--src/qmlcompiler/qmljsimporter.cpp14
-rw-r--r--src/qmlcompiler/qmljsimporter_p.h18
-rw-r--r--src/qmlcompiler/qmljstypereader.cpp10
-rw-r--r--src/qmlcompiler/qmljstypereader_p.h4
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp (renamed from src/qmlcompiler/scopetree.cpp)38
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h (renamed from src/qmlcompiler/scopetree_p.h)42
-rw-r--r--src/qmlcompiler/typedescriptionreader.cpp20
-rw-r--r--src/qmlcompiler/typedescriptionreader_p.h16
13 files changed, 106 insertions, 107 deletions
diff --git a/src/qmlcompiler/CMakeLists.txt b/src/qmlcompiler/CMakeLists.txt
index d6895704a4..62853541e5 100644
--- a/src/qmlcompiler/CMakeLists.txt
+++ b/src/qmlcompiler/CMakeLists.txt
@@ -13,8 +13,8 @@ qt_add_module(QmlCompiler
qmljsimporter.cpp qmljsimporter_p.h
qmljstypereader.cpp qmljstypereader_p.h
qmlstreamwriter.cpp qmlstreamwriter_p.h
+ qqmljsscope.cpp qqmljsscope_p.h
resourcefilemapper.cpp resourcefilemapper_p.h
- scopetree.cpp scopetree_p.h
typedescriptionreader.cpp typedescriptionreader_p.h
PUBLIC_LIBRARIES
Qt::CorePrivate
diff --git a/src/qmlcompiler/importedmembersvisitor.cpp b/src/qmlcompiler/importedmembersvisitor.cpp
index 655b77d91f..6b0cd1b9c9 100644
--- a/src/qmlcompiler/importedmembersvisitor.cpp
+++ b/src/qmlcompiler/importedmembersvisitor.cpp
@@ -27,13 +27,12 @@
****************************************************************************/
#include "importedmembersvisitor_p.h"
-#include "scopetree_p.h"
using namespace QQmlJS::AST;
-ScopeTree::Ptr ImportedMembersVisitor::result(const QString &scopeName) const
+QQmlJSScope::Ptr ImportedMembersVisitor::result(const QString &scopeName) const
{
- ScopeTree::Ptr result = ScopeTree::create();
+ QQmlJSScope::Ptr result = QQmlJSScope::create();
result->setIsComposite(true);
result->setInternalName(scopeName);
result->setBaseTypeName(m_rootObject->baseTypeName());
@@ -60,7 +59,7 @@ ScopeTree::Ptr ImportedMembersVisitor::result(const QString &scopeName) const
bool ImportedMembersVisitor::visit(UiObjectDefinition *definition)
{
- ScopeTree::Ptr scope = ScopeTree::create();
+ QQmlJSScope::Ptr scope = QQmlJSScope::create();
QString superType;
for (auto segment = definition->qualifiedTypeNameId; segment; segment = segment->next) {
if (!superType.isEmpty())
diff --git a/src/qmlcompiler/importedmembersvisitor_p.h b/src/qmlcompiler/importedmembersvisitor_p.h
index b909265f0b..71fd0927d6 100644
--- a/src/qmlcompiler/importedmembersvisitor_p.h
+++ b/src/qmlcompiler/importedmembersvisitor_p.h
@@ -39,14 +39,14 @@
//
// We mean it.
-#include "scopetree_p.h"
+#include "qqmljsscope_p.h"
#include <private/qqmljsast_p.h>
class ImportedMembersVisitor : public QQmlJS::AST::Visitor
{
public:
- ScopeTree::Ptr result(const QString &scopeName) const;
+ QQmlJSScope::Ptr result(const QString &scopeName) const;
QStringList errors() const { return m_errors; }
private:
@@ -58,11 +58,11 @@ private:
bool visit(QQmlJS::AST::UiEnumDeclaration *uied) override;
void throwRecursionDepthError() override;
- ScopeTree::Ptr currentObject() const { return m_currentObjects.back(); }
+ QQmlJSScope::Ptr currentObject() const { return m_currentObjects.back(); }
- QVector<ScopeTree::Ptr> m_currentObjects;
- ScopeTree::ConstPtr m_rootObject;
- QHash<QString, ScopeTree::Ptr> m_objects;
+ QVector<QQmlJSScope::Ptr> m_currentObjects;
+ QQmlJSScope::ConstPtr m_rootObject;
+ QHash<QString, QQmlJSScope::Ptr> m_objects;
QStringList m_errors;
};
diff --git a/src/qmlcompiler/metatypes_p.h b/src/qmlcompiler/metatypes_p.h
index d462fb684f..a821e3f0b6 100644
--- a/src/qmlcompiler/metatypes_p.h
+++ b/src/qmlcompiler/metatypes_p.h
@@ -43,7 +43,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qsharedpointer.h>
-// MetaMethod and MetaProperty have both type names and actual ScopeTree types.
+// MetaMethod and MetaProperty have both type names and actual QQmlJSScope types.
// When parsing the information from the relevant QML or qmltypes files, we only
// see the names and don't have a complete picture of the types, yet. In a second
// pass we typically fill in the types. The types may have multiple exported names
@@ -53,7 +53,7 @@
// The parent of an Item, for example, is typically not just a QtObject, but rather
// some other Item with custom properties.
-class ScopeTree;
+class QQmlJSScope;
class MetaEnum
{
QStringList m_keys;
@@ -107,23 +107,23 @@ public:
void setMethodName(const QString &name) { m_name = name; }
QString returnTypeName() const { return m_returnTypeName; }
- QSharedPointer<const ScopeTree> returnType() const { return m_returnType.toStrongRef(); }
+ QSharedPointer<const QQmlJSScope> returnType() const { return m_returnType.toStrongRef(); }
void setReturnTypeName(const QString &type) { m_returnTypeName = type; }
- void setReturnType(const QSharedPointer<const ScopeTree> &type)
+ void setReturnType(const QSharedPointer<const QQmlJSScope> &type)
{
m_returnType = type;
}
QStringList parameterNames() const { return m_paramNames; }
QStringList parameterTypeNames() const { return m_paramTypeNames; }
- QList<QSharedPointer<const ScopeTree>> parameterTypes() const
+ QList<QSharedPointer<const QQmlJSScope>> parameterTypes() const
{
- QList<QSharedPointer<const ScopeTree>> result;
+ QList<QSharedPointer<const QQmlJSScope>> result;
for (const auto &type : m_paramTypes)
result.append(type.toStrongRef());
return result;
}
- void setParameterTypes(const QList<QSharedPointer<const ScopeTree>> &types)
+ void setParameterTypes(const QList<QSharedPointer<const QQmlJSScope>> &types)
{
Q_ASSERT(types.length() == m_paramNames.length());
m_paramTypes.clear();
@@ -131,7 +131,7 @@ public:
m_paramTypes.append(type);
}
void addParameter(const QString &name, const QString &typeName,
- const QSharedPointer<const ScopeTree> &type = {})
+ const QSharedPointer<const QQmlJSScope> &type = {})
{
m_paramNames.append(name);
m_paramTypeNames.append(typeName);
@@ -149,11 +149,11 @@ public:
private:
QString m_name;
QString m_returnTypeName;
- QWeakPointer<const ScopeTree> m_returnType;
+ QWeakPointer<const QQmlJSScope> m_returnType;
QStringList m_paramNames;
QStringList m_paramTypeNames;
- QList<QWeakPointer<const ScopeTree>> m_paramTypes;
+ QList<QWeakPointer<const QQmlJSScope>> m_paramTypes;
Type m_methodType = Signal;
Access m_methodAccess = Private;
@@ -164,7 +164,7 @@ class MetaProperty
{
QString m_propertyName;
QString m_typeName;
- QWeakPointer<const ScopeTree> m_type;
+ QWeakPointer<const QQmlJSScope> m_type;
bool m_isList;
bool m_isWritable;
bool m_isPointer;
@@ -187,8 +187,8 @@ public:
QString propertyName() const { return m_propertyName; }
QString typeName() const { return m_typeName; }
- void setType(const QSharedPointer<const ScopeTree> &type) { m_type = type; }
- QSharedPointer<const ScopeTree> type() const { return m_type.toStrongRef(); }
+ void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; }
+ QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); }
bool isList() const { return m_isList; }
bool isWritable() const { return m_isWritable; }
diff --git a/src/qmlcompiler/qmlcompiler.pro b/src/qmlcompiler/qmlcompiler.pro
index 906286551f..2605eb8daf 100644
--- a/src/qmlcompiler/qmlcompiler.pro
+++ b/src/qmlcompiler/qmlcompiler.pro
@@ -8,7 +8,7 @@ SOURCES = \
importedmembersvisitor.cpp \
qmljsimporter.cpp \
qmljstypereader.cpp \
- scopetree.cpp \
+ qqmljsscope.cpp \
typedescriptionreader.cpp \
qmlstreamwriter.cpp
@@ -18,7 +18,7 @@ HEADERS = \
qmljsimporter_p.h \
qmljstypereader_p.h \
metatypes_p.h \
- scopetree_p.h \
+ qqmljsscope_p.h \
typedescriptionreader_p.h \
qmlstreamwriter_p.h
diff --git a/src/qmlcompiler/qmljsimporter.cpp b/src/qmlcompiler/qmljsimporter.cpp
index a5701c72d4..9385f74274 100644
--- a/src/qmlcompiler/qmljsimporter.cpp
+++ b/src/qmlcompiler/qmljsimporter.cpp
@@ -54,7 +54,7 @@ static QQmlDirParser createQmldirParserForFile(const QString &filename)
}
void QmlJSImporter::readQmltypes(
- const QString &filename, QHash<QString, ScopeTree::Ptr> *objects)
+ const QString &filename, QHash<QString, QQmlJSScope::Ptr> *objects)
{
const QFileInfo fileInfo(filename);
if (!fileInfo.exists()) {
@@ -83,7 +83,7 @@ QmlJSImporter::Import QmlJSImporter::readQmldir(const QString &path)
result.imports.append(reader.imports());
result.dependencies.append(reader.dependencies());
- QHash<QString, ScopeTree::Ptr> qmlComponents;
+ QHash<QString, QQmlJSScope::Ptr> qmlComponents;
const auto components = reader.components();
for (auto it = components.begin(), end = components.end(); it != end; ++it) {
const QString filePath = path + QLatin1Char('/') + it->fileName;
@@ -227,14 +227,14 @@ void QmlJSImporter::importHelper(const QString &module, AvailableTypes *types,
m_seenImports.insert(importId, {});
}
-ScopeTree::Ptr QmlJSImporter::localFile2ScopeTree(const QString &filePath)
+QQmlJSScope::Ptr QmlJSImporter::localFile2ScopeTree(const QString &filePath)
{
const auto seen = m_importedFiles.find(filePath);
if (seen != m_importedFiles.end())
return *seen;
QmlJSTypeReader typeReader(filePath);
- ScopeTree::Ptr result = typeReader();
+ QQmlJSScope::Ptr result = typeReader();
m_importedFiles.insert(filePath, result);
const QStringList errors = typeReader.errors();
@@ -249,7 +249,7 @@ ScopeTree::Ptr QmlJSImporter::localFile2ScopeTree(const QString &filePath)
QDir::NoFilter
};
while (it.hasNext()) {
- ScopeTree::Ptr scope(localFile2ScopeTree(it.next()));
+ QQmlJSScope::Ptr scope(localFile2ScopeTree(it.next()));
if (!scope->internalName().isEmpty())
types.qmlNames.insert(scope->internalName(), scope);
}
@@ -271,7 +271,7 @@ QmlJSImporter::ImportedTypes QmlJSImporter::importFileOrDirectory(
QFileInfo fileInfo(name);
if (fileInfo.isFile()) {
- ScopeTree::Ptr scope(localFile2ScopeTree(fileInfo.canonicalFilePath()));
+ QQmlJSScope::Ptr scope(localFile2ScopeTree(fileInfo.canonicalFilePath()));
result.qmlNames.insert(prefix.isEmpty() ? scope->internalName() : prefix, scope);
return result.qmlNames;
}
@@ -282,7 +282,7 @@ QmlJSImporter::ImportedTypes QmlJSImporter::importFileOrDirectory(
QDir::NoFilter
};
while (it.hasNext()) {
- ScopeTree::Ptr scope(localFile2ScopeTree(it.next()));
+ QQmlJSScope::Ptr scope(localFile2ScopeTree(it.next()));
if (!scope->internalName().isEmpty())
result.qmlNames.insert(prefixedName(prefix, scope->internalName()), scope);
}
diff --git a/src/qmlcompiler/qmljsimporter_p.h b/src/qmlcompiler/qmljsimporter_p.h
index 0fb81dac5f..31a1d57879 100644
--- a/src/qmlcompiler/qmljsimporter_p.h
+++ b/src/qmlcompiler/qmljsimporter_p.h
@@ -39,13 +39,13 @@
//
// We mean it.
-#include "scopetree_p.h"
+#include "qqmljsscope_p.h"
#include <QtQml/private/qqmldirparser_p.h>
class QmlJSImporter
{
public:
- using ImportedTypes = QHash<QString, ScopeTree::ConstPtr>;
+ using ImportedTypes = QHash<QString, QQmlJSScope::ConstPtr>;
QmlJSImporter(const QStringList &importPaths) : m_importPaths(importPaths) {}
@@ -68,15 +68,15 @@ private:
struct AvailableTypes
{
// C++ names used in qmltypes files for non-composite types
- QHash<QString, ScopeTree::ConstPtr> cppNames;
+ QHash<QString, QQmlJSScope::ConstPtr> cppNames;
// Names the importing component sees, including any prefixes
- QHash<QString, ScopeTree::ConstPtr> qmlNames;
+ QHash<QString, QQmlJSScope::ConstPtr> qmlNames;
};
struct Import {
- QHash<QString, ScopeTree::Ptr> objects;
- QHash<QString, ScopeTree::Ptr> scripts;
+ QHash<QString, QQmlJSScope::Ptr> objects;
+ QHash<QString, QQmlJSScope::Ptr> scripts;
QList<QQmlDirParser::Import> imports;
QList<QQmlDirParser::Import> dependencies;
};
@@ -90,13 +90,13 @@ private:
AvailableTypes *types,
const QString &prefix = QString(),
QTypeRevision version = QTypeRevision());
- void readQmltypes(const QString &filename, QHash<QString, ScopeTree::Ptr> *objects);
+ void readQmltypes(const QString &filename, QHash<QString, QQmlJSScope::Ptr> *objects);
Import readQmldir(const QString &dirname);
- ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);
+ QQmlJSScope::Ptr localFile2ScopeTree(const QString &filePath);
QStringList m_importPaths;
QHash<QPair<QString, QTypeRevision>, Import> m_seenImports;
- QHash<QString, ScopeTree::Ptr> m_importedFiles;
+ QHash<QString, QQmlJSScope::Ptr> m_importedFiles;
QStringList m_warnings;
};
diff --git a/src/qmlcompiler/qmljstypereader.cpp b/src/qmlcompiler/qmljstypereader.cpp
index ef2f5c2cbb..1b7587c107 100644
--- a/src/qmlcompiler/qmljstypereader.cpp
+++ b/src/qmlcompiler/qmljstypereader.cpp
@@ -66,10 +66,10 @@ static QList<QmlJSTypeReader::Import> parseHeaders(QQmlJS::AST::UiHeaderItemList
return imports;
}
-static ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name)
+static QQmlJSScope::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name)
{
using namespace QQmlJS::AST;
- ScopeTree::Ptr result = ScopeTree::create(ScopeType::JSLexicalScope);
+ QQmlJSScope::Ptr result = QQmlJSScope::create(ScopeType::JSLexicalScope);
result->setInternalName(name);
for (auto *statement = program->statements; statement; statement = statement->next) {
if (auto *function = cast<FunctionDeclaration *>(statement->statement)) {
@@ -83,7 +83,7 @@ static ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString
return result;
}
-ScopeTree::Ptr QmlJSTypeReader::operator()()
+QQmlJSScope::Ptr QmlJSTypeReader::operator()()
{
using namespace QQmlJS::AST;
const QFileInfo info { m_file };
@@ -100,7 +100,7 @@ ScopeTree::Ptr QmlJSTypeReader::operator()()
QFile file(m_file);
if (!file.open(QFile::ReadOnly)) {
- ScopeTree::Ptr result = ScopeTree::create(
+ QQmlJSScope::Ptr result = QQmlJSScope::create(
isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope);
result->setInternalName(scopeName);
return result;
@@ -116,7 +116,7 @@ ScopeTree::Ptr QmlJSTypeReader::operator()()
: parser.parseProgram())
: parser.parse();
if (!success) {
- ScopeTree::Ptr result = ScopeTree::create(
+ QQmlJSScope::Ptr result = QQmlJSScope::create(
isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope);
result->setInternalName(scopeName);
return result;
diff --git a/src/qmlcompiler/qmljstypereader_p.h b/src/qmlcompiler/qmljstypereader_p.h
index d3c361ff97..c740fd99c6 100644
--- a/src/qmlcompiler/qmljstypereader_p.h
+++ b/src/qmlcompiler/qmljstypereader_p.h
@@ -39,7 +39,7 @@
//
// We mean it.
-#include "scopetree_p.h"
+#include "qqmljsscope_p.h"
#include <QtQml/private/qqmljsastfwd_p.h>
@@ -57,7 +57,7 @@ public:
QmlJSTypeReader(const QString &file) : m_file(file) {}
- ScopeTree::Ptr operator()();
+ QQmlJSScope::Ptr operator()();
QList<Import> imports() const { return m_imports; }
QStringList errors() const { return m_errors; }
diff --git a/src/qmlcompiler/scopetree.cpp b/src/qmlcompiler/qqmljsscope.cpp
index 5e24aeca73..0d226e5c5c 100644
--- a/src/qmlcompiler/scopetree.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -26,19 +26,19 @@
**
****************************************************************************/
-#include "scopetree_p.h"
+#include "qqmljsscope_p.h"
#include <QtCore/qqueue.h>
#include <QtCore/qsharedpointer.h>
#include <algorithm>
-ScopeTree::ScopeTree(ScopeType type, const ScopeTree::Ptr &parentScope)
+QQmlJSScope::QQmlJSScope(ScopeType type, const QQmlJSScope::Ptr &parentScope)
: m_parentScope(parentScope), m_scopeType(type) {}
-ScopeTree::Ptr ScopeTree::create(ScopeType type, const ScopeTree::Ptr &parentScope)
+QQmlJSScope::Ptr QQmlJSScope::create(ScopeType type, const QQmlJSScope::Ptr &parentScope)
{
- ScopeTree::Ptr childScope(new ScopeTree{type, parentScope});
+ QQmlJSScope::Ptr childScope(new QQmlJSScope{type, parentScope});
if (parentScope) {
Q_ASSERT(type != ScopeType::QMLScope
|| !parentScope->m_parentScope
@@ -49,7 +49,7 @@ ScopeTree::Ptr ScopeTree::create(ScopeType type, const ScopeTree::Ptr &parentSco
return childScope;
}
-void ScopeTree::insertJSIdentifier(const QString &name, const JavaScriptIdentifier &identifier)
+void QQmlJSScope::insertJSIdentifier(const QString &name, const JavaScriptIdentifier &identifier)
{
Q_ASSERT(m_scopeType != ScopeType::QMLScope);
if (identifier.kind == JavaScriptIdentifier::LexicalScoped
@@ -64,19 +64,19 @@ void ScopeTree::insertJSIdentifier(const QString &name, const JavaScriptIdentifi
}
}
-void ScopeTree::insertPropertyIdentifier(const MetaProperty &property)
+void QQmlJSScope::insertPropertyIdentifier(const MetaProperty &property)
{
addProperty(property);
MetaMethod method(property.propertyName() + QLatin1String("Changed"), QLatin1String("void"));
addMethod(method);
}
-bool ScopeTree::isIdInCurrentScope(const QString &id) const
+bool QQmlJSScope::isIdInCurrentScope(const QString &id) const
{
return isIdInCurrentQMlScopes(id) || isIdInCurrentJSScopes(id);
}
-bool ScopeTree::isIdInCurrentQMlScopes(const QString &id) const
+bool QQmlJSScope::isIdInCurrentQMlScopes(const QString &id) const
{
if (m_scopeType == ScopeType::QMLScope)
return m_properties.contains(id) || m_methods.contains(id) || m_enums.contains(id);
@@ -87,7 +87,7 @@ bool ScopeTree::isIdInCurrentQMlScopes(const QString &id) const
|| qmlScope->m_enums.contains(id);
}
-bool ScopeTree::isIdInCurrentJSScopes(const QString &id) const
+bool QQmlJSScope::isIdInCurrentJSScopes(const QString &id) const
{
if (m_scopeType != ScopeType::QMLScope && m_jsIdentifiers.contains(id))
return true;
@@ -100,13 +100,13 @@ bool ScopeTree::isIdInCurrentJSScopes(const QString &id) const
return false;
}
-bool ScopeTree::isIdInjectedFromSignal(const QString &id) const
+bool QQmlJSScope::isIdInjectedFromSignal(const QString &id) const
{
const auto found = findJSIdentifier(id);
return found.has_value() && found->kind == JavaScriptIdentifier::Injected;
}
-std::optional<JavaScriptIdentifier> ScopeTree::findJSIdentifier(const QString &id) const
+std::optional<JavaScriptIdentifier> QQmlJSScope::findJSIdentifier(const QString &id) const
{
for (const auto *scope = this; scope; scope = scope->parentScope().data()) {
if (scope->m_scopeType == ScopeType::JSFunctionScope
@@ -120,14 +120,14 @@ std::optional<JavaScriptIdentifier> ScopeTree::findJSIdentifier(const QString &i
return std::optional<JavaScriptIdentifier>{};
}
-void ScopeTree::resolveTypes(const QHash<QString, ScopeTree::ConstPtr> &contextualTypes)
+void QQmlJSScope::resolveTypes(const QHash<QString, QQmlJSScope::ConstPtr> &contextualTypes)
{
auto findType = [&](const QString &name) {
auto type = contextualTypes.constFind(name);
if (type != contextualTypes.constEnd())
return *type;
- return ScopeTree::ConstPtr();
+ return QQmlJSScope::ConstPtr();
};
m_baseType = findType(m_baseTypeName);
@@ -139,7 +139,7 @@ void ScopeTree::resolveTypes(const QHash<QString, ScopeTree::ConstPtr> &contextu
for (auto it = m_methods.begin(), end = m_methods.end(); it != end; ++it) {
it->setReturnType(findType(it->returnTypeName()));
const auto paramNames = it->parameterTypeNames();
- QList<ScopeTree::ConstPtr> paramTypes;
+ QList<QQmlJSScope::ConstPtr> paramTypes;
for (const QString &paramName: paramNames)
paramTypes.append(findType(paramName));
@@ -148,7 +148,7 @@ void ScopeTree::resolveTypes(const QHash<QString, ScopeTree::ConstPtr> &contextu
}
}
-ScopeTree::ConstPtr ScopeTree::findCurrentQMLScope(const ScopeTree::ConstPtr &scope)
+QQmlJSScope::ConstPtr QQmlJSScope::findCurrentQMLScope(const QQmlJSScope::ConstPtr &scope)
{
auto qmlScope = scope;
while (qmlScope && qmlScope->m_scopeType != ScopeType::QMLScope)
@@ -156,17 +156,17 @@ ScopeTree::ConstPtr ScopeTree::findCurrentQMLScope(const ScopeTree::ConstPtr &sc
return qmlScope;
}
-void ScopeTree::addExport(const QString &name, const QString &package, const QTypeRevision &version)
+void QQmlJSScope::addExport(const QString &name, const QString &package, const QTypeRevision &version)
{
m_exports.append(Export(package, name, version, 0));
}
-void ScopeTree::setExportMetaObjectRevision(int exportIndex, int metaObjectRevision)
+void QQmlJSScope::setExportMetaObjectRevision(int exportIndex, int metaObjectRevision)
{
m_exports[exportIndex].setMetaObjectRevision(metaObjectRevision);
}
-ScopeTree::Export::Export(QString package, QString type, const QTypeRevision &version,
+QQmlJSScope::Export::Export(QString package, QString type, const QTypeRevision &version,
int metaObjectRevision) :
m_package(std::move(package)),
m_type(std::move(type)),
@@ -175,7 +175,7 @@ ScopeTree::Export::Export(QString package, QString type, const QTypeRevision &ve
{
}
-bool ScopeTree::Export::isValid() const
+bool QQmlJSScope::Export::isValid() const
{
return m_version.isValid() || !m_package.isEmpty() || !m_type.isEmpty();
}
diff --git a/src/qmlcompiler/scopetree_p.h b/src/qmlcompiler/qqmljsscope_p.h
index 95fca89315..9d38ee7047 100644
--- a/src/qmlcompiler/scopetree_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -26,8 +26,8 @@
**
****************************************************************************/
-#ifndef SCOPETREE_H
-#define SCOPETREE_H
+#ifndef QQMLJSSCOPE_P_H
+#define QQMLJSSCOPE_P_H
//
// W A R N I N G
@@ -70,14 +70,14 @@ struct JavaScriptIdentifier
QQmlJS::SourceLocation location;
};
-class ScopeTree
+class QQmlJSScope
{
- Q_DISABLE_COPY_MOVE(ScopeTree)
+ Q_DISABLE_COPY_MOVE(QQmlJSScope)
public:
- using Ptr = QSharedPointer<ScopeTree>;
- using WeakPtr = QWeakPointer<ScopeTree>;
- using ConstPtr = QSharedPointer<const ScopeTree>;
- using WeakConstPtr = QWeakPointer<const ScopeTree>;
+ using Ptr = QSharedPointer<QQmlJSScope>;
+ using WeakPtr = QWeakPointer<QQmlJSScope>;
+ using ConstPtr = QSharedPointer<const QQmlJSScope>;
+ using WeakConstPtr = QWeakPointer<const QQmlJSScope>;
enum class AccessSemantics {
Reference,
@@ -117,11 +117,11 @@ public:
int m_metaObjectRevision = 0;
};
- static ScopeTree::Ptr create(ScopeType type = ScopeType::QMLScope,
- const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
- static ScopeTree::ConstPtr findCurrentQMLScope(const ScopeTree::ConstPtr &scope);
+ static QQmlJSScope::Ptr create(ScopeType type = ScopeType::QMLScope,
+ const QQmlJSScope::Ptr &parentScope = QQmlJSScope::Ptr());
+ static QQmlJSScope::ConstPtr findCurrentQMLScope(const QQmlJSScope::ConstPtr &scope);
- ScopeTree::Ptr parentScope() const { return m_parentScope.toStrongRef(); }
+ QQmlJSScope::Ptr parentScope() const { return m_parentScope.toStrongRef(); }
void insertJSIdentifier(const QString &name, const JavaScriptIdentifier &identifier);
@@ -155,7 +155,7 @@ public:
// relevant base class (in the hierarchy starting from QObject) of a C++ type.
void setBaseTypeName(const QString &baseTypeName) { m_baseTypeName = baseTypeName; }
QString baseTypeName() const { return m_baseTypeName; }
- ScopeTree::ConstPtr baseType() const { return m_baseType; }
+ QQmlJSScope::ConstPtr baseType() const { return m_baseType; }
void addProperty(const MetaProperty &prop) { m_properties.insert(prop.propertyName(), prop); }
QHash<QString, MetaProperty> properties() const { return m_properties; }
@@ -165,7 +165,7 @@ public:
QString attachedTypeName() const { return m_attachedTypeName; }
void setAttachedTypeName(const QString &name) { m_attachedTypeName = name; }
- ScopeTree::ConstPtr attachedType() const { return m_attachedType; }
+ QQmlJSScope::ConstPtr attachedType() const { return m_attachedType; }
bool isSingleton() const { return m_flags & Singleton; }
bool isCreatable() const { return m_flags & Creatable; }
@@ -183,7 +183,7 @@ public:
std::optional<JavaScriptIdentifier> findJSIdentifier(const QString &id) const;
- QVector<ScopeTree::Ptr> childScopes() const
+ QVector<QQmlJSScope::Ptr> childScopes() const
{
return m_childScopes;
}
@@ -191,7 +191,7 @@ public:
void resolveTypes(const QHash<QString, ConstPtr> &contextualTypes);
private:
- ScopeTree(ScopeType type, const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
+ QQmlJSScope(ScopeType type, const QQmlJSScope::Ptr &parentScope = QQmlJSScope::Ptr());
QHash<QString, JavaScriptIdentifier> m_jsIdentifiers;
@@ -199,23 +199,23 @@ private:
QHash<QString, MetaProperty> m_properties;
QHash<QString, MetaEnum> m_enums;
- QVector<ScopeTree::Ptr> m_childScopes;
- ScopeTree::WeakPtr m_parentScope;
+ QVector<QQmlJSScope::Ptr> m_childScopes;
+ QQmlJSScope::WeakPtr m_parentScope;
QString m_fileName;
QString m_internalName;
QString m_baseTypeName;
- ScopeTree::WeakConstPtr m_baseType;
+ QQmlJSScope::WeakConstPtr m_baseType;
ScopeType m_scopeType = ScopeType::QMLScope;
QList<Export> m_exports;
QString m_defaultPropertyName;
QString m_attachedTypeName;
- ScopeTree::WeakConstPtr m_attachedType;
+ QQmlJSScope::WeakConstPtr m_attachedType;
Flags m_flags;
AccessSemantics m_semantics = AccessSemantics::Reference;
};
-#endif // SCOPETREE_H
+#endif // QQMLJSSCOPE_P_H
diff --git a/src/qmlcompiler/typedescriptionreader.cpp b/src/qmlcompiler/typedescriptionreader.cpp
index 30808e6e99..c5df5f12a6 100644
--- a/src/qmlcompiler/typedescriptionreader.cpp
+++ b/src/qmlcompiler/typedescriptionreader.cpp
@@ -52,7 +52,7 @@ QString toString(const UiQualifiedId *qualifiedId, QChar delimiter = QLatin1Char
}
bool TypeDescriptionReader::operator()(
- QHash<QString, ScopeTree::Ptr> *objects,
+ QHash<QString, QQmlJSScope::Ptr> *objects,
QStringList *dependencies)
{
Engine engine;
@@ -188,7 +188,7 @@ void TypeDescriptionReader::readDependencies(UiScriptBinding *ast)
void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
{
- ScopeTree::Ptr scope = ScopeTree::create();
+ QQmlJSScope::Ptr scope = QQmlJSScope::create();
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
@@ -231,11 +231,11 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
} else if (name == QLatin1String("accessSemantics")) {
const QString semantics = readStringBinding(script);
if (semantics == QLatin1String("reference")) {
- scope->setAccessSemantics(ScopeTree::AccessSemantics::Reference);
+ scope->setAccessSemantics(QQmlJSScope::AccessSemantics::Reference);
} else if (semantics == QLatin1String("value")) {
- scope->setAccessSemantics(ScopeTree::AccessSemantics::Value);
+ scope->setAccessSemantics(QQmlJSScope::AccessSemantics::Value);
} else if (semantics == QLatin1String("none")) {
- scope->setAccessSemantics(ScopeTree::AccessSemantics::None);
+ scope->setAccessSemantics(QQmlJSScope::AccessSemantics::None);
} else {
addWarning(script->firstSourceLocation(),
tr("Unknown access semantics \"%1\".").arg(semantics));
@@ -261,7 +261,7 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
}
void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isMethod,
- const ScopeTree::Ptr &scope)
+ const QQmlJSScope::Ptr &scope)
{
MetaMethod metaMethod;
// ### confusion between Method and Slot. Method should be removed.
@@ -309,7 +309,7 @@ void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isM
scope->addMethod(metaMethod);
}
-void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, const ScopeTree::Ptr &scope)
+void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope)
{
QString name;
QString type;
@@ -355,7 +355,7 @@ void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, const ScopeTre
scope->addProperty(MetaProperty(name, type, isList, !isReadonly, isPointer, false, revision));
}
-void TypeDescriptionReader::readEnum(UiObjectDefinition *ast, const ScopeTree::Ptr &scope)
+void TypeDescriptionReader::readEnum(UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope)
{
MetaEnum metaEnum;
@@ -547,7 +547,7 @@ int TypeDescriptionReader::readIntBinding(UiScriptBinding *ast)
return i;
}
-void TypeDescriptionReader::readExports(UiScriptBinding *ast, const ScopeTree::Ptr &scope)
+void TypeDescriptionReader::readExports(UiScriptBinding *ast, const QQmlJSScope::Ptr &scope)
{
Q_ASSERT(ast);
@@ -598,7 +598,7 @@ void TypeDescriptionReader::readExports(UiScriptBinding *ast, const ScopeTree::P
}
void TypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast,
- const ScopeTree::Ptr &scope)
+ const QQmlJSScope::Ptr &scope)
{
Q_ASSERT(ast);
diff --git a/src/qmlcompiler/typedescriptionreader_p.h b/src/qmlcompiler/typedescriptionreader_p.h
index ca79a68a4f..91fc373656 100644
--- a/src/qmlcompiler/typedescriptionreader_p.h
+++ b/src/qmlcompiler/typedescriptionreader_p.h
@@ -39,7 +39,7 @@
//
// We mean it.
-#include "scopetree_p.h"
+#include "qqmljsscope_p.h"
#include <QtQml/private/qqmljsastfwd_p.h>
@@ -55,7 +55,7 @@ public:
: m_fileName(std::move(fileName)), m_source(std::move(data)) {}
bool operator()(
- QHash<QString, ScopeTree::Ptr> *objects,
+ QHash<QString, QQmlJSScope::Ptr> *objects,
QStringList *dependencies);
QString errorMessage() const { return m_errorMessage; }
@@ -67,9 +67,9 @@ private:
void readDependencies(QQmlJS::AST::UiScriptBinding *ast);
void readComponent(QQmlJS::AST::UiObjectDefinition *ast);
void readSignalOrMethod(QQmlJS::AST::UiObjectDefinition *ast, bool isMethod,
- const ScopeTree::Ptr &scope);
- void readProperty(QQmlJS::AST::UiObjectDefinition *ast, const ScopeTree::Ptr &scope);
- void readEnum(QQmlJS::AST::UiObjectDefinition *ast, const ScopeTree::Ptr &scope);
+ const QQmlJSScope::Ptr &scope);
+ void readProperty(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope);
+ void readEnum(QQmlJS::AST::UiObjectDefinition *ast, const QQmlJSScope::Ptr &scope);
void readParameter(QQmlJS::AST::UiObjectDefinition *ast, MetaMethod *metaMethod);
QString readStringBinding(QQmlJS::AST::UiScriptBinding *ast);
@@ -77,8 +77,8 @@ private:
double readNumericBinding(QQmlJS::AST::UiScriptBinding *ast);
QTypeRevision readNumericVersionBinding(QQmlJS::AST::UiScriptBinding *ast);
int readIntBinding(QQmlJS::AST::UiScriptBinding *ast);
- void readExports(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);
- void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const ScopeTree::Ptr &scope);
+ void readExports(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
+ void readMetaObjectRevisions(QQmlJS::AST::UiScriptBinding *ast, const QQmlJSScope::Ptr &scope);
void readEnumValues(QQmlJS::AST::UiScriptBinding *ast, MetaEnum *metaEnum);
void addError(const QQmlJS::SourceLocation &loc, const QString &message);
@@ -88,7 +88,7 @@ private:
QString m_source;
QString m_errorMessage;
QString m_warningMessage;
- QHash<QString, ScopeTree::Ptr> *m_objects = nullptr;
+ QHash<QString, QQmlJSScope::Ptr> *m_objects = nullptr;
QStringList *m_dependencies = nullptr;
};