From b9a2b68e9308071827c00594ccc59f3bd2b18f00 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Mon, 18 Dec 2017 23:54:00 -0800 Subject: [PATCH] Never elide `result` response for hover. --- src/messages/text_document_hover.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/messages/text_document_hover.cc b/src/messages/text_document_hover.cc index 0c05605c..04669a8b 100644 --- a/src/messages/text_document_hover.cc +++ b/src/messages/text_document_hover.cc @@ -51,7 +51,20 @@ struct Out_TextDocumentHover : public lsOutMessage { optional result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentHover::Result, contents, range); -MAKE_REFLECT_STRUCT(Out_TextDocumentHover, jsonrpc, id, result); +void Reflect(Writer& visitor, Out_TextDocumentHover& value) { + REFLECT_MEMBER_START(); + REFLECT_MEMBER(jsonrpc); + REFLECT_MEMBER(id); + if (value.result) + REFLECT_MEMBER(result); + else { + // Empty optional<> is elided by the default serializer, we need to write + // |null| to be compliant with the LSP. + visitor.Key("result"); + visitor.Null(); + } + REFLECT_MEMBER_END(); +} struct TextDocumentHoverHandler : BaseMessageHandler { void Run(Ipc_TextDocumentHover* request) override {