forked from qt-creator/qt-creator
ClangCodeModel: fix setting refactoring markers for clangd
LanguageClient::updateCodeActionRefactoringMarker overwrites previously set refactoring markers. Fixes: QTCREATORBUG-29493 Change-Id: I156b4e2ff65aed5928251bfea184e093df686818 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -628,13 +628,14 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms)
|
|||||||
const int docVersion = documentVersion(uri);
|
const int docVersion = documentVersion(uri);
|
||||||
if (params.version().value_or(docVersion) != docVersion)
|
if (params.version().value_or(docVersion) != docVersion)
|
||||||
return;
|
return;
|
||||||
|
QList<CodeAction> allCodeActions;
|
||||||
for (const Diagnostic &diagnostic : params.diagnostics()) {
|
for (const Diagnostic &diagnostic : params.diagnostics()) {
|
||||||
const ClangdDiagnostic clangdDiagnostic(diagnostic);
|
const ClangdDiagnostic clangdDiagnostic(diagnostic);
|
||||||
auto codeActions = clangdDiagnostic.codeActions();
|
auto codeActions = clangdDiagnostic.codeActions();
|
||||||
if (codeActions && !codeActions->isEmpty()) {
|
if (codeActions && !codeActions->isEmpty()) {
|
||||||
for (CodeAction &action : *codeActions)
|
for (CodeAction &action : *codeActions)
|
||||||
action.setDiagnostics({diagnostic});
|
action.setDiagnostics({diagnostic});
|
||||||
LanguageClient::updateCodeActionRefactoringMarker(this, *codeActions, uri);
|
allCodeActions << *codeActions;
|
||||||
} else {
|
} else {
|
||||||
// We know that there's only one kind of diagnostic for which clangd has
|
// We know that there's only one kind of diagnostic for which clangd has
|
||||||
// a quickfix tweak, so let's not be wasteful.
|
// a quickfix tweak, so let's not be wasteful.
|
||||||
@@ -644,6 +645,8 @@ void ClangdClient::handleDiagnostics(const PublishDiagnosticsParams ¶ms)
|
|||||||
requestCodeActions(uri, diagnostic);
|
requestCodeActions(uri, diagnostic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!allCodeActions.isEmpty())
|
||||||
|
LanguageClient::updateCodeActionRefactoringMarker(this, allCodeActions, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangdClient::handleDocumentOpened(TextDocument *doc)
|
void ClangdClient::handleDocumentOpened(TextDocument *doc)
|
||||||
|
Reference in New Issue
Block a user