From 0e2b2cfb0c478939b272fbe7d1a873709d55a96f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 19 Jan 2018 00:56:09 -0800 Subject: [PATCH] Switch to {Request,Notification}Message --- src/messages/text_document_code_action.cc | 4 +--- src/messages/text_document_code_lens.cc | 4 ++-- src/messages/text_document_completion.cc | 5 ++--- src/messages/text_document_did_change.cc | 2 +- src/messages/text_document_did_close.cc | 6 +++--- src/messages/text_document_did_open.cc | 6 +++--- src/messages/text_document_did_save.cc | 6 +++--- src/messages/text_document_document_link.cc | 11 ++++------- src/messages/text_document_document_symbol.cc | 4 +--- src/messages/text_document_formatting.cc | 17 +++++++---------- src/messages/text_document_highlight.cc | 4 +--- src/messages/text_document_hover.cc | 4 +--- src/messages/text_document_range_formatting.cc | 4 +--- src/messages/text_document_rename.cc | 6 ++---- src/messages/text_document_signature_help.cc | 4 +--- .../workspace_did_change_watched_files.cc | 2 +- src/messages/workspace_symbol.cc | 14 ++++++-------- 17 files changed, 40 insertions(+), 63 deletions(-) diff --git a/src/messages/text_document_code_action.cc b/src/messages/text_document_code_action.cc index 1460f6ad..69b65b1f 100644 --- a/src/messages/text_document_code_action.cc +++ b/src/messages/text_document_code_action.cc @@ -251,7 +251,7 @@ optional BuildAutoImplementForFunction(QueryDatabase* db, } struct Ipc_TextDocumentCodeAction - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentCodeAction; // Contains additional diagnostic information about the context in which // a code action is run. @@ -268,8 +268,6 @@ struct Ipc_TextDocumentCodeAction // Context carrying additional information. lsCodeActionContext context; }; - - lsRequestId id; lsCodeActionParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionContext, diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index 5a67c330..24732ab0 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -36,9 +36,9 @@ void Reflect(Reader& visitor, lsCodeLensCommandArguments& value) { #endif using TCodeLens = lsCodeLens; -struct Ipc_TextDocumentCodeLens : public IpcMessage { +struct Ipc_TextDocumentCodeLens + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentCodeLens; - lsRequestId id; lsDocumentCodeLensParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params); diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index 80c3c2f5..e947af39 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -45,10 +45,9 @@ struct lsCompletionParams : lsTextDocumentPositionParams { }; MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context); -struct Ipc_TextDocumentComplete : public IpcMessage { +struct Ipc_TextDocumentComplete + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentCompletion; - - lsRequestId id; lsCompletionParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentComplete, id, params); diff --git a/src/messages/text_document_did_change.cc b/src/messages/text_document_did_change.cc index 0de72c35..b6673a33 100644 --- a/src/messages/text_document_did_change.cc +++ b/src/messages/text_document_did_change.cc @@ -4,7 +4,7 @@ namespace { struct Ipc_TextDocumentDidChange - : public IpcMessage { + : public NotificationMessage { const static IpcId kIpcId = IpcId::TextDocumentDidChange; lsTextDocumentDidChangeParams params; }; diff --git a/src/messages/text_document_did_close.cc b/src/messages/text_document_did_close.cc index 23549f6d..d83f0fa6 100644 --- a/src/messages/text_document_did_close.cc +++ b/src/messages/text_document_did_close.cc @@ -4,12 +4,12 @@ #include "working_files.h" namespace { -struct Ipc_TextDocumentDidClose : public IpcMessage { +struct Ipc_TextDocumentDidClose + : public NotificationMessage { + const static IpcId kIpcId = IpcId::TextDocumentDidClose; struct Params { lsTextDocumentIdentifier textDocument; }; - - const static IpcId kIpcId = IpcId::TextDocumentDidClose; Params params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose::Params, textDocument); diff --git a/src/messages/text_document_did_open.cc b/src/messages/text_document_did_open.cc index 6af0089e..c635dac4 100644 --- a/src/messages/text_document_did_open.cc +++ b/src/messages/text_document_did_open.cc @@ -9,12 +9,12 @@ namespace { // Open, view, change, close file -struct Ipc_TextDocumentDidOpen : public IpcMessage { +struct Ipc_TextDocumentDidOpen + : public NotificationMessage { + const static IpcId kIpcId = IpcId::TextDocumentDidOpen; struct Params { lsTextDocumentItem textDocument; }; - - const static IpcId kIpcId = IpcId::TextDocumentDidOpen; Params params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument); diff --git a/src/messages/text_document_did_save.cc b/src/messages/text_document_did_save.cc index d6e41854..b76ccbda 100644 --- a/src/messages/text_document_did_save.cc +++ b/src/messages/text_document_did_save.cc @@ -6,7 +6,9 @@ #include namespace { -struct Ipc_TextDocumentDidSave : public IpcMessage { +struct Ipc_TextDocumentDidSave + : public NotificationMessage { + const static IpcId kIpcId = IpcId::TextDocumentDidSave; struct Params { // The document that was saved. lsTextDocumentIdentifier textDocument; @@ -15,8 +17,6 @@ struct Ipc_TextDocumentDidSave : public IpcMessage { // when the save notifcation was requested. // std::string text; }; - - const static IpcId kIpcId = IpcId::TextDocumentDidSave; Params params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave::Params, textDocument); diff --git a/src/messages/text_document_document_link.cc b/src/messages/text_document_document_link.cc index bbe8cbde..2d6d2e55 100644 --- a/src/messages/text_document_document_link.cc +++ b/src/messages/text_document_document_link.cc @@ -7,18 +7,15 @@ namespace { struct Ipc_TextDocumentDocumentLink - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentDocumentLink; - - struct DocumentLinkParams { + struct Params { // The document to provide document links for. lsTextDocumentIdentifier textDocument; }; - - lsRequestId id; - DocumentLinkParams params; + Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::DocumentLinkParams, +MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::Params, textDocument); MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink, id, params); REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentLink); diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/text_document_document_symbol.cc index c9d37fdd..71bcc2ff 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/text_document_document_symbol.cc @@ -9,10 +9,8 @@ struct lsDocumentSymbolParams { MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument); struct Ipc_TextDocumentDocumentSymbol - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol; - - lsRequestId id; lsDocumentSymbolParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params); diff --git a/src/messages/text_document_formatting.cc b/src/messages/text_document_formatting.cc index c67dc412..08a8d1a2 100644 --- a/src/messages/text_document_formatting.cc +++ b/src/messages/text_document_formatting.cc @@ -7,19 +7,16 @@ namespace { -struct lsTextDocumentFormattingParams { - lsTextDocumentIdentifier textDocument; - lsFormattingOptions options; -}; -MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options); - struct Ipc_TextDocumentFormatting - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentFormatting; - - lsRequestId id; - lsTextDocumentFormattingParams params; + struct Params { + lsTextDocumentIdentifier textDocument; + lsFormattingOptions options; + }; + Params params; }; +MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting::Params, textDocument, options); MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params); REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting); diff --git a/src/messages/text_document_highlight.cc b/src/messages/text_document_highlight.cc index f3f1f66a..c417c82a 100644 --- a/src/messages/text_document_highlight.cc +++ b/src/messages/text_document_highlight.cc @@ -4,10 +4,8 @@ namespace { struct Ipc_TextDocumentDocumentHighlight - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentDocumentHighlight; - - lsRequestId id; lsTextDocumentPositionParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentHighlight, id, params); diff --git a/src/messages/text_document_hover.cc b/src/messages/text_document_hover.cc index 61e6dc7e..6280b68c 100644 --- a/src/messages/text_document_hover.cc +++ b/src/messages/text_document_hover.cc @@ -38,10 +38,8 @@ std::pair, std::string> GetCommentsAndHover( return {nullopt, ""}; } -struct Ipc_TextDocumentHover : public IpcMessage { +struct Ipc_TextDocumentHover : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentHover; - - lsRequestId id; lsTextDocumentPositionParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params); diff --git a/src/messages/text_document_range_formatting.cc b/src/messages/text_document_range_formatting.cc index 5eb6a2d6..93608905 100644 --- a/src/messages/text_document_range_formatting.cc +++ b/src/messages/text_document_range_formatting.cc @@ -19,10 +19,8 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams, options); struct Ipc_TextDocumentRangeFormatting - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting; - - lsRequestId id; lsTextDocumentRangeFormattingParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params); diff --git a/src/messages/text_document_rename.cc b/src/messages/text_document_rename.cc index 8c62251d..c6076280 100644 --- a/src/messages/text_document_rename.cc +++ b/src/messages/text_document_rename.cc @@ -49,7 +49,8 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db, return edit; } -struct Ipc_TextDocumentRename : public IpcMessage { +struct Ipc_TextDocumentRename : public RequestMessage { + const static IpcId kIpcId = IpcId::TextDocumentRename; struct Params { // The document to format. lsTextDocumentIdentifier textDocument; @@ -62,9 +63,6 @@ struct Ipc_TextDocumentRename : public IpcMessage { // appropriate message set. std::string newName; }; - const static IpcId kIpcId = IpcId::TextDocumentRename; - - lsRequestId id; Params params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename::Params, diff --git a/src/messages/text_document_signature_help.cc b/src/messages/text_document_signature_help.cc index f84df6d0..4f42ff3e 100644 --- a/src/messages/text_document_signature_help.cc +++ b/src/messages/text_document_signature_help.cc @@ -6,10 +6,8 @@ namespace { struct Ipc_TextDocumentSignatureHelp - : public IpcMessage { + : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentSignatureHelp; - - lsRequestId id; lsTextDocumentPositionParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentSignatureHelp, id, params); diff --git a/src/messages/workspace_did_change_watched_files.cc b/src/messages/workspace_did_change_watched_files.cc index 04e05ce0..51e6ef49 100644 --- a/src/messages/workspace_did_change_watched_files.cc +++ b/src/messages/workspace_did_change_watched_files.cc @@ -22,7 +22,7 @@ struct lsDidChangeWatchedFilesParams { MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes); struct Ipc_WorkspaceDidChangeWatchedFiles - : public IpcMessage { + : public NotificationMessage { const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles; lsDidChangeWatchedFilesParams params; }; diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index e1eca3ae..d61b7d93 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -39,16 +39,14 @@ bool InsertSymbolIntoResult(QueryDatabase* db, return true; } -struct lsWorkspaceSymbolParams { - std::string query; -}; -MAKE_REFLECT_STRUCT(lsWorkspaceSymbolParams, query); - -struct Ipc_WorkspaceSymbol : public IpcMessage { +struct Ipc_WorkspaceSymbol : public RequestMessage { const static IpcId kIpcId = IpcId::WorkspaceSymbol; - lsRequestId id; - lsWorkspaceSymbolParams params; + struct Params { + std::string query; + }; + Params params; }; +MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol::Params, query); MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params); REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol);