From cc85f196f499baeed5dc5ca0a951b47f165c087a Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sat, 25 Mar 2017 17:22:06 -0700 Subject: [PATCH] never elide data for language server json serialization --- src/language_server_api.h | 16 ++++++++-------- src/serializer.h | 12 +++++++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/language_server_api.h b/src/language_server_api.h index c9b8775a..0c808d57 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -688,14 +688,14 @@ struct lsCompletionOptions { bool resolveProvider = false; // The characters that trigger completion automatically. - std::vector triggerCharacters; + NonElidedVector triggerCharacters; }; MAKE_REFLECT_STRUCT(lsCompletionOptions, resolveProvider, triggerCharacters); // Signature help options. struct lsSignatureHelpOptions { // The characters that trigger signature help automatically. - std::vector triggerCharacters; + NonElidedVector triggerCharacters; }; MAKE_REFLECT_STRUCT(lsSignatureHelpOptions, triggerCharacters); @@ -712,7 +712,7 @@ struct lsDocumentOnTypeFormattingOptions { std::string firstTriggerCharacter; // More trigger characters. - std::vector moreTriggerCharacter; + NonElidedVector moreTriggerCharacter; }; MAKE_REFLECT_STRUCT(lsDocumentOnTypeFormattingOptions, firstTriggerCharacter, moreTriggerCharacter); @@ -726,7 +726,7 @@ MAKE_REFLECT_STRUCT(lsDocumentLinkOptions, resolveProvider); // Execute command options. struct lsExecuteCommandOptions { // The commands to be executed on the server - std::vector commands; + NonElidedVector commands; }; MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, commands); @@ -897,7 +897,7 @@ struct Ipc_TextDocumentDocumentSymbol : public IpcMessage { lsRequestId id; - std::vector result; + NonElidedVector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result); @@ -911,7 +911,7 @@ MAKE_REFLECT_EMPTY_STRUCT(lsCodeLensUserData); struct lsCodeLensCommandArguments { lsDocumentUri uri; lsPosition position; - std::vector locations; + NonElidedVector locations; }; void Reflect(Writer& visitor, lsCodeLensCommandArguments& value); void Reflect(Reader& visitor, lsCodeLensCommandArguments& value); @@ -924,7 +924,7 @@ struct Ipc_TextDocumentCodeLens : public IpcMessage { MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params); struct Out_TextDocumentCodeLens : public lsOutMessage { lsRequestId id; - std::vector> result; + NonElidedVector> result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentCodeLens, jsonrpc, id, result); struct Ipc_CodeLensResolve : public IpcMessage { @@ -953,7 +953,7 @@ struct Ipc_WorkspaceSymbol : public IpcMessage { MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params); struct Out_WorkspaceSymbol : public lsOutMessage { lsRequestId id; - std::vector result; + NonElidedVector result; }; MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result); diff --git a/src/serializer.h b/src/serializer.h index d1e51b1b..cb957831 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -16,7 +16,6 @@ using Reader = rapidjson::GenericValue>; using Writer = rapidjson::PrettyWriter; struct IndexedFile; - #define REFLECT_MEMBER_START() \ if (!ReflectMemberStart(visitor, value)) return #define REFLECT_MEMBER_START1(value) \ @@ -65,6 +64,9 @@ struct IndexedFile; +template +struct NonElidedVector : public std::vector {}; + @@ -154,6 +156,14 @@ void ReflectMember(Writer& visitor, const char* name, std::vector& values) { visitor.EndArray(); } template +void ReflectMember(Writer& visitor, const char* name, NonElidedVector& values) { + visitor.Key(name); + visitor.StartArray(); + for (auto& value : values) + Reflect(visitor, value); + visitor.EndArray(); +} +template void ReflectMember(Writer& visitor, const char* name, optional& value) { if (!value) return;