aboutsummaryrefslogtreecommitdiffstats
path: root/tools/shared
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-25 10:13:26 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-09-25 15:21:41 +0200
commit5458f379ac5d5d88dd7f5ddeafd370dbeee3a436 (patch)
treec032ca45fff744cbe41b55c357a73b4a09eb057c /tools/shared
parent5a88c06665d5c0295691e216740210a5172fcc9e (diff)
ScopeTree: Remove the "name" property
It was rarely used and only caused confusion. Use internalName instead. Change-Id: I196b1d77db04a2cb6e3cd0447d34ce9bae0b9cd5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/shared')
-rw-r--r--tools/shared/qmljstypereader.cpp15
-rw-r--r--tools/shared/scopetree.cpp15
-rw-r--r--tools/shared/scopetree.h7
3 files changed, 19 insertions, 18 deletions
diff --git a/tools/shared/qmljstypereader.cpp b/tools/shared/qmljstypereader.cpp
index 527dba4535..4adacf96b4 100644
--- a/tools/shared/qmljstypereader.cpp
+++ b/tools/shared/qmljstypereader.cpp
@@ -69,7 +69,8 @@ static QList<QmlJSTypeReader::Import> parseHeaders(QQmlJS::AST::UiHeaderItemList
static ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name)
{
using namespace QQmlJS::AST;
- ScopeTree::Ptr result = ScopeTree::create(ScopeType::JSLexicalScope, name);
+ ScopeTree::Ptr result = ScopeTree::create(ScopeType::JSLexicalScope);
+ result->setInternalName(name);
for (auto *statement = program->statements; statement; statement = statement->next) {
if (auto *function = cast<FunctionDeclaration *>(statement->statement)) {
MetaMethod method(function->name.toString());
@@ -99,8 +100,10 @@ ScopeTree::Ptr QmlJSTypeReader::operator()()
QFile file(m_file);
if (!file.open(QFile::ReadOnly)) {
- return ScopeTree::create(isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope,
- scopeName);
+ ScopeTree::Ptr result = ScopeTree::create(
+ isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope);
+ result->setInternalName(scopeName);
+ return result;
}
QString code = QString::fromUtf8(file.readAll());
@@ -113,8 +116,10 @@ ScopeTree::Ptr QmlJSTypeReader::operator()()
: parser.parseProgram())
: parser.parse();
if (!success) {
- return ScopeTree::create(isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope,
- scopeName);
+ ScopeTree::Ptr result = ScopeTree::create(
+ isJavaScript ? ScopeType::JSLexicalScope : ScopeType::QMLScope);
+ result->setInternalName(scopeName);
+ return result;
}
if (!isJavaScript) {
diff --git a/tools/shared/scopetree.cpp b/tools/shared/scopetree.cpp
index ea5175d2d6..6cbabf4b51 100644
--- a/tools/shared/scopetree.cpp
+++ b/tools/shared/scopetree.cpp
@@ -33,18 +33,17 @@
#include <algorithm>
-ScopeTree::ScopeTree(ScopeType type, const QString &name, const ScopeTree::Ptr &parentScope)
- : m_parentScope(parentScope), m_name(name), m_scopeType(type) {}
+ScopeTree::ScopeTree(ScopeType type, const ScopeTree::Ptr &parentScope)
+ : m_parentScope(parentScope), m_scopeType(type) {}
-ScopeTree::Ptr ScopeTree::create(ScopeType type, const QString &name,
- const ScopeTree::Ptr &parentScope)
+ScopeTree::Ptr ScopeTree::create(ScopeType type, const ScopeTree::Ptr &parentScope)
{
- ScopeTree::Ptr childScope(new ScopeTree{type, name, parentScope});
+ ScopeTree::Ptr childScope(new ScopeTree{type, parentScope});
if (parentScope) {
Q_ASSERT(type != ScopeType::QMLScope
|| !parentScope->m_parentScope
|| parentScope->parentScope()->m_scopeType == ScopeType::QMLScope
- || parentScope->parentScope()->m_name == QLatin1String("global"));
+ || parentScope->parentScope()->m_internalName == QLatin1String("global"));
parentScope->m_childScopes.push_back(childScope);
}
return childScope;
@@ -168,8 +167,8 @@ void ScopeTree::updateParentProperty(const ScopeTree::ConstPtr &scope)
{
auto it = m_properties.find(QLatin1String("parent"));
if (it != m_properties.end()
- && scope->name() != QLatin1String("Component")
- && scope->name() != QLatin1String("program"))
+ && scope->internalName() != QLatin1String("Component")
+ && scope->internalName() != QLatin1String("program"))
it->setType(scope);
}
diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h
index f505ed7457..9c16f6b05f 100644
--- a/tools/shared/scopetree.h
+++ b/tools/shared/scopetree.h
@@ -109,7 +109,7 @@ public:
int m_metaObjectRevision = 0;
};
- static ScopeTree::Ptr create(ScopeType type = ScopeType::QMLScope, const QString &name = QString(),
+ static ScopeTree::Ptr create(ScopeType type = ScopeType::QMLScope,
const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
static ScopeTree::ConstPtr findCurrentQMLScope(const ScopeTree::ConstPtr &scope);
@@ -129,7 +129,6 @@ public:
const QQmlJS::SourceLocation &location);
bool isVisualRootScope() const;
- QString name() const { return m_name; }
ScopeType scopeType() const { return m_scopeType; }
@@ -209,8 +208,7 @@ public:
}
private:
- ScopeTree(ScopeType type, const QString &name = QString(),
- const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
+ ScopeTree(ScopeType type, const ScopeTree::Ptr &parentScope = ScopeTree::Ptr());
QSet<QString> m_jsIdentifiers;
QMultiHash<QString, MethodUsage> m_injectedSignalIdentifiers;
@@ -226,7 +224,6 @@ private:
ScopeTree::WeakPtr m_parentScope;
QString m_fileName;
- QString m_name;
QString m_internalName;
QString m_baseTypeName;