LSP: allow non versioned text document in SemanticHighlightingParams

The proposal of SemanticHighlighting uses a versioned text document
identifier, but there is a suggestion to be more coherent with other
existing requests and use text document identifier instead (non versionned).
See here: https://github.com/microsoft/vscode-languageserver-node/pull/367/files#r225879268

The clangd language server implements the non versioned version.

Existing code was returning errors with clangd because
SemanticHighlightingParams::isValid would return false because of the
missing version field.

Change-Id: I1c36151342437adad2405118ca6b303db0936e41
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Alexis Murzeau
2020-04-26 19:31:15 +02:00
parent c15e09e0fe
commit 2d5a981b9c
3 changed files with 30 additions and 6 deletions

View File

@@ -1215,9 +1215,18 @@ void Client::handleDiagnostics(const PublishDiagnosticsParams &params)
void Client::handleSemanticHighlight(const SemanticHighlightingParams &params)
{
const DocumentUri &uri = params.textDocument().uri();
DocumentUri uri;
LanguageClientValue<int> version;
auto textDocument = params.textDocument();
if (Utils::holds_alternative<VersionedTextDocumentIdentifier>(textDocument)) {
uri = Utils::get<VersionedTextDocumentIdentifier>(textDocument).uri();
version = Utils::get<VersionedTextDocumentIdentifier>(textDocument).version();
} else {
uri = Utils::get<TextDocumentIdentifier>(textDocument).uri();
}
m_highlights[uri].clear();
const LanguageClientValue<int> &version = params.textDocument().version();
TextEditor::TextDocument *doc = TextEditor::TextDocument::textDocumentForFilePath(
uri.toFilePath());