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:
Christian Kandeler
2023-05-17 13:45:56 +02:00
parent 5abb1959c5
commit aa5ddaf412
4 changed files with 66 additions and 4 deletions

View File

@@ -352,10 +352,24 @@ void ClangModelManagerSupport::findUsages(const CursorInEditor &cursor) const
void ClangModelManagerSupport::switchHeaderSource(const FilePath &filePath, bool inNextSplit)
{
if (ClangdClient * const client = clientForFile(filePath))
client->switchHeaderSource(filePath, inNextSplit);
else
CppModelManager::switchHeaderSource(inNextSplit, CppModelManager::Backend::Builtin);
if (ClangdClient * const client = clientForFile(filePath)) {
switch (ClangdProjectSettings(client->project()).settings().headerSourceSwitchMode) {
case ClangdSettings::HeaderSourceSwitchMode::BuiltinOnly:
CppModelManager::switchHeaderSource(inNextSplit, CppModelManager::Backend::Builtin);
return;
case ClangdSettings::HeaderSourceSwitchMode::ClangdOnly:
client->switchHeaderSource(filePath, inNextSplit);
return;
case ClangdSettings::HeaderSourceSwitchMode::Both:
const FilePath otherFile = correspondingHeaderOrSource(filePath);
if (!otherFile.isEmpty())
openEditor(otherFile, inNextSplit);
else
client->switchHeaderSource(filePath, inNextSplit);
return;
}
}
CppModelManager::switchHeaderSource(inNextSplit, CppModelManager::Backend::Builtin);
}
void ClangModelManagerSupport::checkUnused(const Link &link, SearchResult *search,