diff --git a/src/libs/languageserverprotocol/servercapabilities.cpp b/src/libs/languageserverprotocol/servercapabilities.cpp index 3d2721f4a69..1b2c0bd9cc0 100644 --- a/src/libs/languageserverprotocol/servercapabilities.cpp +++ b/src/libs/languageserverprotocol/servercapabilities.cpp @@ -130,6 +130,25 @@ void ServerCapabilities::setRenameProvider(Utils::variant(renameProvider)); } +Utils::optional> ServerCapabilities::colorProvider() const +{ + using RetType = Utils::variant; + 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 colorProvider) +{ + if (Utils::holds_alternative(colorProvider)) + insert(renameProviderKey, Utils::get(colorProvider)); + else if (Utils::holds_alternative(colorProvider)) + insert(renameProviderKey, Utils::get(colorProvider)); +} + bool ServerCapabilities::isValid(QStringList *error) const { return checkOptional(error, textDocumentSyncKey) @@ -149,7 +168,7 @@ bool ServerCapabilities::isValid(QStringList *error) const && checkOptional(error, documentRangeFormattingProviderKey) && checkOptional(error, renameProviderKey) && checkOptional(error, documentLinkProviderKey) - && checkOptional(error, colorProviderKey) + && checkOptional(error, colorProviderKey) && checkOptional(error, executeCommandProviderKey) && checkOptional(error, workspaceKey); } diff --git a/src/libs/languageserverprotocol/servercapabilities.h b/src/libs/languageserverprotocol/servercapabilities.h index 0cbc7facf87..4c8011378f4 100644 --- a/src/libs/languageserverprotocol/servercapabilities.h +++ b/src/libs/languageserverprotocol/servercapabilities.h @@ -373,10 +373,8 @@ public: void clearDocumentLinkProvider() { remove(documentLinkProviderKey); } // The server provides color provider support. - Utils::optional colorProvider() const - { return optionalValue(colorProviderKey); } - void setColorProvider(TextDocumentRegistrationOptions colorProvider) - { insert(colorProviderKey, colorProvider); } + Utils::optional> colorProvider() const; + void setColorProvider(Utils::variant colorProvider); void clearColorProvider() { remove(colorProviderKey); } // The server provides execute command support.