ClangCodeModel: Do not make clangd open all ui headers

This amends 01ceb3a3cb, where we failed to
consider the case of projects with lots of UI headers, which cause
excessive memory use by clangd with our current simplistic approach.
Instead, we now only open ui headers that are used by currently open
documents.
Note that this approach will fail for indirect includes via header files,
but people who do that do not deserve happiness.

Change-Id: I1ef2add701e0f13dc0da79267d3c1367c1b496cc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-07-25 15:25:56 +02:00
parent a6d1f7594c
commit 5f9c30cacf
4 changed files with 97 additions and 24 deletions

View File

@@ -1143,6 +1143,14 @@ DiagnosticManager *ClangdClient::createDiagnosticManager()
return diagnosticManager;
}
bool ClangdClient::referencesShadowFile(const TextEditor::TextDocument *doc,
const Utils::FilePath &candidate)
{
const QRegularExpression includeRex("#include.*" + candidate.fileName() + R"([>"])");
const QTextCursor includePos = doc->document()->find(includeRex);
return !includePos.isNull();
}
RefactoringChangesData *ClangdClient::createRefactoringChangesBackend() const
{
return new CppEditor::CppRefactoringChangesData(