aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-24 13:23:32 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-09-25 15:21:41 +0200
commit88fd9c3996fd0280be639ad116ebc3a1b30ae0c4 (patch)
tree24fa1ece436e8394869f078380d1c6a366d0e521 /tools/qmllint
parent25a1ad9b654a9a7b0b04d8b63a020162c18b5e20 (diff)
qmllint: Keep scopes mutable until all the imports are resolved
Change-Id: I48601019d0e200eae9d52c3a9db45913cdd9d0f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint')
-rw-r--r--tools/qmllint/findwarnings.cpp14
-rw-r--r--tools/qmllint/findwarnings.h6
2 files changed, 10 insertions, 10 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 715da12ca1..9686194c92 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -71,8 +71,8 @@ void FindWarningVisitor::leaveEnvironment()
static const QLatin1String SlashQmldir = QLatin1String("/qmldir");
static const QLatin1String SlashPluginsDotQmltypes = QLatin1String("/plugins.qmltypes");
-void FindWarningVisitor::Importer::readQmltypes(const QString &filename,
- QHash<QString, ScopeTree::ConstPtr> *objects)
+void FindWarningVisitor::Importer::readQmltypes(
+ const QString &filename, QHash<QString, ScopeTree::Ptr> *objects)
{
const QFileInfo fileInfo(filename);
if (!fileInfo.exists()) {
@@ -121,7 +121,7 @@ FindWarningVisitor::Importer::Import FindWarningVisitor::Importer::readQmldir(co
ComponentVersion(it->version));
}
for (auto it = qmlComponents.begin(), end = qmlComponents.end(); it != end; ++it)
- result.objects.insert( it.key(), ScopeTree::ConstPtr(it.value()));
+ result.objects.insert(it.key(), it.value());
if (!reader.plugins().isEmpty() && QFile::exists(path + SlashPluginsDotQmltypes))
readQmltypes(path + SlashPluginsDotQmltypes, &result.objects);
@@ -129,8 +129,7 @@ FindWarningVisitor::Importer::Import FindWarningVisitor::Importer::readQmldir(co
const auto scripts = reader.scripts();
for (const auto &script : scripts) {
const QString filePath = path + QLatin1Char('/') + script.fileName;
- result.scripts.push_back(
- { script.nameSpace, ScopeTree::ConstPtr(localFile2ScopeTree(filePath)) });
+ result.scripts.push_back({ script.nameSpace, localFile2ScopeTree(filePath) });
}
return result;
}
@@ -264,14 +263,15 @@ QHash<QString, ScopeTree::ConstPtr> FindWarningVisitor::Importer::importFileOrDi
name = QDir(m_currentDir).filePath(name);
if (QFileInfo(name).isFile()) {
- m_exportedName2Scope.insert(prefix, ScopeTree::ConstPtr(localFile2ScopeTree(name)));
+ ScopeTree::Ptr scope(localFile2ScopeTree(name));
+ m_exportedName2Scope.insert(prefix, scope);
result.swap(m_exportedName2Scope);
return result;
}
QDirIterator it { name, QStringList() << QLatin1String("*.qml"), QDir::NoFilter };
while (it.hasNext()) {
- ScopeTree::ConstPtr scope(localFile2ScopeTree(it.next()));
+ ScopeTree::Ptr scope(localFile2ScopeTree(it.next()));
if (!scope->className().isEmpty())
m_exportedName2Scope.insert(prefixedName(prefix, scope->className()), scope);
}
diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h
index 315c72aa47..edc4d46272 100644
--- a/tools/qmllint/findwarnings.h
+++ b/tools/qmllint/findwarnings.h
@@ -82,16 +82,16 @@ private:
private:
struct Import {
- QHash<QString, ScopeTree::ConstPtr> objects;
+ QHash<QString, ScopeTree::Ptr> objects;
QList<QQmlDirParser::Import> imports;
QList<QQmlDirParser::Component> dependencies;
- QList<QPair<QString, ScopeTree::ConstPtr>> scripts;
+ QList<QPair<QString, ScopeTree::Ptr>> scripts;
};
void importHelper(const QString &module, const QString &prefix = QString(),
QTypeRevision version = QTypeRevision());
void processImport(const QString &prefix, const Import &import, QTypeRevision version);
- void readQmltypes(const QString &filename, QHash<QString, ScopeTree::ConstPtr> *objects);
+ void readQmltypes(const QString &filename, QHash<QString, ScopeTree::Ptr> *objects);
Import readQmldir(const QString &dirname);
ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);