forked from qt-creator/qt-creator
Add QML import path supplied by the kit
Although QUL has merged the QML import paths and the include paths, the convention for C/C++ is to have the headers for a project under a subdirectory of the include path, and do imports relative to the include path. For example: #include <qul/SomeHeader.h> The QML code model doesn't know about this convention, so for the kit has to supply an extra QML import path for this case. Change-Id: I82d4375dd8a1f510180f81b011a715dee8c10d60 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
committed by
Erik Verbruggen
parent
95d8734e5f
commit
9d90efee8b
@@ -1188,11 +1188,15 @@ void CMakeBuildSystem::updateQmlJSCodeModel()
|
||||
|
||||
projectInfo.importPaths.clear();
|
||||
|
||||
auto addImports = [&projectInfo](const QString &imports) {
|
||||
foreach (const QString &import, CMakeConfigItem::cmakeSplitValue(imports))
|
||||
projectInfo.importPaths.maybeInsert(FilePath::fromString(import), QmlJS::Dialect::Qml);
|
||||
};
|
||||
|
||||
const CMakeConfig &cm = cmakeBuildConfiguration()->configurationFromCMake();
|
||||
const QString cmakeImports = QString::fromUtf8(CMakeConfigItem::valueOf("QML_IMPORT_PATH", cm));
|
||||
|
||||
foreach (const QString &cmakeImport, CMakeConfigItem::cmakeSplitValue(cmakeImports))
|
||||
projectInfo.importPaths.maybeInsert(FilePath::fromString(cmakeImport), QmlJS::Dialect::Qml);
|
||||
addImports(cmakeImports);
|
||||
addImports(kit()->value(QtSupport::KitQmlImportPath::id()).toString());
|
||||
|
||||
project()->setProjectLanguage(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID,
|
||||
!projectInfo.sourceFiles.isEmpty());
|
||||
|
||||
Reference in New Issue
Block a user