forked from qt-creator/qt-creator
ClangCodeModel: Start fallback clangd on demand
E.g. when a non-project source file is opened. Fixes: QTCREATORBUG-29576 Change-Id: Ia99346a7a1016c4c7dcdb41ad6c8dbbc85ed95ff Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -231,10 +231,10 @@ ClangModelManagerSupport::ClangModelManagerSupport()
|
||||
connect(modelManager, &CppModelManager::fallbackProjectPartUpdated, this, [this] {
|
||||
if (sessionModeEnabled())
|
||||
return;
|
||||
if (ClangdClient * const fallbackClient = clientForProject(nullptr)) {
|
||||
if (ClangdClient * const fallbackClient = clientForProject(nullptr))
|
||||
LanguageClientManager::shutdownClient(fallbackClient);
|
||||
if (ClangdSettings::instance().useClangd())
|
||||
claimNonProjectSources(new ClangdClient(nullptr, {}));
|
||||
}
|
||||
});
|
||||
|
||||
auto projectManager = ProjectManager::instance();
|
||||
@@ -251,9 +251,6 @@ ClangModelManagerSupport::ClangModelManagerSupport()
|
||||
connect(&ClangdSettings::instance(), &ClangdSettings::changed,
|
||||
this, &ClangModelManagerSupport::onClangdSettingsChanged);
|
||||
|
||||
if (ClangdSettings::instance().useClangd())
|
||||
new ClangdClient(nullptr, {});
|
||||
|
||||
new ClangdQuickFixFactory(); // memory managed by CppEditor::g_cppQuickFixFactories
|
||||
}
|
||||
|
||||
@@ -777,7 +774,12 @@ void ClangModelManagerSupport::onEditorOpened(IEditor *editor)
|
||||
project = nullptr;
|
||||
else if (!project && ProjectFile::isHeader(document->filePath()))
|
||||
project = fallbackProject();
|
||||
if (ClangdClient * const client = clientForProject(project))
|
||||
ClangdClient *client = clientForProject(project);
|
||||
if (!client) {
|
||||
if (project)
|
||||
return;
|
||||
client = new ClangdClient(nullptr, {});
|
||||
}
|
||||
LanguageClientManager::openDocumentWithClient(textDocument, client);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user