diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-05 08:51:05 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-06 08:19:23 +0200 |
commit | 2b8ec2eacbf96340ce95a2648450fde07bf3b5c3 (patch) | |
tree | fcd14125a2af765a4e3cee2e5d9926fe0d9e6b5b /tools | |
parent | d6091eb768a898377d191143ac8b43b1b666a2d7 (diff) |
QmlCompiler: Split importFileOrDirectory() in two
importing a file and importing a directory are really quite different
things and the code paths inside the function were completely separate.
We also don't have to create a map of ImportedTypes if we are only going
to return a single one.
Change-Id: Ifbb0caa70e9272dfde2d9f1cf5ed1b102e02f5cc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index 17d3588123..d601b3e910 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -137,7 +137,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiProgram *) // using an empty QQmlJSScope m_rootScopeImports.insert(QFileInfo { m_filePath }.baseName(), {}); - const auto imported = m_importer.importFileOrDirectory(QFileInfo(m_filePath).path()); + const auto imported = m_importer.importDirectory(QFileInfo(m_filePath).canonicalPath()); m_rootScopeImports.insert(imported); const QStringList warnings = m_importer.takeWarnings(); @@ -539,10 +539,15 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiImport *import) 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.insert(imported); + const QFileInfo path(file.isRelative() ? QFileInfo(m_filePath).dir().filePath(filename) + : filename); + if (path.isDir()) { + m_rootScopeImports.insert(m_importer.importDirectory(path.canonicalFilePath(), prefix)); + } else if (path.isFile()) { + const auto scope = m_importer.importFile(path.canonicalFilePath()); + m_rootScopeImports.insert(prefix.isEmpty() ? scope->internalName() : prefix, scope); + } + } QString path {}; |