ClangCodeModel: Make "live update" of dependent sources opt-in

Not everyone wants to invest the extra computing resources needed for
this feature.
Amends b33b99e2d9.
See 6d805195f6 for the original
motivation.

Task-number: QTCREATORBUG-29943
Change-Id: I4c8cce5bb58b34d930a409ea3e0995377c90d4ab
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2024-03-13 15:38:44 +01:00
parent ac4bf6901b
commit 3b80da7117
4 changed files with 51 additions and 5 deletions

View File

@@ -18,6 +18,8 @@
#include <languageclient/languageclientmanager.h>
#include <projectexplorer/projectmanager.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditorconstants.h>
@@ -84,7 +86,12 @@ void ClangEditorDocumentProcessor::forceUpdate(TextEditor::TextDocument *doc)
{
if (const auto client = qobject_cast<ClangdClient *>(
LanguageClient::LanguageClientManager::clientForDocument(doc))) {
client->documentContentsChanged(doc, 0, 0, 0);
const CppEditor::ClangdSettings settings(
CppEditor::ClangdProjectSettings(
ProjectExplorer::ProjectManager::projectForFile(doc->filePath()))
.settings());
if (settings.updateDependentSources())
client->documentContentsChanged(doc, 0, 0, 0);
}
}

View File

@@ -2240,6 +2240,8 @@ public:
ClangdTestIndirectChanges();
private slots:
void initTestCase() override;
void cleanupTestCase();
void test();
};
@@ -2249,6 +2251,20 @@ ClangdTestIndirectChanges::ClangdTestIndirectChanges()
setSourceFileNames({"main.cpp", "directheader.h", "indirectheader.h", "unrelatedheader.h"});
}
void ClangdTestIndirectChanges::initTestCase()
{
CppEditor::ClangdSettings &settings = CppEditor::ClangdSettings::instance();
CppEditor::ClangdSettings::Data settingsData = settings.data();
settingsData.updateDependentSources = true;
settings.setData(settingsData, false);
ClangdTest::initTestCase();
}
void ClangdTestIndirectChanges::cleanupTestCase()
{
CppEditor::ClangdSettings::instance().setData({}, false);
}
void ClangdTestIndirectChanges::test()
{
// Initially, everything is fine.