aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-29 17:56:46 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-02 15:32:51 +0200
commit5296c163acb520706177807c2a12c30177046fab (patch)
tree829f17d0bd05074d97c072f117689c1b0a8e53ee /tools/qmllint
parente548c8576d1794cdac4b9a679b90cb74cf307e44 (diff)
qmllint: Remove C++ types from the importer interface
We don't use them anymore. Now we can also make all the ScopeTrees const again as we don't need to modify them anymore after importing. Change-Id: I3ece767f4f62f06cb0640f1f191eb8d98400717c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint')
-rw-r--r--tools/qmllint/checkidentifiers.cpp18
-rw-r--r--tools/qmllint/findwarnings.cpp22
2 files changed, 20 insertions, 20 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index c3037a8774..9334c13e43 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -188,8 +188,8 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> &
if (unknownBuiltins.contains(typeName))
return true;
- const auto it = m_types.qmlNames.find(typeName);
- if (it == m_types.qmlNames.end()) {
+ const auto it = m_types.find(typeName);
+ if (it == m_types.end()) {
detectedRestrictiveKind = typeName;
detectedRestrictiveName = access.m_name;
scope = nullptr;
@@ -232,7 +232,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> &
ScopeTree::ConstPtr rootType;
if (!access.m_parentType.isEmpty())
- rootType = m_types.qmlNames.value(access.m_parentType);
+ rootType = m_types.value(access.m_parentType);
else
rootType = scope;
@@ -260,8 +260,8 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> &
if (access.m_name.front().isUpper() && scope->scopeType() == ScopeType::QMLScope) {
// may be an attached type
- const auto it = m_types.qmlNames.find(access.m_name);
- if (it != m_types.qmlNames.end() && !(*it)->attachedTypeName().isEmpty()) {
+ const auto it = m_types.find(access.m_name);
+ if (it != m_types.end() && !(*it)->attachedTypeName().isEmpty()) {
if (const auto attached = (*it)->attachedType()) {
scope = attached;
continue;
@@ -326,8 +326,8 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml
if (scopedName.front().isUpper()) {
const QString qualified = memberAccessBase.m_name + QLatin1Char('.')
+ scopedName;
- const auto typeIt = m_types.qmlNames.find(qualified);
- if (typeIt != m_types.qmlNames.end()) {
+ const auto typeIt = m_types.find(qualified);
+ if (typeIt != m_types.end()) {
memberAccessChain.takeFirst();
if (!checkMemberAccess(memberAccessChain, *typeIt))
noUnqualifiedIdentifier = false;
@@ -370,8 +370,8 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml
if (memberAccessBase.m_name == QLatin1String("Qt"))
continue;
- const auto typeIt = m_types.qmlNames.find(memberAccessBase.m_name);
- if (typeIt != m_types.qmlNames.end()) {
+ const auto typeIt = m_types.find(memberAccessBase.m_name);
+ if (typeIt != m_types.end()) {
if (!checkMemberAccess(memberAccessChain, *typeIt))
noUnqualifiedIdentifier = false;
continue;
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index c7d3bb828d..3d59259ea3 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -117,15 +117,15 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiProgram *)
if (!m_qmltypesFiles.isEmpty()) {
const auto baseTypes = m_importer.importQmltypes(m_qmltypesFiles);
- m_rootScopeImports.qmlNames.insert(baseTypes.qmlNames);
+ m_rootScopeImports.insert(baseTypes);
}
// add "self" (as we only ever check the first part of a qualified identifier, we get away with
// using an empty ScopeTree
- m_rootScopeImports.qmlNames.insert(QFileInfo { m_filePath }.baseName(), {});
+ m_rootScopeImports.insert(QFileInfo { m_filePath }.baseName(), {});
const auto imported = m_importer.importFileOrDirectory(QFileInfo(m_filePath).path());
- m_rootScopeImports.qmlNames.insert(imported.qmlNames);
+ m_rootScopeImports.insert(imported);
const QStringList warnings = m_importer.takeWarnings();
for (const QString &warning : warnings) {
@@ -328,7 +328,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiPublicMember *uipm)
uipm->memberType ? uipm->memberType->name.toString() : QString(),
uipm->typeModifier == QLatin1String("list"), !uipm->isReadonlyMember, false,
uipm->memberType ? (uipm->memberType->name == QLatin1String("alias")) : false, 0);
- property.setType(m_rootScopeImports.qmlNames.value(property.typeName()));
+ property.setType(m_rootScopeImports.value(property.typeName()));
m_currentScope->insertPropertyIdentifier(property);
}
return true;
@@ -478,14 +478,14 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiImport *import)
const auto imported = m_importer.importFileOrDirectory(
file.isRelative() ? QFileInfo(m_filePath).dir().filePath(filename) : filename,
prefix);
- m_rootScopeImports.qmlNames.insert(imported.qmlNames);
+ m_rootScopeImports.insert(imported);
}
QString path {};
if (!import->importId.isEmpty()) {
// TODO: do not put imported ids into the same space as qml IDs
const QString importId = import->importId.toString();
- m_qmlid2scope.insert(importId, m_rootScopeImports.qmlNames.value(importId));
+ m_qmlid2scope.insert(importId, m_rootScopeImports.value(importId));
}
auto uri = import->importUri;
while (uri) {
@@ -498,7 +498,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiImport *import)
const auto imported = m_importer.importModule(
path, prefix, import->version ? import->version->version : QTypeRevision());
- m_rootScopeImports.qmlNames.insert(imported.qmlNames);
+ m_rootScopeImports.insert(imported);
const QStringList warnings = m_importer.takeWarnings();
for (const QString &warning : warnings) {
@@ -530,11 +530,11 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
MetaProperty prop(uiob->qualifiedId->name.toString(), name, false, true, true,
name == QLatin1String("alias"), 0);
- prop.setType(m_rootScopeImports.qmlNames.value(uiob->qualifiedTypeNameId->name.toString()));
+ prop.setType(m_rootScopeImports.value(uiob->qualifiedTypeNameId->name.toString()));
m_currentScope->addProperty(prop);
enterEnvironment(ScopeType::QMLScope, name);
- m_currentScope->resolveTypes(m_rootScopeImports.qmlNames);
+ m_currentScope->resolveTypes(m_rootScopeImports);
importExportedNames(m_currentScope);
return true;
}
@@ -565,7 +565,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod)
if (name.isLower())
return false; // Ignore grouped properties for now
- m_currentScope->resolveTypes(m_rootScopeImports.qmlNames);
+ m_currentScope->resolveTypes(m_rootScopeImports);
importExportedNames(m_currentScope);
if (name.endsWith("Connections")) {
@@ -595,7 +595,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod)
do {
scope = scope->parentScope(); // TODO: rename method
} while (scope->scopeType() != ScopeType::QMLScope);
- targetScope = m_rootScopeImports.qmlNames.value(scope->baseTypeName());
+ targetScope = m_rootScopeImports.value(scope->baseTypeName());
} else {
// there was a target, check if we already can find it
auto scopeIt = m_qmlid2scope.find(target);