From e84033e9b79533860025f3703023e0a07142c7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Havli=C4=8Dek?= Date: Wed, 22 Oct 2025 13:24:25 +0000 Subject: [PATCH 1/2] Add ShowMessageParams --- llvm/include/llvm/Support/LSP/Protocol.h | 17 +++++++++++++++++ llvm/lib/Support/LSP/Protocol.cpp | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/llvm/include/llvm/Support/LSP/Protocol.h b/llvm/include/llvm/Support/LSP/Protocol.h index e38203a8b4a39..355b84f8e21f4 100644 --- a/llvm/include/llvm/Support/LSP/Protocol.h +++ b/llvm/include/llvm/Support/LSP/Protocol.h @@ -1244,6 +1244,23 @@ struct CodeAction { /// Add support for JSON serialization. llvm::json::Value toJSON(const CodeAction &); +//===----------------------------------------------------------------------===// +// ShowMessageParams +//===----------------------------------------------------------------------===// + +enum class MessageType { Error = 1, Warning = 2, Info = 3, Log = 4, Debug = 5 }; + +struct ShowMessageParams { + ShowMessageParams(MessageType Type, std::string Message) + : type(Type), message(Message) {} + MessageType type; + /// The actual message. + std::string message; +}; + +/// Add support for JSON serialization. +llvm::json::Value toJSON(const ShowMessageParams &Params); + } // namespace lsp } // namespace llvm diff --git a/llvm/lib/Support/LSP/Protocol.cpp b/llvm/lib/Support/LSP/Protocol.cpp index f22126345a435..10ee6cd02c789 100644 --- a/llvm/lib/Support/LSP/Protocol.cpp +++ b/llvm/lib/Support/LSP/Protocol.cpp @@ -1041,3 +1041,14 @@ llvm::json::Value llvm::lsp::toJSON(const CodeAction &Value) { CodeAction["edit"] = *Value.edit; return std::move(CodeAction); } + +//===----------------------------------------------------------------------===// +// ShowMessageParams +//===----------------------------------------------------------------------===// + +llvm::json::Value llvm::lsp::toJSON(const ShowMessageParams &Params) { + return llvm::json::Object{ + {"type", static_cast(Params.type)}, + {"message", Params.message}, + }; +} From ccc1fdc7f7f521513108146eceb838bbd5205c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Havli=C4=8Dek?= Date: Wed, 22 Oct 2025 13:39:14 +0000 Subject: [PATCH 2/2] MessageActionItems --- llvm/include/llvm/Support/LSP/Protocol.h | 10 ++++++++++ llvm/lib/Support/LSP/Protocol.cpp | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/LSP/Protocol.h b/llvm/include/llvm/Support/LSP/Protocol.h index 355b84f8e21f4..00bd3eb73234a 100644 --- a/llvm/include/llvm/Support/LSP/Protocol.h +++ b/llvm/include/llvm/Support/LSP/Protocol.h @@ -1250,14 +1250,24 @@ llvm::json::Value toJSON(const CodeAction &); enum class MessageType { Error = 1, Warning = 2, Info = 3, Log = 4, Debug = 5 }; +struct MessageActionItem { + /// A short title like 'Retry', 'Open Log' etc. + std::string title; +}; + struct ShowMessageParams { ShowMessageParams(MessageType Type, std::string Message) : type(Type), message(Message) {} MessageType type; /// The actual message. std::string message; + /// The message action items to present. + std::optional> actions; }; +/// Add support for JSON serialization. +llvm::json::Value toJSON(const MessageActionItem &Params); + /// Add support for JSON serialization. llvm::json::Value toJSON(const ShowMessageParams &Params); diff --git a/llvm/lib/Support/LSP/Protocol.cpp b/llvm/lib/Support/LSP/Protocol.cpp index 10ee6cd02c789..968e2141d4f08 100644 --- a/llvm/lib/Support/LSP/Protocol.cpp +++ b/llvm/lib/Support/LSP/Protocol.cpp @@ -1047,8 +1047,15 @@ llvm::json::Value llvm::lsp::toJSON(const CodeAction &Value) { //===----------------------------------------------------------------------===// llvm::json::Value llvm::lsp::toJSON(const ShowMessageParams &Params) { - return llvm::json::Object{ + auto Out = llvm::json::Object{ {"type", static_cast(Params.type)}, {"message", Params.message}, }; + if (Params.actions) + Out["actions"] = *Params.actions; + return Out; +} + +llvm::json::Value llvm::lsp::toJSON(const MessageActionItem &Params) { + return llvm::json::Object{{"title", Params.title}}; }