ClangCodeModel: Implement per-session mode for clangd

Fixes: QTCREATORBUG-26526
Change-Id: If9e018475b4e2f0557d9bf64ad9a7921c9dd6046
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-08-24 11:16:20 +02:00
parent eae5de0fa3
commit 2fc5dba1c3
14 changed files with 226 additions and 114 deletions

View File

@@ -40,6 +40,7 @@
#include <languageserverprotocol/progresssupport.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h>
#include <projectexplorer/taskhub.h>
#include <texteditor/codeassist/assistinterface.h>
#include <texteditor/codeassist/iassistprocessor.h>
@@ -372,10 +373,9 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
setClientCapabilities(caps);
setLocatorsEnabled(false);
setAutoRequestCodeActions(false); // clangd sends code actions inside diagnostics
if (project) {
setProgressTitleForToken(indexingToken(),
tr("Indexing %1 with clangd").arg(project->displayName()));
}
setProgressTitleForToken(indexingToken(),
project ? tr("Indexing %1 with clangd").arg(project->displayName())
: tr("Indexing session with clangd"));
setCurrentProject(project);
setDocumentChangeUpdateThreshold(d->settings.documentUpdateThreshold);
setSymbolStringifier(displayNameFromDocumentSymbol);
@@ -587,6 +587,15 @@ bool ClangdClient::referencesShadowFile(const TextEditor::TextDocument *doc,
return !includePos.isNull();
}
bool ClangdClient::fileBelongsToProject(const Utils::FilePath &filePath) const
{
if (CppEditor::ClangdSettings::instance().granularity()
== CppEditor::ClangdSettings::Granularity::Session) {
return SessionManager::projectForFile(filePath);
}
return Client::fileBelongsToProject(filePath);
}
RefactoringChangesData *ClangdClient::createRefactoringChangesBackend() const
{
return new CppEditor::CppRefactoringChangesData(