qmljsinterpreter: Fix directory imports not being found in selector paths

Previously qml files in selector paths would not properly locate directory imports,
now when an import in a selector path fails we try to go up to the next non-selector
directory and look for the imported directory there.

Fixes: QTCREATORBUG-25127
Change-Id: Ib9b364981b49068637aa97d6f75abf7f1f5878cc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Maximilian Goldstein
2021-12-03 14:39:52 +01:00
parent e09bb8017d
commit 708e0fc06f

View File

@@ -2258,6 +2258,14 @@ ImportInfo ImportInfo::pathImport(const QString &docPath, const QString &path,
? ImportType::QrcDirectory
: ImportType::QrcFile;
} else {
QDir dir(docPath);
while (dir.dirName().startsWith("+"))
dir.cdUp();
const QString docPathStripped = dir.absolutePath();
if (docPathStripped != docPath)
return pathImport(docPathStripped, path, version, as, ast);
info.m_type = ImportType::UnknownFile;
}
info.m_version = version;