diff options
Diffstat (limited to 'src/qmlcompiler')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 8 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljslinter.cpp | 19 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsutils_p.h | 11 |
3 files changed, 25 insertions, 13 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index d07b70bb16..7db2821a5d 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -2207,10 +2207,12 @@ void QQmlJSImportVisitor::importFromHost(const QString &path, const QString &pre void QQmlJSImportVisitor::importFromQrc(const QString &path, const QString &prefix, const QQmlJS::SourceLocation &location) { - if (const auto &mapper = m_importer->resourceFileMapper()) { - if (mapper->isFile(path)) { + Q_ASSERT(path.startsWith(u':')); + if (const QQmlJSResourceFileMapper *mapper = m_importer->resourceFileMapper()) { + const auto pathNoColon = path.mid(1); + if (mapper->isFile(pathNoColon)) { const auto entry = m_importer->resourceFileMapper()->entry( - QQmlJSResourceFileMapper::resourceFileFilter(path)); + QQmlJSResourceFileMapper::resourceFileFilter(pathNoColon)); const auto scope = m_importer->importFile(entry.filePath); const QString actualPrefix = prefix.isEmpty() ? QFileInfo(entry.resourcePath).baseName() : prefix; diff --git a/src/qmlcompiler/qqmljslinter.cpp b/src/qmlcompiler/qqmljslinter.cpp index 51a1489360..9d80406a03 100644 --- a/src/qmlcompiler/qqmljslinter.cpp +++ b/src/qmlcompiler/qqmljslinter.cpp @@ -552,10 +552,19 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintFile(const QString &filename, QQmlJSLiteralBindingCheck literalCheck; literalCheck.run(&v, &typeResolver); + const QStringList resourcePaths = mapper + ? mapper->resourcePaths(QQmlJSResourceFileMapper::localFileFilter(filename)) + : QStringList(); + const QString resolvedPath = + (resourcePaths.size() == 1) ? u':' + resourcePaths.first() : filename; + + QQmlJSLinterCodegen codegen{ &m_importer, resolvedPath, qmldirFiles, m_logger.get() }; + codegen.setTypeResolver(std::move(typeResolver)); + QScopedPointer<QQmlSA::PassManager> passMan; if (m_enablePlugins) { - passMan.reset(new QQmlSA::PassManager(&v, &typeResolver)); + passMan.reset(new QQmlSA::PassManager(&v, codegen.typeResolver())); for (const Plugin &plugin : m_plugins) { if (!plugin.isValid() || !plugin.isEnabled()) @@ -577,14 +586,6 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintFile(const QString &filename, return; } - const QStringList resourcePaths = mapper - ? mapper->resourcePaths(QQmlJSResourceFileMapper::localFileFilter(filename)) - : QStringList(); - const QString resolvedPath = - (resourcePaths.size() == 1) ? u':' + resourcePaths.first() : filename; - - QQmlJSLinterCodegen codegen { &m_importer, resolvedPath, qmldirFiles, m_logger.get() }; - codegen.setTypeResolver(std::move(typeResolver)); if (passMan) codegen.setPassManager(passMan.get()); QQmlJSSaveFunction saveFunction = [](const QV4::CompiledData::SaveableUnitPointer &, diff --git a/src/qmlcompiler/qqmljsutils_p.h b/src/qmlcompiler/qqmljsutils_p.h index 956d946980..311671cd42 100644 --- a/src/qmlcompiler/qqmljsutils_p.h +++ b/src/qmlcompiler/qqmljsutils_p.h @@ -21,10 +21,12 @@ #include "qqmljsscope_p.h" #include "qqmljsmetatypes_p.h" +#include <QtCore/qdir.h> #include <QtCore/qstack.h> #include <QtCore/qstring.h> -#include <QtCore/qstringview.h> #include <QtCore/qstringbuilder.h> +#include <QtCore/qstringview.h> + #include <private/qduplicatetracker_p.h> #include <optional> @@ -365,6 +367,13 @@ struct Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSUtils static std::variant<QString, QQmlJS::DiagnosticMessage> sourceDirectoryPath(const QQmlJSImporter *importer, const QString &buildDirectoryPath); + + static QStringList cleanPaths(QStringList &&paths) + { + for (QString &path : paths) + path = QDir::cleanPath(path); + return paths; + } }; bool Q_QMLCOMPILER_PRIVATE_EXPORT canStrictlyCompareWithVar( |
