diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index dcbf45da420..4eced0d6735 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -1091,12 +1091,6 @@ void ClangdClient::enableTesting() }); } -void ClangdClient::openEditorDocument(TextEditor::BaseTextEditor *editor) -{ - if (!documentOpen(editor->textDocument())) - openDocument(editor->textDocument()); -} - void ClangdClient::Private::handleFindUsagesResult(quint64 key, const QList &locations) { const auto refData = runningFindUsages.find(key); diff --git a/src/plugins/clangcodemodel/clangdclient.h b/src/plugins/clangcodemodel/clangdclient.h index 7c8ef426fcc..440c56e1d54 100644 --- a/src/plugins/clangcodemodel/clangdclient.h +++ b/src/plugins/clangcodemodel/clangdclient.h @@ -52,8 +52,6 @@ public: QVersionNumber versionNumber() const; CppEditor::ClangdSettings::Data settingsData() const; - void openEditorDocument(TextEditor::BaseTextEditor *editor); - void openExtraFile(const Utils::FilePath &filePath, const QString &content = {}); void closeExtraFile(const Utils::FilePath &filePath); diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index e8eaf1f5af9..54d2a891e39 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -321,7 +321,7 @@ void ClangModelManagerSupport::updateLanguageClient( if (Client * const oldClient = clientForProject(project)) LanguageClientManager::shutdownClient(oldClient); ClangdClient * const client = createClient(project, jsonDbDir); - connect(client, &Client::initialized, this, [this, client, project, projectInfo, jsonDbDir] { + connect(client, &Client::initialized, this, [client, project, projectInfo, jsonDbDir] { using namespace ProjectExplorer; if (!SessionManager::hasProject(project)) return; @@ -333,14 +333,11 @@ void ClangModelManagerSupport::updateLanguageClient( return; // Acquaint the client with all open C++ documents for this project. - ClangdClient * const fallbackClient = clientForProject(nullptr); bool hasDocuments = false; for (TextEditor::BaseTextEditor * const editor : allCppEditors()) { if (!project->isKnownFile(editor->textDocument()->filePath())) continue; - if (fallbackClient && fallbackClient->documentOpen(editor->textDocument())) - fallbackClient->closeDocument(editor->textDocument()); - client->openEditorDocument(editor); + LanguageClientManager::openDocumentWithClient(editor->textDocument(), client); ClangEditorDocumentProcessor::clearTextMarks(editor->textDocument()->filePath()); hasDocuments = true; } @@ -498,7 +495,7 @@ void ClangModelManagerSupport::onEditorOpened(Core::IEditor *editor) ProjectExplorer::Project * const project = ProjectExplorer::SessionManager::projectForFile(document->filePath()); if (ClangdClient * const client = clientForProject(project)) - client->openEditorDocument(qobject_cast(editor)); + LanguageClientManager::openDocumentWithClient(textDocument, client); } }