forked from qt-creator/qt-creator
ClangCodeModel: Let user decide how to do the header/source switch
While clangd's AST matching can find source files at any location, it also has a number of annoying bugs that break the functionality for some users. This patch brings back the previous "try built-in first" logic, but also lets users choose their preferred backend. Task-number: QTCREATORBUG-29175 Change-Id: I6b854ed05652e6468509e5748a83a8f9bf76fc20 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -64,6 +64,9 @@ static QString useClangdKey() { return QLatin1String("UseClangdV7"); }
|
||||
static QString clangdPathKey() { return QLatin1String("ClangdPath"); }
|
||||
static QString clangdIndexingKey() { return QLatin1String("ClangdIndexing"); }
|
||||
static QString clangdIndexingPriorityKey() { return QLatin1String("ClangdIndexingPriority"); }
|
||||
static QString clangdHeaderSourceSwitchModeKey() {
|
||||
return QLatin1String("ClangdHeaderSourceSwitchMode");
|
||||
}
|
||||
static QString clangdHeaderInsertionKey() { return QLatin1String("ClangdHeaderInsertion"); }
|
||||
static QString clangdThreadLimitKey() { return QLatin1String("ClangdThreadLimit"); }
|
||||
static QString clangdDocumentThresholdKey() { return QLatin1String("ClangdDocumentThreshold"); }
|
||||
@@ -229,6 +232,16 @@ QString ClangdSettings::priorityToDisplayString(const IndexingPriority &priority
|
||||
return {};
|
||||
}
|
||||
|
||||
QString ClangdSettings::headerSourceSwitchModeToDisplayString(HeaderSourceSwitchMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case HeaderSourceSwitchMode::BuiltinOnly: return Tr::tr("Use Built-in Only");
|
||||
case HeaderSourceSwitchMode::ClangdOnly: return Tr::tr("Use Clangd Only");
|
||||
case HeaderSourceSwitchMode::Both: return Tr::tr("Try Both");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ClangdSettings &ClangdSettings::instance()
|
||||
{
|
||||
static ClangdSettings settings;
|
||||
@@ -528,6 +541,7 @@ QVariantMap ClangdSettings::Data::toMap() const
|
||||
: QString());
|
||||
map.insert(clangdIndexingKey(), indexingPriority != IndexingPriority::Off);
|
||||
map.insert(clangdIndexingPriorityKey(), int(indexingPriority));
|
||||
map.insert(clangdHeaderSourceSwitchModeKey(), int(headerSourceSwitchMode));
|
||||
map.insert(clangdHeaderInsertionKey(), autoIncludeHeaders);
|
||||
map.insert(clangdThreadLimitKey(), workerThreadLimit);
|
||||
map.insert(clangdDocumentThresholdKey(), documentUpdateThreshold);
|
||||
@@ -549,6 +563,8 @@ void ClangdSettings::Data::fromMap(const QVariantMap &map)
|
||||
const auto it = map.find(clangdIndexingKey());
|
||||
if (it != map.end() && !it->toBool())
|
||||
indexingPriority = IndexingPriority::Off;
|
||||
headerSourceSwitchMode = HeaderSourceSwitchMode(map.value(clangdHeaderSourceSwitchModeKey(),
|
||||
int(headerSourceSwitchMode)).toInt());
|
||||
autoIncludeHeaders = map.value(clangdHeaderInsertionKey(), false).toBool();
|
||||
workerThreadLimit = map.value(clangdThreadLimitKey(), 0).toInt();
|
||||
documentUpdateThreshold = map.value(clangdDocumentThresholdKey(), 500).toInt();
|
||||
|
||||
Reference in New Issue
Block a user