forked from qt-creator/qt-creator
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:
@@ -491,10 +491,24 @@ void SemanticHighlightToken::appendToByteArray(QByteArray &byteArray) const
|
||||
byteArray.append(char((scope & 0x00ff)));
|
||||
}
|
||||
|
||||
Utils::variant<VersionedTextDocumentIdentifier, TextDocumentIdentifier>
|
||||
SemanticHighlightingParams::textDocument() const
|
||||
{
|
||||
VersionedTextDocumentIdentifier textDocument = fromJsonValue<VersionedTextDocumentIdentifier>(
|
||||
value(textDocumentKey));
|
||||
ErrorHierarchy error;
|
||||
if (!textDocument.isValid(&error)) {
|
||||
return TextDocumentIdentifier(textDocument);
|
||||
} else {
|
||||
return textDocument;
|
||||
}
|
||||
}
|
||||
|
||||
bool SemanticHighlightingParams::isValid(ErrorHierarchy *error) const
|
||||
{
|
||||
return check<VersionedTextDocumentIdentifier>(error, textDocumentKey)
|
||||
&& checkArray<SemanticHighlightingInformation>(error, linesKey);
|
||||
return checkVariant<VersionedTextDocumentIdentifier, TextDocumentIdentifier>(error,
|
||||
textDocumentKey)
|
||||
&& checkArray<SemanticHighlightingInformation>(error, linesKey);
|
||||
}
|
||||
|
||||
} // namespace LanguageServerProtocol
|
||||
|
||||
Reference in New Issue
Block a user