QtSupport: Remove unusual access pattern to plugin constants

Change-Id: Ifc21607cd9927e99b5c49f1631d8940725a058fd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-08-18 14:40:01 +02:00
parent 743938b6cb
commit 8346905a51
5 changed files with 16 additions and 46 deletions

View File

@@ -36,9 +36,11 @@
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljstools/qmljstoolsconstants.h> #include <qmljstools/qmljstoolsconstants.h>
#include <qtsupport/qtcppkitinfo.h> #include <qtsupport/qtcppkitinfo.h>
#include <qtsupport/qtkitaspect.h> #include <qtsupport/qtsupportconstants.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/checkablemessagebox.h> #include <utils/checkablemessagebox.h>
@@ -1017,7 +1019,7 @@ void CMakeBuildSystem::updateProjectData()
{ {
const bool mergedHeaderPathsAndQmlImportPaths = kit()->value( const bool mergedHeaderPathsAndQmlImportPaths = kit()->value(
QtSupport::KitHasMergedHeaderPathsWithQmlImportPaths::id(), false).toBool(); QtSupport::Constants::KIT_HAS_MERGED_HEADER_PATHS_WITH_QML_IMPORT_PATHS, false).toBool();
QStringList extraHeaderPaths; QStringList extraHeaderPaths;
QList<QByteArray> moduleMappings; QList<QByteArray> moduleMappings;
for (const RawProjectPart &rpp : std::as_const(rpps)) { for (const RawProjectPart &rpp : std::as_const(rpps)) {
@@ -1575,7 +1577,7 @@ void CMakeBuildSystem::updateQmlJSCodeModel(const QStringList &extraHeaderPaths,
const CMakeConfig &cm = configurationFromCMake(); const CMakeConfig &cm = configurationFromCMake();
addImports(cm.stringValueOf("QML_IMPORT_PATH")); addImports(cm.stringValueOf("QML_IMPORT_PATH"));
addImports(kit()->value(QtSupport::KitQmlImportPath::id()).toString()); addImports(kit()->value(QtSupport::Constants::KIT_QML_IMPORT_PATH).toString());
for (const QString &extraHeaderPath : extraHeaderPaths) for (const QString &extraHeaderPath : extraHeaderPaths)
projectInfo.importPaths.maybeInsert(FilePath::fromString(extraHeaderPath), projectInfo.importPaths.maybeInsert(FilePath::fromString(extraHeaderPath),

View File

@@ -26,6 +26,7 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <qtsupport/qtkitaspect.h> #include <qtsupport/qtkitaspect.h>
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
@@ -115,15 +116,15 @@ public:
k->makeSticky(); k->makeSticky();
if (mcuTarget->toolChainPackage()->isDesktopToolchain()) if (mcuTarget->toolChainPackage()->isDesktopToolchain())
k->setDeviceTypeForIcon(DEVICE_TYPE); k->setDeviceTypeForIcon(DEVICE_TYPE);
k->setValue(QtSupport::SuppliesQtQuickImportPath::id(), true); k->setValue(QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH, true);
// FIXME: This is treated as a pathlist in CMakeBuildSystem::updateQmlJSCodeModel // FIXME: This is treated as a pathlist in CMakeBuildSystem::updateQmlJSCodeModel
k->setValue(QtSupport::KitQmlImportPath::id(), (sdkPath / "include/qul").toString()); k->setValue(QtSupport::Constants::KIT_QML_IMPORT_PATH, (sdkPath / "include/qul").toString());
k->setValue(QtSupport::KitHasMergedHeaderPathsWithQmlImportPaths::id(), true); k->setValue(QtSupport::Constants::KIT_HAS_MERGED_HEADER_PATHS_WITH_QML_IMPORT_PATHS, true);
QSet<Id> irrelevant = { QSet<Id> irrelevant = {
SysRootKitAspect::id(), SysRootKitAspect::id(),
QtSupport::SuppliesQtQuickImportPath::id(), QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH,
QtSupport::KitQmlImportPath::id(), QtSupport::Constants::KIT_QML_IMPORT_PATH,
QtSupport::KitHasMergedHeaderPathsWithQmlImportPaths::id(), QtSupport::Constants::KIT_HAS_MERGED_HEADER_PATHS_WITH_QML_IMPORT_PATHS,
}; };
if (!McuSupportOptions::kitsNeedQtVersion()) if (!McuSupportOptions::kitsNeedQtVersion())
irrelevant.insert(QtSupport::QtKitAspect::id()); irrelevant.insert(QtSupport::QtKitAspect::id());
@@ -668,7 +669,7 @@ void fixExistingKits(const SettingsHandler::Ptr &settingsHandler)
// Check if the MCU kits are flagged as supplying a QtQuick import path, in order // Check if the MCU kits are flagged as supplying a QtQuick import path, in order
// to tell the QMLJS code-model that it won't need to add a fall-back import // to tell the QMLJS code-model that it won't need to add a fall-back import
// path. // path.
const auto bringsQtQuickImportPath = QtSupport::SuppliesQtQuickImportPath::id(); const Id bringsQtQuickImportPath = QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH;
auto irrelevantAspects = kit->irrelevantAspects(); auto irrelevantAspects = kit->irrelevantAspects();
if (!irrelevantAspects.contains(bringsQtQuickImportPath)) { if (!irrelevantAspects.contains(bringsQtQuickImportPath)) {
irrelevantAspects.insert(bringsQtQuickImportPath); irrelevantAspects.insert(bringsQtQuickImportPath);
@@ -679,7 +680,7 @@ void fixExistingKits(const SettingsHandler::Ptr &settingsHandler)
} }
// Check if the MCU kit supplies its import path. // Check if the MCU kit supplies its import path.
const auto kitQmlImportPath = QtSupport::KitQmlImportPath::id(); const Id kitQmlImportPath = QtSupport::Constants::KIT_QML_IMPORT_PATH;
if (!irrelevantAspects.contains(kitQmlImportPath)) { if (!irrelevantAspects.contains(kitQmlImportPath)) {
irrelevantAspects.insert(kitQmlImportPath); irrelevantAspects.insert(kitQmlImportPath);
kit->setIrrelevantAspects(irrelevantAspects); kit->setIrrelevantAspects(irrelevantAspects);
@@ -698,7 +699,7 @@ void fixExistingKits(const SettingsHandler::Ptr &settingsHandler)
} }
// Check if the MCU kit has the flag for merged header/qml-import paths set. // Check if the MCU kit has the flag for merged header/qml-import paths set.
const auto mergedPaths = QtSupport::KitHasMergedHeaderPathsWithQmlImportPaths::id(); const Id mergedPaths = QtSupport::Constants::KIT_HAS_MERGED_HEADER_PATHS_WITH_QML_IMPORT_PATHS;
if (!irrelevantAspects.contains(mergedPaths)) { if (!irrelevantAspects.contains(mergedPaths)) {
irrelevantAspects.insert(mergedPaths); irrelevantAspects.insert(mergedPaths);
kit->setIrrelevantAspects(irrelevantAspects); kit->setIrrelevantAspects(irrelevantAspects);

View File

@@ -200,7 +200,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
auto v = qtVersion->qtVersion(); auto v = qtVersion->qtVersion();
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(qtVersion->hostBinPath(), v); projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(qtVersion->hostBinPath(), v);
projectInfo.qtVersionString = qtVersion->qtVersionString(); projectInfo.qtVersionString = qtVersion->qtVersionString();
} else if (!activeKit || !activeKit->value(QtSupport::SuppliesQtQuickImportPath::id(), false).toBool()) { } else if (!activeKit || !activeKit->value(QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH, false).toBool()) {
projectInfo.qtQmlPath = FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath)); projectInfo.qtQmlPath = FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath));
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath( projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(
FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::BinariesPath)), QLibraryInfo::version()); FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::BinariesPath)), QLibraryInfo::version());

View File

@@ -490,19 +490,4 @@ int QtKitAspectFactory::weight(const Kit *k) const
return qtAbi.isCompatibleWith(tcAbi); }) ? 1 : 0; return qtAbi.isCompatibleWith(tcAbi); }) ? 1 : 0;
} }
Id SuppliesQtQuickImportPath::id()
{
return QtSupport::Constants::FLAGS_SUPPLIES_QTQUICK_IMPORT_PATH;
}
Id KitQmlImportPath::id()
{
return QtSupport::Constants::KIT_QML_IMPORT_PATH;
}
Id KitHasMergedHeaderPathsWithQmlImportPaths::id()
{
return QtSupport::Constants::KIT_HAS_MERGED_HEADER_PATHS_WITH_QML_IMPORT_PATHS;
}
} // namespace QtSupport } // namespace QtSupport

View File

@@ -29,22 +29,4 @@ public:
const QVersionNumber &max = QVersionNumber(INT_MAX, INT_MAX, INT_MAX)); const QVersionNumber &max = QVersionNumber(INT_MAX, INT_MAX, INT_MAX));
}; };
class QTSUPPORT_EXPORT SuppliesQtQuickImportPath
{
public:
static Utils::Id id();
};
class QTSUPPORT_EXPORT KitQmlImportPath
{
public:
static Utils::Id id();
};
class QTSUPPORT_EXPORT KitHasMergedHeaderPathsWithQmlImportPaths
{
public:
static Utils::Id id();
};
} // namespace QtSupport } // namespace QtSupport