From 94727b7eaecb7bc9ad65827b8d6d2daf4b021510 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 30 Apr 2019 06:22:32 -0700 Subject: [PATCH] JsonWriter: write "null" if VersionedTextDocumentIdentifier.version is null Fix #387 --- src/message_handler.hh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/message_handler.hh b/src/message_handler.hh index ef428abc..4f0fc039 100644 --- a/src/message_handler.hh +++ b/src/message_handler.hh @@ -165,11 +165,22 @@ struct WorkspaceSymbolParam { }; REFLECT_STRUCT(WorkspaceFolder, uri, name); -inline void Reflect(JsonReader &visitor, DocumentUri &value) { - Reflect(visitor, value.raw_uri); +inline void Reflect(JsonReader &vis, DocumentUri &v) { + Reflect(vis, v.raw_uri); } -inline void Reflect(JsonWriter &visitor, DocumentUri &value) { - Reflect(visitor, value.raw_uri); +inline void Reflect(JsonWriter &vis, DocumentUri &v) { + Reflect(vis, v.raw_uri); +} +inline void Reflect(JsonReader &vis, VersionedTextDocumentIdentifier &v) { + REFLECT_MEMBER(uri); + REFLECT_MEMBER(version); +} +inline void Reflect(JsonWriter &vis, VersionedTextDocumentIdentifier &v) { + vis.StartObject(); + REFLECT_MEMBER(uri); + vis.Key("version"); + Reflect(vis, v.version); + vis.EndObject(); } REFLECT_UNDERLYING(ErrorCode); @@ -182,7 +193,6 @@ REFLECT_UNDERLYING_B(SymbolKind); REFLECT_STRUCT(TextDocumentIdentifier, uri); REFLECT_STRUCT(TextDocumentItem, uri, languageId, version, text); REFLECT_STRUCT(TextEdit, range, newText); -REFLECT_STRUCT(VersionedTextDocumentIdentifier, uri, version); REFLECT_STRUCT(DiagnosticRelatedInformation, location, message); REFLECT_STRUCT(Diagnostic, range, severity, code, source, message, relatedInformation); REFLECT_STRUCT(ShowMessageParam, type, message);