aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint
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/qmllint
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/qmllint')
-rw-r--r--tools/qmllint/findwarnings.cpp13
1 files changed, 8 insertions, 5 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);
}