From 0a7b608ca97132a158e3219f55a0eac1f5746843 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 21 Oct 2024 09:16:26 +0200 Subject: [PATCH] LSP: Add Diagnostic.CodeDescription to the protocol implementation see https://microsoft.github.io/language-server-protocol/specifications/ lsp/3.17/specification/#codeDescription Change-Id: Id2f92f1aea73928306be413afda636dcec978cf7 Reviewed-by: Christian Kandeler --- src/libs/languageserverprotocol/jsonkeys.h | 2 ++ src/libs/languageserverprotocol/lsptypes.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/libs/languageserverprotocol/jsonkeys.h b/src/libs/languageserverprotocol/jsonkeys.h index 37894f166e9..a4ba26e11c8 100644 --- a/src/libs/languageserverprotocol/jsonkeys.h +++ b/src/libs/languageserverprotocol/jsonkeys.h @@ -34,6 +34,7 @@ constexpr Key codeActionKindKey{"codeActionKind"}; constexpr Key codeActionKindsKey{"codeActionKinds"}; constexpr Key codeActionLiteralSupportKey{"codeActionLiteralSupport"}; constexpr Key codeActionProviderKey{"codeActionProvider"}; +constexpr Key codeDescriptionKey{"codeDescription"}; constexpr Key codeKey{"code"}; constexpr Key codeLensKey{"codeLens"}; constexpr Key codeLensProviderKey{"codeLensProvider"}; @@ -99,6 +100,7 @@ constexpr Key greenKey{"green"}; constexpr Key hierarchicalDocumentSymbolSupportKey{"hierarchicalDocumentSymbolSupport"}; constexpr Key hoverKey{"hover"}; constexpr Key hoverProviderKey{"hoverProvider"}; +constexpr Key hrefKey{"href"}; constexpr Key idKey{"id"}; constexpr Key ignoreIfExistsKey{"ignoreIfExists"}; constexpr Key ignoreIfNotExistsKey{"ignoreIfNotExists"}; diff --git a/src/libs/languageserverprotocol/lsptypes.h b/src/libs/languageserverprotocol/lsptypes.h index 6e25fcb49d0..07e56e7c34f 100644 --- a/src/libs/languageserverprotocol/lsptypes.h +++ b/src/libs/languageserverprotocol/lsptypes.h @@ -154,6 +154,17 @@ enum class DiagnosticSeverity }; +class LANGUAGESERVERPROTOCOL_EXPORT CodeDescription : public JsonObject +{ +public: + using JsonObject::JsonObject; + + QString href() const { return typedValue(hrefKey); } + void setHref(const QString &href) { insert(hrefKey, href); } + + bool isValid() const override { return contains(hrefKey); } +}; + class LANGUAGESERVERPROTOCOL_EXPORT Diagnostic : public JsonObject { public: @@ -188,6 +199,12 @@ public: { return typedValue(messageKey); } void setMessage(const QString &message) { insert(messageKey, message); } + std::optional codeDescription() const + { return optionalValue(codeDescriptionKey); } + void setCodeDescription(const CodeDescription &codeDescription) + { insert(codeDescriptionKey, codeDescription); } + void clearCodeDescription() { remove(codeDescriptionKey); } + bool isValid() const override { return contains(rangeKey) && contains(messageKey); } };