LSP: update colorProvider entry of ServerCapabilities

Since version 3.8.0 of the lsp the server can provide the information
whether it supports colors also via an boolean value. The newly added
ColorProviderOptions are currently completely empty, so we ignore them.

Fixes: QTCREATORBUG-22691
Change-Id: I76232d160f4abed7b07574dc1b5413cead26b9f0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2019-07-18 13:26:34 +02:00
parent 636209fa92
commit 71fa2d950c
2 changed files with 22 additions and 5 deletions

View File

@@ -130,6 +130,25 @@ void ServerCapabilities::setRenameProvider(Utils::variant<ServerCapabilities::Re
insert(renameProviderKey, Utils::get<RenameOptions>(renameProvider)); insert(renameProviderKey, Utils::get<RenameOptions>(renameProvider));
} }
Utils::optional<Utils::variant<bool, JsonObject>> ServerCapabilities::colorProvider() const
{
using RetType = Utils::variant<bool, JsonObject>;
const QJsonValue &localValue = value(colorProviderKey);
if (localValue.isBool())
return RetType(localValue.toBool());
if (localValue.isObject())
return RetType(JsonObject(localValue.toObject()));
return Utils::nullopt;
}
void ServerCapabilities::setColorProvider(Utils::variant<bool, JsonObject> colorProvider)
{
if (Utils::holds_alternative<bool>(colorProvider))
insert(renameProviderKey, Utils::get<bool>(colorProvider));
else if (Utils::holds_alternative<JsonObject>(colorProvider))
insert(renameProviderKey, Utils::get<JsonObject>(colorProvider));
}
bool ServerCapabilities::isValid(QStringList *error) const bool ServerCapabilities::isValid(QStringList *error) const
{ {
return checkOptional<TextDocumentSyncOptions, int>(error, textDocumentSyncKey) return checkOptional<TextDocumentSyncOptions, int>(error, textDocumentSyncKey)
@@ -149,7 +168,7 @@ bool ServerCapabilities::isValid(QStringList *error) const
&& checkOptional<bool>(error, documentRangeFormattingProviderKey) && checkOptional<bool>(error, documentRangeFormattingProviderKey)
&& checkOptional<bool, RenameOptions>(error, renameProviderKey) && checkOptional<bool, RenameOptions>(error, renameProviderKey)
&& checkOptional<DocumentLinkOptions>(error, documentLinkProviderKey) && checkOptional<DocumentLinkOptions>(error, documentLinkProviderKey)
&& checkOptional<TextDocumentRegistrationOptions>(error, colorProviderKey) && checkOptional<bool, JsonObject>(error, colorProviderKey)
&& checkOptional<ExecuteCommandOptions>(error, executeCommandProviderKey) && checkOptional<ExecuteCommandOptions>(error, executeCommandProviderKey)
&& checkOptional<WorkspaceServerCapabilities>(error, workspaceKey); && checkOptional<WorkspaceServerCapabilities>(error, workspaceKey);
} }

View File

@@ -373,10 +373,8 @@ public:
void clearDocumentLinkProvider() { remove(documentLinkProviderKey); } void clearDocumentLinkProvider() { remove(documentLinkProviderKey); }
// The server provides color provider support. // The server provides color provider support.
Utils::optional<TextDocumentRegistrationOptions> colorProvider() const Utils::optional<Utils::variant<bool, JsonObject>> colorProvider() const;
{ return optionalValue<TextDocumentRegistrationOptions>(colorProviderKey); } void setColorProvider(Utils::variant<bool, JsonObject> colorProvider);
void setColorProvider(TextDocumentRegistrationOptions colorProvider)
{ insert(colorProviderKey, colorProvider); }
void clearColorProvider() { remove(colorProviderKey); } void clearColorProvider() { remove(colorProviderKey); }
// The server provides execute command support. // The server provides execute command support.