never elide data for language server json serialization

This commit is contained in:
Jacob Dufault 2017-03-25 17:22:06 -07:00
parent c8afc0f022
commit cc85f196f4
2 changed files with 19 additions and 9 deletions

View File

@ -688,14 +688,14 @@ struct lsCompletionOptions {
bool resolveProvider = false; bool resolveProvider = false;
// The characters that trigger completion automatically. // The characters that trigger completion automatically.
std::vector<std::string> triggerCharacters; NonElidedVector<std::string> triggerCharacters;
}; };
MAKE_REFLECT_STRUCT(lsCompletionOptions, resolveProvider, triggerCharacters); MAKE_REFLECT_STRUCT(lsCompletionOptions, resolveProvider, triggerCharacters);
// Signature help options. // Signature help options.
struct lsSignatureHelpOptions { struct lsSignatureHelpOptions {
// The characters that trigger signature help automatically. // The characters that trigger signature help automatically.
std::vector<std::string> triggerCharacters; NonElidedVector<std::string> triggerCharacters;
}; };
MAKE_REFLECT_STRUCT(lsSignatureHelpOptions, triggerCharacters); MAKE_REFLECT_STRUCT(lsSignatureHelpOptions, triggerCharacters);
@ -712,7 +712,7 @@ struct lsDocumentOnTypeFormattingOptions {
std::string firstTriggerCharacter; std::string firstTriggerCharacter;
// More trigger characters. // More trigger characters.
std::vector<std::string> moreTriggerCharacter; NonElidedVector<std::string> moreTriggerCharacter;
}; };
MAKE_REFLECT_STRUCT(lsDocumentOnTypeFormattingOptions, firstTriggerCharacter, moreTriggerCharacter); MAKE_REFLECT_STRUCT(lsDocumentOnTypeFormattingOptions, firstTriggerCharacter, moreTriggerCharacter);
@ -726,7 +726,7 @@ MAKE_REFLECT_STRUCT(lsDocumentLinkOptions, resolveProvider);
// Execute command options. // Execute command options.
struct lsExecuteCommandOptions { struct lsExecuteCommandOptions {
// The commands to be executed on the server // The commands to be executed on the server
std::vector<std::string> commands; NonElidedVector<std::string> commands;
}; };
MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, commands); MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, commands);
@ -897,7 +897,7 @@ struct Ipc_TextDocumentDocumentSymbol : public IpcMessage<Ipc_TextDocumentDocume
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params); MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params);
struct Out_TextDocumentDocumentSymbol : public lsOutMessage<Out_TextDocumentDocumentSymbol> { struct Out_TextDocumentDocumentSymbol : public lsOutMessage<Out_TextDocumentDocumentSymbol> {
lsRequestId id; lsRequestId id;
std::vector<lsSymbolInformation> result; NonElidedVector<lsSymbolInformation> result;
}; };
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result); MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result);
@ -911,7 +911,7 @@ MAKE_REFLECT_EMPTY_STRUCT(lsCodeLensUserData);
struct lsCodeLensCommandArguments { struct lsCodeLensCommandArguments {
lsDocumentUri uri; lsDocumentUri uri;
lsPosition position; lsPosition position;
std::vector<lsLocation> locations; NonElidedVector<lsLocation> locations;
}; };
void Reflect(Writer& visitor, lsCodeLensCommandArguments& value); void Reflect(Writer& visitor, lsCodeLensCommandArguments& value);
void Reflect(Reader& visitor, lsCodeLensCommandArguments& value); void Reflect(Reader& visitor, lsCodeLensCommandArguments& value);
@ -924,7 +924,7 @@ struct Ipc_TextDocumentCodeLens : public IpcMessage<Ipc_TextDocumentCodeLens> {
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params); MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params);
struct Out_TextDocumentCodeLens : public lsOutMessage<Out_TextDocumentCodeLens> { struct Out_TextDocumentCodeLens : public lsOutMessage<Out_TextDocumentCodeLens> {
lsRequestId id; lsRequestId id;
std::vector<lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>> result; NonElidedVector<lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>> result;
}; };
MAKE_REFLECT_STRUCT(Out_TextDocumentCodeLens, jsonrpc, id, result); MAKE_REFLECT_STRUCT(Out_TextDocumentCodeLens, jsonrpc, id, result);
struct Ipc_CodeLensResolve : public IpcMessage<Ipc_CodeLensResolve> { struct Ipc_CodeLensResolve : public IpcMessage<Ipc_CodeLensResolve> {
@ -953,7 +953,7 @@ struct Ipc_WorkspaceSymbol : public IpcMessage<Ipc_WorkspaceSymbol > {
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params); MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params);
struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> { struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> {
lsRequestId id; lsRequestId id;
std::vector<lsSymbolInformation> result; NonElidedVector<lsSymbolInformation> result;
}; };
MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result); MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result);

View File

@ -16,7 +16,6 @@ using Reader = rapidjson::GenericValue<rapidjson::UTF8<>>;
using Writer = rapidjson::PrettyWriter<rapidjson::StringBuffer>; using Writer = rapidjson::PrettyWriter<rapidjson::StringBuffer>;
struct IndexedFile; struct IndexedFile;
#define REFLECT_MEMBER_START() \ #define REFLECT_MEMBER_START() \
if (!ReflectMemberStart(visitor, value)) return if (!ReflectMemberStart(visitor, value)) return
#define REFLECT_MEMBER_START1(value) \ #define REFLECT_MEMBER_START1(value) \
@ -65,6 +64,9 @@ struct IndexedFile;
template<typename T>
struct NonElidedVector : public std::vector<T> {};
@ -154,6 +156,14 @@ void ReflectMember(Writer& visitor, const char* name, std::vector<T>& values) {
visitor.EndArray(); visitor.EndArray();
} }
template<typename T> template<typename T>
void ReflectMember(Writer& visitor, const char* name, NonElidedVector<T>& values) {
visitor.Key(name);
visitor.StartArray();
for (auto& value : values)
Reflect(visitor, value);
visitor.EndArray();
}
template<typename T>
void ReflectMember(Writer& visitor, const char* name, optional<T>& value) { void ReflectMember(Writer& visitor, const char* name, optional<T>& value) {
if (!value) if (!value)
return; return;