aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-29 16:26:07 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-02 15:32:21 +0200
commit4bb53fd1086e5e67391c7bd328ab5083ed83be68 (patch)
tree0776d2548976137eda8b79a974290ad466565728 /tools
parent48426aa705cb7ed88489200864c2fc0143058671 (diff)
tools: Remove QmlJSImporter::m_currentDir
It was only used to make paths passed to importFileOrDirectory absolute. We can do that before passing them. Change-Id: I0798d38080596fc6eb314259e81702b81a7743dd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/findwarnings.cpp13
-rw-r--r--tools/shared/qmljsimporter.cpp3
-rw-r--r--tools/shared/qmljsimporter.h4
3 files changed, 9 insertions, 11 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index b28a4ee695..a11abbf002 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -119,7 +119,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiProgram *)
// using an empty ScopeTree
m_rootScopeImports.importedQmlNames.insert(QFileInfo { m_filePath }.baseName(), {});
- const auto imported = m_importer.importFileOrDirectory(".");
+ const auto imported = m_importer.importFileOrDirectory(QFileInfo(m_filePath).path());
m_rootScopeImports.importedQmlNames.insert(imported.importedQmlNames);
m_rootScopeImports.cppNames.insert(imported.cppNames);
@@ -350,7 +350,7 @@ FindWarningVisitor::FindWarningVisitor(
m_warnUnqualified(warnUnqualified),
m_warnWithStatement(warnWithStatement),
m_warnInheritanceCycle(warnInheritanceCycle),
- m_importer(QFileInfo(m_filePath).path(), qmltypeDirs)
+ m_importer(qmltypeDirs)
{
m_rootScope->setInternalName("global");
m_currentScope = m_rootScope;
@@ -468,9 +468,12 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiImport *import)
if (import->asToken.isValid()) {
prefix += import->importId;
}
- auto dirname = import->fileName.toString();
- if (!dirname.isEmpty()) {
- const auto imported = m_importer.importFileOrDirectory(dirname, prefix);
+ auto filename = import->fileName.toString();
+ if (!filename.isEmpty()) {
+ const QFileInfo file(filename);
+ const auto imported = m_importer.importFileOrDirectory(
+ file.isRelative() ? QFileInfo(m_filePath).dir().filePath(filename) : filename,
+ prefix);
m_rootScopeImports.importedQmlNames.insert(imported.importedQmlNames);
m_rootScopeImports.cppNames.insert(imported.cppNames);
}
diff --git a/tools/shared/qmljsimporter.cpp b/tools/shared/qmljsimporter.cpp
index 28b7e7950f..b061b96a53 100644
--- a/tools/shared/qmljsimporter.cpp
+++ b/tools/shared/qmljsimporter.cpp
@@ -287,9 +287,6 @@ QmlJSImporter::ImportedTypes QmlJSImporter::importFileOrDirectory(
QString name = fileOrDirectory;
- if (QFileInfo(name).isRelative())
- name = QDir(m_currentDir).filePath(name);
-
QFileInfo fileInfo(name);
if (fileInfo.isFile()) {
ScopeTree::Ptr scope(localFile2ScopeTree(fileInfo.canonicalFilePath()));
diff --git a/tools/shared/qmljsimporter.h b/tools/shared/qmljsimporter.h
index 44536acc51..170b211175 100644
--- a/tools/shared/qmljsimporter.h
+++ b/tools/shared/qmljsimporter.h
@@ -57,8 +57,7 @@ public:
QHash<QString, ScopeTree::Ptr> importedQmlNames;
};
- QmlJSImporter(const QString &currentDir, const QStringList &importPaths) :
- m_currentDir(currentDir), m_importPaths(importPaths) {}
+ QmlJSImporter(const QStringList &importPaths) : m_importPaths(importPaths) {}
ImportedTypes importBaseQmlTypes(const QStringList &qmltypesFiles);
ImportedTypes importFileOrDirectory(
@@ -95,7 +94,6 @@ private:
Import readQmldir(const QString &dirname);
ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);
- QString m_currentDir;
QStringList m_importPaths;
QHash<QPair<QString, QTypeRevision>, Import> m_seenImports;
QHash<QString, ScopeTree::Ptr> m_importedFiles;