From e37a6c814b29308bee51028b2cd8b9f7b0021fab Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 21 Mar 2018 21:05:25 -0700 Subject: [PATCH] Remove global list of message ids. Also do some naming cleanup. Also remove xmacros. --- src/command_line.cc | 71 ++++++------------- src/diagnostics_engine.cc | 2 +- src/import_pipeline.cc | 4 +- src/ipc.cc | 30 ++------ src/ipc.h | 40 +++-------- src/lsp.h | 11 +-- src/match.cc | 2 +- src/message_handler.cc | 6 +- src/message_handler.h | 5 +- src/messages/cquery_base.cc | 22 +++--- src/messages/cquery_call_hierarchy.cc | 28 +++++--- src/messages/cquery_callers.cc | 19 ++--- src/messages/cquery_derived.cc | 19 ++--- src/messages/cquery_did_view.cc | 22 +++--- src/messages/cquery_file_info.cc | 19 ++--- src/messages/cquery_freshen_index.cc | 20 +++--- src/messages/cquery_index_file.cc | 19 ++--- src/messages/cquery_inheritance_hierarchy.cc | 25 ++++--- src/messages/cquery_member_hierarchy.cc | 26 ++++--- src/messages/cquery_random.cc | 20 +++--- src/messages/cquery_vars.cc | 21 +++--- src/messages/cquery_wait.cc | 19 ++--- src/messages/exit.cc | 16 ++--- src/messages/initialize.cc | 21 +++--- src/messages/shutdown.cc | 19 ++--- src/messages/text_document_code_action.cc | 27 +++---- src/messages/text_document_code_lens.cc | 22 +++--- src/messages/text_document_completion.cc | 26 +++---- src/messages/text_document_definition.cc | 21 +++--- src/messages/text_document_did_change.cc | 21 +++--- src/messages/text_document_did_close.cc | 25 ++++--- src/messages/text_document_did_open.cc | 24 ++++--- src/messages/text_document_did_save.cc | 24 ++++--- .../text_document_document_highlight.cc | 22 +++--- src/messages/text_document_document_link.cc | 24 ++++--- src/messages/text_document_document_symbol.cc | 22 +++--- src/messages/text_document_formatting.cc | 23 +++--- src/messages/text_document_hover.cc | 18 ++--- .../text_document_range_formatting.cc | 22 +++--- src/messages/text_document_references.cc | 27 +++---- src/messages/text_document_rename.cc | 20 +++--- src/messages/text_document_signature_help.cc | 23 +++--- src/messages/text_document_type_definition.cc | 21 +++--- .../workspace_did_change_configuration.cc | 20 +++--- .../workspace_did_change_watched_files.cc | 20 +++--- src/messages/workspace_execute_command.cc | 21 +++--- src/messages/workspace_symbol.cc | 20 +++--- src/methods.inc | 60 ---------------- src/queue_manager.cc | 4 +- src/queue_manager.h | 4 +- 50 files changed, 517 insertions(+), 550 deletions(-) delete mode 100644 src/methods.inc diff --git a/src/command_line.cc b/src/command_line.cc index 8a58da02..6229ad33 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -57,20 +57,15 @@ namespace { std::vector kEmptyArgs; // This function returns true if e2e timing should be displayed for the given -// IpcId. -bool ShouldDisplayIpcTiming(IpcId id) { - switch (id) { - case IpcId::TextDocumentPublishDiagnostics: - case IpcId::CqueryPublishInactiveRegions: - case IpcId::Unknown: - return false; - default: - return true; - } +// MethodId. +bool ShouldDisplayMethodTiming(MethodType type) { + return + type != kMethodType_TextDocumentPublishDiagnostics && + type != kMethodType_CqueryPublishInactiveRegions && + type != kMethodType_Unknown; + return true; } -REGISTER_IPC_MESSAGE(Ipc_CancelRequest); - void PrintHelp() { std::cout << R"help(cquery is a low-latency C/C++/Objective-C language server. @@ -146,16 +141,16 @@ bool QueryDbMainLoop(Config* config, queue->for_querydb.DequeueAll(); bool did_work = messages.size(); for (auto& message : messages) { + // TODO: Consider using std::unordered_map to lookup the handler for (MessageHandler* handler : *MessageHandler::message_handlers) { - if (handler->GetId() == message->method_id) { + if (handler->GetMethodType() == message->GetMethodType()) { handler->Run(std::move(message)); break; } } if (message) { - LOG_S(FATAL) << "Exiting; unhandled IPC message " - << IpcIdToString(message->method_id); + LOG_S(FATAL) << "Exiting; no handler for " << message->GetMethodType(); exit(1); } } @@ -199,7 +194,7 @@ void RunQueryDbThread(const std::string& bin_name, out.error.message = "Dropping completion request; a newer request " "has come in that will be serviced instead."; - QueueManager::WriteStdout(IpcId::Unknown, out); + QueueManager::WriteStdout(kMethodType_Unknown, out); } }); @@ -278,7 +273,7 @@ void RunQueryDbThread(const std::string& bin_name, // // |ipc| is connected to a server. void LaunchStdinLoop(Config* config, - std::unordered_map* request_times) { + std::unordered_map* request_times) { // If flushing cin requires flushing cout there could be deadlocks in some // clients. std::cin.tie(nullptr); @@ -301,47 +296,28 @@ void LaunchStdinLoop(Config* config, out.id = id; out.error.code = lsErrorCodes::InvalidParams; out.error.message = std::move(*err); - queue->WriteStdout(IpcId::Unknown, out); + queue->WriteStdout(kMethodType_Unknown, out); } } continue; } // Cache |method_id| so we can access it after moving |message|. - IpcId method_id = message->method_id; - (*request_times)[method_id] = Timer(); + MethodType method_type = message->GetMethodType(); + (*request_times)[method_type] = Timer(); - switch (method_id) { - case IpcId::Initialized: { - // TODO: don't send output until we get this notification - break; - } - - case IpcId::CancelRequest: { - // TODO: support cancellation - break; - } - - case IpcId::Exit: -#define CASE(name, method) case IpcId::name: -#include "methods.inc" -#undef CASE - queue->for_querydb.PushBack(std::move(message)); - break; - - case IpcId::Unknown: - break; - } + LOG_S(ERROR) << "!! Got message of type " << method_type; + queue->for_querydb.PushBack(std::move(message)); // If the message was to exit then querydb will take care of the actual // exit. Stop reading from stdin since it might be detached. - if (method_id == IpcId::Exit) + if (method_type == kMethodType_Exit) break; } }); } -void LaunchStdoutThread(std::unordered_map* request_times, +void LaunchStdoutThread(std::unordered_map* request_times, MultiQueueWaiter* waiter) { WorkThread::StartThread("stdout", [=]() { auto* queue = QueueManager::instance(); @@ -354,10 +330,9 @@ void LaunchStdoutThread(std::unordered_map* request_times, } for (auto& message : messages) { - if (ShouldDisplayIpcTiming(message.id)) { - Timer time = (*request_times)[message.id]; - time.ResetAndPrint("[e2e] Running " + - std::string(IpcIdToString(message.id))); + if (ShouldDisplayMethodTiming(message.method)) { + Timer time = (*request_times)[message.method]; + time.ResetAndPrint("[e2e] Running " + std::string(message.method)); } RecordOutput(message.content); @@ -374,7 +349,7 @@ void LanguageServerMain(const std::string& bin_name, MultiQueueWaiter* querydb_waiter, MultiQueueWaiter* indexer_waiter, MultiQueueWaiter* stdout_waiter) { - std::unordered_map request_times; + std::unordered_map request_times; LaunchStdinLoop(config, &request_times); diff --git a/src/diagnostics_engine.cc b/src/diagnostics_engine.cc index 36453ea2..75dfe4a4 100644 --- a/src/diagnostics_engine.cc +++ b/src/diagnostics_engine.cc @@ -30,6 +30,6 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files, Out_TextDocumentPublishDiagnostics out; out.params.uri = lsDocumentUri::FromPath(path); out.params.diagnostics = diagnostics; - QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out); + QueueManager::WriteStdout(kMethodType_TextDocumentPublishDiagnostics, out); } } diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index 27d52411..90e1ac09 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -136,7 +136,7 @@ struct ActiveThread { GetCurrentTimeInMilliseconds() + config_->progressReportFrequencyMs; } - QueueManager::WriteStdout(IpcId::Unknown, out); + QueueManager::WriteStdout(kMethodType_Unknown, out); } Config* config_; @@ -400,7 +400,7 @@ void ParseFile(Config* config, out.id = request.id; out.error.code = lsErrorCodes::InternalError; out.error.message = "Failed to index " + path_to_index; - QueueManager::WriteStdout(IpcId::Unknown, out); + QueueManager::WriteStdout(kMethodType_Unknown, out); } return; } diff --git a/src/ipc.cc b/src/ipc.cc index 90c75f9b..81139319 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -1,30 +1,10 @@ #include "ipc.h" -#include - -const char* IpcIdToString(IpcId id) { - switch (id) { - case IpcId::CancelRequest: - return "$/cancelRequest"; - case IpcId::Initialized: - return "initialized"; - case IpcId::Exit: - return "exit"; - -#define CASE(name, method) \ - case IpcId::name: \ - return method; -#include "methods.inc" -#undef CASE - - case IpcId::Unknown: - return "$unknown"; - } - - CQUERY_UNREACHABLE("missing IpcId string name"); -} - -BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {} +const char* kMethodType_Unknown = "$unknown"; +const char* kMethodType_Exit = "exit"; +const char* kMethodType_TextDocumentPublishDiagnostics = "textDocument/publishDiagnostics"; +const char* kMethodType_CqueryPublishInactiveRegions = "$cquery/publishInactiveRegions"; +const char* kMethodType_CqueryPublishSemanticHighlighting = "$cquery/publishSemanticHighlighting"; BaseIpcMessage::~BaseIpcMessage() = default; diff --git a/src/ipc.h b/src/ipc.h index 3992e058..0718d7fe 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -7,48 +7,26 @@ using lsRequestId = std::variant; -enum class IpcId : int { - // Language server specific requests. - CancelRequest = 0, - Initialized, - Exit, +using MethodType = std::string; -#define CASE(x, _) x, -#include "methods.inc" -#undef CASE - - // Internal implementation detail. - Unknown, -}; -MAKE_ENUM_HASHABLE(IpcId) -MAKE_REFLECT_TYPE_PROXY(IpcId) -const char* IpcIdToString(IpcId id); +extern const char* kMethodType_Unknown; +extern const char* kMethodType_Exit; +extern const char* kMethodType_TextDocumentPublishDiagnostics; +extern const char* kMethodType_CqueryPublishInactiveRegions; +extern const char* kMethodType_CqueryPublishSemanticHighlighting; struct BaseIpcMessage { - const IpcId method_id; - BaseIpcMessage(IpcId method_id); virtual ~BaseIpcMessage(); + virtual MethodType GetMethodType() const = 0; virtual lsRequestId GetRequestId(); - - template - T* As() { - assert(method_id == T::kIpcId); - return static_cast(this); - } }; -template struct RequestMessage : public BaseIpcMessage { - // number | string, actually no null + // number or string, actually no null lsRequestId id; - RequestMessage() : BaseIpcMessage(T::kIpcId) {} - lsRequestId GetRequestId() override { return id; } }; // NotificationMessage does not have |id|. -template -struct NotificationMessage : public BaseIpcMessage { - NotificationMessage() : BaseIpcMessage(T::kIpcId) {} -}; +struct NotificationMessage : public BaseIpcMessage {}; diff --git a/src/lsp.h b/src/lsp.h index b44024ce..e0d70cb5 100644 --- a/src/lsp.h +++ b/src/lsp.h @@ -24,7 +24,7 @@ ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -#define REGISTER_IPC_MESSAGE(type) \ +#define REGISTER_IN_MESSAGE(type) \ static MessageRegistryRegister type##message_handler_instance_; struct MessageRegistry { @@ -44,7 +44,8 @@ struct MessageRegistry { template struct MessageRegistryRegister { MessageRegistryRegister() { - std::string method_name = IpcIdToString(T::kIpcId); + T dummy; + std::string method_name = dummy.GetMethodType(); MessageRegistry::instance()->allocators[method_name] = [](Reader& visitor, std::unique_ptr* message) { *message = std::make_unique(); @@ -334,12 +335,6 @@ struct lsFormattingOptions { }; MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces); -// Cancel an existing request. -struct Ipc_CancelRequest : public RequestMessage { - static const IpcId kIpcId = IpcId::CancelRequest; -}; -MAKE_REFLECT_STRUCT(Ipc_CancelRequest, id); - // MarkedString can be used to render human readable text. It is either a // markdown string or a code-block that provides a language and a code snippet. // The language identifier is sematically equal to the optional language diff --git a/src/match.cc b/src/match.cc index bec67dcf..21f0b55f 100644 --- a/src/match.cc +++ b/src/match.cc @@ -32,7 +32,7 @@ optional Matcher::Create(const std::string& search) { out.params.type = lsMessageType::Error; out.params.message = "cquery: Parsing EMCAScript regex \"" + search + "\" failed; " + e.what(); - QueueManager::WriteStdout(IpcId::Unknown, out); + QueueManager::WriteStdout(kMethodType_Unknown, out); return nullopt; } } diff --git a/src/message_handler.cc b/src/message_handler.cc index a00bc859..2236d6aa 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -99,7 +99,7 @@ bool FindFileOrFail(QueryDatabase* db, out.error.code = lsErrorCodes::InternalError; out.error.message = "Unable to find file " + absolute_path; } - QueueManager::WriteStdout(IpcId::Unknown, out); + QueueManager::WriteStdout(kMethodType_Unknown, out); } return false; @@ -114,7 +114,7 @@ void EmitInactiveLines(WorkingFile* working_file, if (ls_skipped) out.params.inactiveRegions.push_back(*ls_skipped); } - QueueManager::WriteStdout(IpcId::CqueryPublishInactiveRegions, out); + QueueManager::WriteStdout(kMethodType_CqueryPublishInactiveRegions, out); } void EmitSemanticHighlighting(QueryDatabase* db, @@ -277,7 +277,7 @@ void EmitSemanticHighlighting(QueryDatabase* db, for (auto& entry : grouped_symbols) if (entry.second.ranges.size()) out.params.symbols.push_back(entry.second); - QueueManager::WriteStdout(IpcId::CqueryPublishSemanticHighlighting, out); + QueueManager::WriteStdout(kMethodType_CqueryPublishSemanticHighlighting, out); } bool ShouldIgnoreFileForIndexing(const std::string& path) { diff --git a/src/message_handler.h b/src/message_handler.h index d5b79d48..a68990f4 100644 --- a/src/message_handler.h +++ b/src/message_handler.h @@ -86,7 +86,7 @@ struct MessageHandler { CodeCompleteCache* non_global_code_complete_cache = nullptr; CodeCompleteCache* signature_cache = nullptr; - virtual IpcId GetId() const = 0; + virtual MethodType GetMethodType() const = 0; virtual void Run(std::unique_ptr message) = 0; static std::vector* message_handlers; @@ -100,9 +100,8 @@ struct BaseMessageHandler : MessageHandler { virtual void Run(TMessage* message) = 0; // MessageHandler: - IpcId GetId() const override { return TMessage::kIpcId; } void Run(std::unique_ptr message) override { - Run(message->As()); + Run(static_cast(message.get())); } }; diff --git a/src/messages/cquery_base.cc b/src/messages/cquery_base.cc index 6a11a064..05963f85 100644 --- a/src/messages/cquery_base.cc +++ b/src/messages/cquery_base.cc @@ -3,15 +3,21 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryBase : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryBase; + +MethodType kMethodType = "$cquery/base"; + +struct In_CqueryBase : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryBase, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryBase); +MAKE_REFLECT_STRUCT(In_CqueryBase, id, params); +REGISTER_IN_MESSAGE(In_CqueryBase); -struct CqueryBaseHandler : BaseMessageHandler { - void Run(Ipc_CqueryBase* request) override { +struct Handler_CqueryBase : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_CqueryBase* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -39,8 +45,8 @@ struct CqueryBaseHandler : BaseMessageHandler { break; } } - QueueManager::WriteStdout(IpcId::CqueryBase, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryBaseHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryBase); } // namespace diff --git a/src/messages/cquery_call_hierarchy.cc b/src/messages/cquery_call_hierarchy.cc index 594ce931..7143680b 100644 --- a/src/messages/cquery_call_hierarchy.cc +++ b/src/messages/cquery_call_hierarchy.cc @@ -5,6 +5,9 @@ #include namespace { + +MethodType kMethodType = "$cquery/callHierarchy"; + enum class CallType : uint8_t { Direct = 0, Base = 1, @@ -17,9 +20,9 @@ bool operator&(CallType lhs, CallType rhs) { return uint8_t(lhs) & uint8_t(rhs); } -struct Ipc_CqueryCallHierarchy - : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryCallHierarchy; +struct In_CqueryCallHierarchy : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + struct Params { // If id is specified, expand a node; otherwise textDocument+position should // be specified for building the root and |levels| of nodes below. @@ -38,8 +41,9 @@ struct Ipc_CqueryCallHierarchy int levels = 1; }; Params params; + }; -MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params, +MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy::Params, textDocument, position, id, @@ -47,8 +51,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params, callType, detailedName, levels); -MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchy); +MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy, id, params); +REGISTER_IN_MESSAGE(In_CqueryCallHierarchy); struct Out_CqueryCallHierarchy : public lsOutMessage { struct Entry { @@ -155,8 +159,10 @@ bool Expand(MessageHandler* m, return true; } -struct CqueryCallHierarchyHandler - : BaseMessageHandler { +struct Handler_CqueryCallHierarchy + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + optional BuildInitial(QueryFuncId root_id, bool callee, CallType call_type, @@ -178,7 +184,7 @@ struct CqueryCallHierarchyHandler return entry; } - void Run(Ipc_CqueryCallHierarchy* request) override { + void Run(In_CqueryCallHierarchy* request) override { const auto& params = request->params; Out_CqueryCallHierarchy out; out.id = request->id; @@ -209,9 +215,9 @@ struct CqueryCallHierarchyHandler } } - QueueManager::WriteStdout(IpcId::CqueryCallHierarchy, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryCallHierarchyHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryCallHierarchy); } // namespace diff --git a/src/messages/cquery_callers.cc b/src/messages/cquery_callers.cc index 088b9313..4214253f 100644 --- a/src/messages/cquery_callers.cc +++ b/src/messages/cquery_callers.cc @@ -3,15 +3,18 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryCallers : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryCallers; +MethodType kMethodType = "$cquery/callers"; + +struct In_CqueryCallers : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryCallers, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryCallers); +MAKE_REFLECT_STRUCT(In_CqueryCallers, id, params); +REGISTER_IN_MESSAGE(In_CqueryCallers); -struct CqueryCallersHandler : BaseMessageHandler { - void Run(Ipc_CqueryCallers* request) override { +struct Handler_CqueryCallers : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryCallers* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -38,8 +41,8 @@ struct CqueryCallersHandler : BaseMessageHandler { break; } } - QueueManager::WriteStdout(IpcId::CqueryCallers, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryCallersHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryCallers); } // namespace diff --git a/src/messages/cquery_derived.cc b/src/messages/cquery_derived.cc index 08e7033f..e43da912 100644 --- a/src/messages/cquery_derived.cc +++ b/src/messages/cquery_derived.cc @@ -3,15 +3,18 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryDerived : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryDerived; +MethodType kMethodType = "$cquery/derived"; + +struct In_CqueryDerived : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryDerived, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryDerived); +MAKE_REFLECT_STRUCT(In_CqueryDerived, id, params); +REGISTER_IN_MESSAGE(In_CqueryDerived); -struct CqueryDerivedHandler : BaseMessageHandler { - void Run(Ipc_CqueryDerived* request) override { +struct Handler_CqueryDerived : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryDerived* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -39,8 +42,8 @@ struct CqueryDerivedHandler : BaseMessageHandler { break; } } - QueueManager::WriteStdout(IpcId::CqueryDerived, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryDerivedHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryDerived); } // namespace diff --git a/src/messages/cquery_did_view.cc b/src/messages/cquery_did_view.cc index 7b394996..d01f6d95 100644 --- a/src/messages/cquery_did_view.cc +++ b/src/messages/cquery_did_view.cc @@ -3,21 +3,23 @@ #include "working_files.h" namespace { -struct Ipc_CqueryTextDocumentDidView - : public NotificationMessage { - const static IpcId kIpcId = IpcId::CqueryTextDocumentDidView; +MethodType kMethodType = "$cquery/textDocumentDidView"; + +struct In_CqueryTextDocumentDidView : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { lsDocumentUri textDocumentUri; }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView::Params, textDocumentUri); -MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryTextDocumentDidView); +MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView::Params, textDocumentUri); +MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView, params); +REGISTER_IN_MESSAGE(In_CqueryTextDocumentDidView); -struct CqueryDidViewHandler - : BaseMessageHandler { - void Run(Ipc_CqueryTextDocumentDidView* request) override { +struct Handler_CqueryDidView + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryTextDocumentDidView* request) override { std::string path = request->params.textDocumentUri.GetPath(); WorkingFile* working_file = working_files->GetFileByFilename(path); @@ -34,5 +36,5 @@ struct CqueryDidViewHandler } } }; -REGISTER_MESSAGE_HANDLER(CqueryDidViewHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryDidView); } // namespace diff --git a/src/messages/cquery_file_info.cc b/src/messages/cquery_file_info.cc index 1fa9998b..22db960c 100644 --- a/src/messages/cquery_file_info.cc +++ b/src/messages/cquery_file_info.cc @@ -3,17 +3,19 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "$cquery/fileInfo"; + struct lsDocumentSymbolParams { lsTextDocumentIdentifier textDocument; }; MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument); -struct Ipc_CqueryFileInfo : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryFileInfo; +struct In_CqueryFileInfo : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsDocumentSymbolParams params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryFileInfo, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryFileInfo); +MAKE_REFLECT_STRUCT(In_CqueryFileInfo, id, params); +REGISTER_IN_MESSAGE(In_CqueryFileInfo); struct Out_CqueryFileInfo : public lsOutMessage { lsRequestId id; @@ -21,8 +23,9 @@ struct Out_CqueryFileInfo : public lsOutMessage { }; MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result); -struct CqueryFileInfoHandler : BaseMessageHandler { - void Run(Ipc_CqueryFileInfo* request) override { +struct Handler_CqueryFileInfo : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryFileInfo* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -37,8 +40,8 @@ struct CqueryFileInfoHandler : BaseMessageHandler { out.result.language = file->def->language; out.result.includes = file->def->includes; out.result.inactive_regions = file->def->inactive_regions; - QueueManager::WriteStdout(IpcId::CqueryFileInfo, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryFileInfoHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryFileInfo); } // namespace diff --git a/src/messages/cquery_freshen_index.cc b/src/messages/cquery_freshen_index.cc index bb08b2a1..0b7cc073 100644 --- a/src/messages/cquery_freshen_index.cc +++ b/src/messages/cquery_freshen_index.cc @@ -13,9 +13,10 @@ #include namespace { -struct Ipc_CqueryFreshenIndex - : public NotificationMessage { - const static IpcId kIpcId = IpcId::CqueryFreshenIndex; +MethodType kMethodType = "$cquery/freshenIndex"; + +struct In_CqueryFreshenIndex : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { bool dependencies = true; std::vector whitelist; @@ -23,15 +24,16 @@ struct Ipc_CqueryFreshenIndex }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex::Params, +MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex::Params, dependencies, whitelist, blacklist); -MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryFreshenIndex); +MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex, params); +REGISTER_IN_MESSAGE(In_CqueryFreshenIndex); -struct CqueryFreshenIndexHandler : BaseMessageHandler { - void Run(Ipc_CqueryFreshenIndex* request) override { +struct Handler_CqueryFreshenIndex : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryFreshenIndex* request) override { LOG_S(INFO) << "Freshening " << project->entries.size() << " files"; // TODO: think about this flow and test it more. @@ -90,5 +92,5 @@ struct CqueryFreshenIndexHandler : BaseMessageHandler { time.ResetAndPrint("[perf] Dispatched $cquery/freshenIndex index requests"); } }; -REGISTER_MESSAGE_HANDLER(CqueryFreshenIndexHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryFreshenIndex); } // namespace diff --git a/src/messages/cquery_index_file.cc b/src/messages/cquery_index_file.cc index 59ef02f5..0d188ea6 100644 --- a/src/messages/cquery_index_file.cc +++ b/src/messages/cquery_index_file.cc @@ -6,8 +6,10 @@ #include namespace { -struct Ipc_CqueryIndexFile : public NotificationMessage { - static constexpr IpcId kIpcId = IpcId::CqueryIndexFile; +MethodType kMethodType = "$cquery/indexFile"; + +struct In_CqueryIndexFile : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { std::string path; std::vector args; @@ -16,16 +18,17 @@ struct Ipc_CqueryIndexFile : public NotificationMessage { }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile::Params, +MAKE_REFLECT_STRUCT(In_CqueryIndexFile::Params, path, args, is_interactive, contents); -MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryIndexFile); +MAKE_REFLECT_STRUCT(In_CqueryIndexFile, params); +REGISTER_IN_MESSAGE(In_CqueryIndexFile); -struct CqueryIndexFileHandler : BaseMessageHandler { - void Run(Ipc_CqueryIndexFile* request) override { +struct Handler_CqueryIndexFile : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_CqueryIndexFile* request) override { LOG_S(INFO) << "Indexing file " << request->params.path; QueueManager::instance()->index_request.PushBack( Index_Request(NormalizePath(request->params.path), request->params.args, @@ -33,5 +36,5 @@ struct CqueryIndexFileHandler : BaseMessageHandler { ICacheManager::Make(config))); } }; -REGISTER_MESSAGE_HANDLER(CqueryIndexFileHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryIndexFile); } // namespace diff --git a/src/messages/cquery_inheritance_hierarchy.cc b/src/messages/cquery_inheritance_hierarchy.cc index d81df343..3c024619 100644 --- a/src/messages/cquery_inheritance_hierarchy.cc +++ b/src/messages/cquery_inheritance_hierarchy.cc @@ -3,9 +3,10 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryInheritanceHierarchy - : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy; +MethodType kMethodType = "$cquery/inheritanceHierarchy"; + +struct In_CqueryInheritanceHierarchy : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { // If id+kind are specified, expand a node; otherwise textDocument+position // should be specified for building the root and |levels| of nodes below. @@ -23,7 +24,7 @@ struct Ipc_CqueryInheritanceHierarchy Params params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params, +MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy::Params, textDocument, position, id, @@ -31,8 +32,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params, derived, detailedName, levels); -MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchy); +MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy, id, params); +REGISTER_IN_MESSAGE(In_CqueryInheritanceHierarchy); struct Out_CqueryInheritanceHierarchy : public lsOutMessage { @@ -127,8 +128,10 @@ bool Expand(MessageHandler* m, m->db->types[entry->id.id]); } -struct CqueryInheritanceHierarchyHandler - : BaseMessageHandler { +struct Handler_CqueryInheritanceHierarchy + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + optional BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) { Out_CqueryInheritanceHierarchy::Entry entry; @@ -138,7 +141,7 @@ struct CqueryInheritanceHierarchyHandler return entry; } - void Run(Ipc_CqueryInheritanceHierarchy* request) override { + void Run(In_CqueryInheritanceHierarchy* request) override { const auto& params = request->params; Out_CqueryInheritanceHierarchy out; out.id = request->id; @@ -171,9 +174,9 @@ struct CqueryInheritanceHierarchyHandler } } - QueueManager::WriteStdout(IpcId::CqueryInheritanceHierarchy, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryInheritanceHierarchyHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryInheritanceHierarchy); } // namespace diff --git a/src/messages/cquery_member_hierarchy.cc b/src/messages/cquery_member_hierarchy.cc index 8245c857..b4f03763 100644 --- a/src/messages/cquery_member_hierarchy.cc +++ b/src/messages/cquery_member_hierarchy.cc @@ -3,9 +3,11 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryMemberHierarchy - : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryMemberHierarchy; +MethodType kMethodType = "$cquery/memberHierarchy"; + +struct In_CqueryMemberHierarchy : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + struct Params { // If id is specified, expand a node; otherwise textDocument+position should // be specified for building the root and |levels| of nodes below. @@ -20,14 +22,14 @@ struct Ipc_CqueryMemberHierarchy Params params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy::Params, +MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy::Params, textDocument, position, id, detailedName, levels); -MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchy); +MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy, id, params); +REGISTER_IN_MESSAGE(In_CqueryMemberHierarchy); struct Out_CqueryMemberHierarchy : public lsOutMessage { @@ -158,8 +160,10 @@ bool Expand(MessageHandler* m, return true; } -struct CqueryMemberHierarchyHandler - : BaseMessageHandler { +struct Handler_CqueryMemberHierarchy + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + optional BuildInitial(QueryFuncId root_id, bool detailed_name, int levels) { @@ -202,7 +206,7 @@ struct CqueryMemberHierarchyHandler return entry; } - void Run(Ipc_CqueryMemberHierarchy* request) override { + void Run(In_CqueryMemberHierarchy* request) override { const auto& params = request->params; Out_CqueryMemberHierarchy out; out.id = request->id; @@ -246,9 +250,9 @@ struct CqueryMemberHierarchyHandler } } - QueueManager::WriteStdout(IpcId::CqueryMemberHierarchy, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryMemberHierarchyHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryMemberHierarchy); } // namespace diff --git a/src/messages/cquery_random.cc b/src/messages/cquery_random.cc index 510088c0..bf7c4668 100644 --- a/src/messages/cquery_random.cc +++ b/src/messages/cquery_random.cc @@ -7,11 +7,13 @@ #include namespace { -struct Ipc_CqueryRandom : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryRandom; +MethodType kMethodType = "$cquery/random"; + +struct In_CqueryRandom : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } }; -MAKE_REFLECT_STRUCT(Ipc_CqueryRandom, id); -REGISTER_IPC_MESSAGE(Ipc_CqueryRandom); +MAKE_REFLECT_STRUCT(In_CqueryRandom, id); +REGISTER_IN_MESSAGE(In_CqueryRandom); const double kDeclWeight = 3; const double kDamping = 0.1; @@ -44,8 +46,10 @@ void Add(const std::unordered_map& sym2id, } } -struct CqueryRandomHandler : BaseMessageHandler { - void Run(Ipc_CqueryRandom* request) override { +struct Handler_CqueryRandom : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_CqueryRandom* request) override { std::unordered_map sym2id; std::vector syms; int n = 0; @@ -137,8 +141,8 @@ struct CqueryRandomHandler : BaseMessageHandler { break; } } - QueueManager::WriteStdout(IpcId::CqueryRandom, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryRandomHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryRandom); } // namespace diff --git a/src/messages/cquery_vars.cc b/src/messages/cquery_vars.cc index 1f6b9c56..812ec6f0 100644 --- a/src/messages/cquery_vars.cc +++ b/src/messages/cquery_vars.cc @@ -3,15 +3,20 @@ #include "queue_manager.h" namespace { -struct Ipc_CqueryVars : public RequestMessage { - const static IpcId kIpcId = IpcId::CqueryVars; +MethodType kMethodType = "$cquery/vars"; + +struct In_CqueryVars : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_CqueryVars, id, params); -REGISTER_IPC_MESSAGE(Ipc_CqueryVars); +MAKE_REFLECT_STRUCT(In_CqueryVars, id, params); +REGISTER_IN_MESSAGE(In_CqueryVars); -struct CqueryVarsHandler : BaseMessageHandler { - void Run(Ipc_CqueryVars* request) override { +struct Handler_CqueryVars : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_CqueryVars* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -45,8 +50,8 @@ struct CqueryVarsHandler : BaseMessageHandler { } } } - QueueManager::WriteStdout(IpcId::CqueryVars, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(CqueryVarsHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryVars); } // namespace diff --git a/src/messages/cquery_wait.cc b/src/messages/cquery_wait.cc index 2e59e997..c9109729 100644 --- a/src/messages/cquery_wait.cc +++ b/src/messages/cquery_wait.cc @@ -6,14 +6,17 @@ #include namespace { -struct Ipc_CqueryWait : public NotificationMessage { - static constexpr IpcId kIpcId = IpcId::CqueryWait; -}; -MAKE_REFLECT_EMPTY_STRUCT(Ipc_CqueryWait); -REGISTER_IPC_MESSAGE(Ipc_CqueryWait); +MethodType kMethodType = "$cquery/wait"; + +struct In_CqueryWait : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } +}; +MAKE_REFLECT_EMPTY_STRUCT(In_CqueryWait); +REGISTER_IN_MESSAGE(In_CqueryWait); + +struct Handler_CqueryWait : MessageHandler { + MethodType GetMethodType() const override { return kMethodType; } -struct CqueryWaitHandler : MessageHandler { - IpcId GetId() const override { return IpcId::CqueryWait; } void Run(std::unique_ptr request) override { // TODO: use status message system here, then run querydb as normal? Maybe // this cannot be a normal message, ie, it needs to be re-entrant. @@ -40,5 +43,5 @@ struct CqueryWaitHandler : MessageHandler { LOG_S(INFO) << "Done waiting for idle"; } }; -REGISTER_MESSAGE_HANDLER(CqueryWaitHandler); +REGISTER_MESSAGE_HANDLER(Handler_CqueryWait); } // namespace diff --git a/src/messages/exit.cc b/src/messages/exit.cc index a0e403f4..d90d80ed 100644 --- a/src/messages/exit.cc +++ b/src/messages/exit.cc @@ -3,19 +3,19 @@ #include namespace { -struct Ipc_Exit : public NotificationMessage { - static const IpcId kIpcId = IpcId::Exit; +struct In_Exit : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType_Exit; } }; -MAKE_REFLECT_EMPTY_STRUCT(Ipc_Exit); -REGISTER_IPC_MESSAGE(Ipc_Exit); +MAKE_REFLECT_EMPTY_STRUCT(In_Exit); +REGISTER_IN_MESSAGE(In_Exit); -struct ExitHandler : MessageHandler { - IpcId GetId() const override { return IpcId::Exit; } +struct Handler_Exit : MessageHandler { + MethodType GetMethodType() const override { return kMethodType_Exit; } void Run(std::unique_ptr request) override { - LOG_S(INFO) << "Exiting; got IpcId::Exit"; + LOG_S(INFO) << "Exiting; got exit message"; exit(0); } }; -REGISTER_MESSAGE_HANDLER(ExitHandler); +REGISTER_MESSAGE_HANDLER(Handler_Exit); } // namespace diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index e0872449..ffbc6115 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -23,6 +23,8 @@ extern std::string g_init_options; namespace { +MethodType kMethodType = "initialize"; + // Code Lens options. struct lsCodeLensOptions { // Code lens has a resolve provider as well. @@ -460,12 +462,13 @@ struct lsInitializeError { }; MAKE_REFLECT_STRUCT(lsInitializeError, retry); -struct Ipc_InitializeRequest : public RequestMessage { - const static IpcId kIpcId = IpcId::Initialize; +struct In_InitializeRequest : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + lsInitializeParams params; }; -MAKE_REFLECT_STRUCT(Ipc_InitializeRequest, id, params); -REGISTER_IPC_MESSAGE(Ipc_InitializeRequest); +MAKE_REFLECT_STRUCT(In_InitializeRequest, id, params); +REGISTER_IN_MESSAGE(In_InitializeRequest); struct Out_InitializeResponse : public lsOutMessage { struct InitializeResult { @@ -477,8 +480,10 @@ struct Out_InitializeResponse : public lsOutMessage { MAKE_REFLECT_STRUCT(Out_InitializeResponse::InitializeResult, capabilities); MAKE_REFLECT_STRUCT(Out_InitializeResponse, jsonrpc, id, result); -struct InitializeHandler : BaseMessageHandler { - void Run(Ipc_InitializeRequest* request) override { +struct Handler_Initialize : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_InitializeRequest* request) override { // Log initialization parameters. rapidjson::StringBuffer output; rapidjson::Writer writer(output); @@ -573,7 +578,7 @@ struct InitializeHandler : BaseMessageHandler { out.result.capabilities.documentRangeFormattingProvider = true; #endif - QueueManager::WriteStdout(IpcId::Initialize, out); + QueueManager::WriteStdout(kMethodType, out); // Set project root. EnsureEndsInSlash(project_path); @@ -627,5 +632,5 @@ struct InitializeHandler : BaseMessageHandler { } } }; -REGISTER_MESSAGE_HANDLER(InitializeHandler); +REGISTER_MESSAGE_HANDLER(Handler_Initialize); } // namespace diff --git a/src/messages/shutdown.cc b/src/messages/shutdown.cc index 5755fb6a..f93f4320 100644 --- a/src/messages/shutdown.cc +++ b/src/messages/shutdown.cc @@ -2,11 +2,13 @@ #include "queue_manager.h" namespace { -struct Ipc_Shutdown : public RequestMessage { - static const IpcId kIpcId = IpcId::Shutdown; +MethodType kMethodType = "shutdown"; + +struct In_Shutdown : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } }; -MAKE_REFLECT_STRUCT(Ipc_Shutdown, id); -REGISTER_IPC_MESSAGE(Ipc_Shutdown); +MAKE_REFLECT_STRUCT(In_Shutdown, id); +REGISTER_IN_MESSAGE(In_Shutdown); struct Out_Shutdown : public lsOutMessage { lsRequestId id; // defaults to std::monostate (null) @@ -14,12 +16,13 @@ struct Out_Shutdown : public lsOutMessage { }; MAKE_REFLECT_STRUCT(Out_Shutdown, jsonrpc, id, result); -struct ShutdownHandler : BaseMessageHandler { - void Run(Ipc_Shutdown* request) override { +struct Handler_Shutdown : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_Shutdown* request) override { Out_Shutdown out; out.id = request->id; - QueueManager::WriteStdout(IpcId::TextDocumentDefinition, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(ShutdownHandler); +REGISTER_MESSAGE_HANDLER(Handler_Shutdown); } // namespace diff --git a/src/messages/text_document_code_action.cc b/src/messages/text_document_code_action.cc index 559cae30..487fbca3 100644 --- a/src/messages/text_document_code_action.cc +++ b/src/messages/text_document_code_action.cc @@ -11,6 +11,7 @@ #include namespace { +MethodType kMethodType = "textDocument/codeAction"; optional FindIncludeLine(const std::vector& lines, const std::string& full_include_line) { @@ -256,9 +257,9 @@ optional BuildAutoImplementForFunction(QueryDatabase* db, return nullopt; } -struct Ipc_TextDocumentCodeAction - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentCodeAction; +struct In_TextDocumentCodeAction : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } + // Contains additional diagnostic information about the context in which // a code action is run. struct lsCodeActionContext { @@ -276,14 +277,14 @@ struct Ipc_TextDocumentCodeAction }; lsCodeActionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionContext, +MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionContext, diagnostics); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionParams, +MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionParams, textDocument, range, context); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeAction); +MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentCodeAction); struct Out_TextDocumentCodeAction : public lsOutMessage { @@ -294,9 +295,11 @@ struct Out_TextDocumentCodeAction }; MAKE_REFLECT_STRUCT(Out_TextDocumentCodeAction, jsonrpc, id, result); -struct TextDocumentCodeActionHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentCodeAction* request) override { +struct Handler_TextDocumentCodeAction + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentCodeAction* request) override { // NOTE: This code snippet will generate some FixIts for testing: // // struct origin { int x, int y }; @@ -534,10 +537,10 @@ struct TextDocumentCodeActionHandler } } - QueueManager::WriteStdout(IpcId::TextDocumentCodeAction, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentCodeActionHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCodeAction); TEST_SUITE("FindIncludeLine") { TEST_CASE("in document") { diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index 239a543a..f735f1bb 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -5,19 +5,20 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "textDocument/codeLens"; + struct lsDocumentCodeLensParams { lsTextDocumentIdentifier textDocument; }; MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument); using TCodeLens = lsCodeLens; -struct Ipc_TextDocumentCodeLens - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentCodeLens; +struct In_TextDocumentCodeLens : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsDocumentCodeLensParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeLens); +MAKE_REFLECT_STRUCT(In_TextDocumentCodeLens, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentCodeLens); struct Out_TextDocumentCodeLens : public lsOutMessage { @@ -81,9 +82,10 @@ void AddCodeLens(const char* singular, common->result->push_back(code_lens); } -struct TextDocumentCodeLensHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentCodeLens* request) override { +struct Handler_TextDocumentCodeLens + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentCodeLens* request) override { Out_TextDocumentCodeLens out; out.id = request->id; @@ -225,8 +227,8 @@ struct TextDocumentCodeLensHandler }; } - QueueManager::WriteStdout(IpcId::TextDocumentCodeLens, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentCodeLensHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCodeLens); } // namespace diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index aec06e27..43dc6c8c 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -14,6 +14,7 @@ #include namespace { +MethodType kMethodType = "textDocument/completion"; // How a completion was triggered enum class lsCompletionTriggerKind { @@ -47,13 +48,12 @@ struct lsCompletionParams : lsTextDocumentPositionParams { }; MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context); -struct Ipc_TextDocumentComplete - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentCompletion; +struct In_TextDocumentComplete : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsCompletionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentComplete, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentComplete); +MAKE_REFLECT_STRUCT(In_TextDocumentComplete, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentComplete); struct lsTextDocumentCompleteResult { // This list it not complete. Further typing should result in recomputing @@ -216,17 +216,17 @@ void FilterAndSortCompletionResponse( finalize(); } -struct TextDocumentCompletionHandler : MessageHandler { - IpcId GetId() const override { return IpcId::TextDocumentCompletion; } +struct Handler_TextDocumentCompletion : MessageHandler { + MethodType GetMethodType() const override { return kMethodType; } void Run(std::unique_ptr message) override { - auto request = std::shared_ptr( - static_cast(message.release())); + auto request = std::shared_ptr( + static_cast(message.release())); auto write_empty_result = [request]() { Out_TextDocumentComplete out; out.id = request->id; - QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out); + QueueManager::WriteStdout(kMethodType, out); }; std::string path = request->params.textDocument.uri.GetPath(); @@ -324,7 +324,7 @@ struct TextDocumentCompletionHandler : MessageHandler { item.textEdit->range.end.character = (int)buffer_line.size(); } - QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out); + QueueManager::WriteStdout(kMethodType, out); } else { ClangCompleteManager::OnComplete callback = std::bind( [this, is_global_completion, existing_completion, request]( @@ -337,7 +337,7 @@ struct TextDocumentCompletionHandler : MessageHandler { // Emit completion results. FilterAndSortCompletionResponse(&out, existing_completion, config->completion.filterAndSort); - QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out); + QueueManager::WriteStdout(kMethodType, out); // Cache completion results. if (!is_cached_result) { @@ -395,6 +395,6 @@ struct TextDocumentCompletionHandler : MessageHandler { } } }; -REGISTER_MESSAGE_HANDLER(TextDocumentCompletionHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCompletion); } // namespace diff --git a/src/messages/text_document_definition.cc b/src/messages/text_document_definition.cc index e5823794..95410f0e 100644 --- a/src/messages/text_document_definition.cc +++ b/src/messages/text_document_definition.cc @@ -8,14 +8,14 @@ #include namespace { +MethodType kMethodType = "textDocument/definition"; -struct Ipc_TextDocumentDefinition - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentDefinition; +struct In_TextDocumentDefinition : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDefinition, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition); +MAKE_REFLECT_STRUCT(In_TextDocumentDefinition, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentDefinition); struct Out_TextDocumentDefinition : public lsOutMessage { @@ -46,9 +46,10 @@ std::vector GetNonDefDeclarationTargets(QueryDatabase* db, SymbolRef sym) { } } -struct TextDocumentDefinitionHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDefinition* request) override { +struct Handler_TextDocumentDefinition + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentDefinition* request) override { QueryFileId file_id; QueryFile* file; if (!FindFileOrFail(db, project, request->id, @@ -165,8 +166,8 @@ struct TextDocumentDefinitionHandler } } - QueueManager::WriteStdout(IpcId::TextDocumentDefinition, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDefinitionHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDefinition); } // namespace diff --git a/src/messages/text_document_did_change.cc b/src/messages/text_document_did_change.cc index d32f2097..fb16e3c3 100644 --- a/src/messages/text_document_did_change.cc +++ b/src/messages/text_document_did_change.cc @@ -8,18 +8,21 @@ #include namespace { -struct Ipc_TextDocumentDidChange - : public NotificationMessage { - const static IpcId kIpcId = IpcId::TextDocumentDidChange; +MethodType kMethodType = "textDocument/didChange"; + +struct In_TextDocumentDidChange : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentDidChangeParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidChange, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidChange); +MAKE_REFLECT_STRUCT(In_TextDocumentDidChange, params); +REGISTER_IN_MESSAGE(In_TextDocumentDidChange); -struct TextDocumentDidChangeHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDidChange* request) override { +struct Handler_TextDocumentDidChange + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentDidChange* request) override { std::string path = request->params.textDocument.uri.GetPath(); working_files->OnChange(request->params); if (config->enableIndexOnDidChange) { @@ -40,5 +43,5 @@ struct TextDocumentDidChangeHandler request->params.textDocument.AsTextDocumentIdentifier()); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDidChangeHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidChange); } // namespace diff --git a/src/messages/text_document_did_close.cc b/src/messages/text_document_did_close.cc index d83f0fa6..e76ee52f 100644 --- a/src/messages/text_document_did_close.cc +++ b/src/messages/text_document_did_close.cc @@ -4,32 +4,35 @@ #include "working_files.h" namespace { -struct Ipc_TextDocumentDidClose - : public NotificationMessage { - const static IpcId kIpcId = IpcId::TextDocumentDidClose; +MethodType kMethodType = "textDocument/didClose"; + +struct In_TextDocumentDidClose : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { lsTextDocumentIdentifier textDocument; }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose::Params, textDocument); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidClose); +MAKE_REFLECT_STRUCT(In_TextDocumentDidClose::Params, textDocument); +MAKE_REFLECT_STRUCT(In_TextDocumentDidClose, params); +REGISTER_IN_MESSAGE(In_TextDocumentDidClose); -struct TextDocumentDidCloseHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDidClose* request) override { +struct Handler_TextDocumentDidClose + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentDidClose* request) override { std::string path = request->params.textDocument.uri.GetPath(); // Clear any diagnostics for the file. Out_TextDocumentPublishDiagnostics out; out.params.uri = request->params.textDocument.uri; - QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out); + QueueManager::WriteStdout(kMethodType, out); // Remove internal state. working_files->OnClose(request->params.textDocument); clang_complete->NotifyClose(path); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDidCloseHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidClose); } // namespace diff --git a/src/messages/text_document_did_open.cc b/src/messages/text_document_did_open.cc index e354e449..2b2562d8 100644 --- a/src/messages/text_document_did_open.cc +++ b/src/messages/text_document_did_open.cc @@ -10,10 +10,12 @@ #include namespace { +MethodType kMethodType = "textDocument/didOpen"; + // Open, view, change, close file -struct Ipc_TextDocumentDidOpen - : public NotificationMessage { - const static IpcId kIpcId = IpcId::TextDocumentDidOpen; +struct In_TextDocumentDidOpen : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } + struct Params { lsTextDocumentItem textDocument; @@ -24,13 +26,15 @@ struct Ipc_TextDocumentDidOpen }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument, args); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidOpen); +MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen::Params, textDocument, args); +MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen, params); +REGISTER_IN_MESSAGE(In_TextDocumentDidOpen); -struct TextDocumentDidOpenHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDidOpen* request) override { +struct Handler_TextDocumentDidOpen + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentDidOpen* request) override { // NOTE: This function blocks code lens. If it starts taking a long time // we will need to find a way to unblock the code lens request. const auto& params = request->params; @@ -75,5 +79,5 @@ struct TextDocumentDidOpenHandler } } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDidOpenHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidOpen); } // namespace diff --git a/src/messages/text_document_did_save.cc b/src/messages/text_document_did_save.cc index 3635d767..7eec5dd0 100644 --- a/src/messages/text_document_did_save.cc +++ b/src/messages/text_document_did_save.cc @@ -7,9 +7,11 @@ #include namespace { -struct Ipc_TextDocumentDidSave - : public NotificationMessage { - const static IpcId kIpcId = IpcId::TextDocumentDidSave; +MethodType kMethodType = "textDocument/didSave"; + +struct In_TextDocumentDidSave : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } + struct Params { // The document that was saved. lsTextDocumentIdentifier textDocument; @@ -20,13 +22,15 @@ struct Ipc_TextDocumentDidSave }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave::Params, textDocument); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidSave); +MAKE_REFLECT_STRUCT(In_TextDocumentDidSave::Params, textDocument); +MAKE_REFLECT_STRUCT(In_TextDocumentDidSave, params); +REGISTER_IN_MESSAGE(In_TextDocumentDidSave); -struct TextDocumentDidSaveHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDidSave* request) override { +struct Handler_TextDocumentDidSave + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentDidSave* request) override { std::string path = request->params.textDocument.uri.GetPath(); if (ShouldIgnoreFileForIndexing(path)) return; @@ -61,5 +65,5 @@ struct TextDocumentDidSaveHandler clang_complete->NotifySave(path); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDidSaveHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave); } // namespace diff --git a/src/messages/text_document_document_highlight.cc b/src/messages/text_document_document_highlight.cc index 1183e1d5..b01bc7a6 100644 --- a/src/messages/text_document_document_highlight.cc +++ b/src/messages/text_document_document_highlight.cc @@ -4,13 +4,14 @@ #include "symbol.h" namespace { -struct Ipc_TextDocumentDocumentHighlight - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentDocumentHighlight; +MethodType kMethodType = "textDocument/documentHighlight"; + +struct In_TextDocumentDocumentHighlight : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentHighlight, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentHighlight); +MAKE_REFLECT_STRUCT(In_TextDocumentDocumentHighlight, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentDocumentHighlight); struct Out_TextDocumentDocumentHighlight : public lsOutMessage { @@ -19,9 +20,10 @@ struct Out_TextDocumentDocumentHighlight }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result); -struct TextDocumentDocumentHighlightHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDocumentHighlight* request) override { +struct Handler_TextDocumentDocumentHighlight + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentDocumentHighlight* request) override { QueryFileId file_id; QueryFile* file; if (!FindFileOrFail(db, project, request->id, @@ -59,8 +61,8 @@ struct TextDocumentDocumentHighlightHandler break; } - QueueManager::WriteStdout(IpcId::TextDocumentDocumentHighlight, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDocumentHighlightHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentHighlight); } // namespace diff --git a/src/messages/text_document_document_link.cc b/src/messages/text_document_document_link.cc index b68bfbcc..fc6994fa 100644 --- a/src/messages/text_document_document_link.cc +++ b/src/messages/text_document_document_link.cc @@ -6,18 +6,19 @@ #include namespace { -struct Ipc_TextDocumentDocumentLink - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentDocumentLink; +MethodType kMethodType = "textDocument/documentLink"; + +struct In_TextDocumentDocumentLink : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { // The document to provide document links for. lsTextDocumentIdentifier textDocument; }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::Params, textDocument); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentLink); +MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink::Params, textDocument); +MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentDocumentLink); // A document link is a range in a text document that links to an internal or // external resource, like another text document or a web site. @@ -36,9 +37,10 @@ struct Out_TextDocumentDocumentLink }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result); -struct TextDocumentDocumentLinkHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDocumentLink* request) override { +struct Handler_TextDocumentDocumentLink + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentDocumentLink* request) override { Out_TextDocumentDocumentLink out; out.id = request->id; @@ -76,8 +78,8 @@ struct TextDocumentDocumentLinkHandler } } - QueueManager::WriteStdout(IpcId::TextDocumentDocumentLink, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDocumentLinkHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentLink); } // namespace diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/text_document_document_symbol.cc index 54e5cf28..4a48a2d3 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/text_document_document_symbol.cc @@ -3,18 +3,19 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "textDocument/documentSymbol"; + struct lsDocumentSymbolParams { lsTextDocumentIdentifier textDocument; }; MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument); -struct Ipc_TextDocumentDocumentSymbol - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol; +struct In_TextDocumentDocumentSymbol : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsDocumentSymbolParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol); +MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol); struct Out_TextDocumentDocumentSymbol : public lsOutMessage { @@ -23,9 +24,10 @@ struct Out_TextDocumentDocumentSymbol }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result); -struct TextDocumentDocumentSymbolHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentDocumentSymbol* request) override { +struct Handler_TextDocumentDocumentSymbol + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentDocumentSymbol* request) override { Out_TextDocumentDocumentSymbol out; out.id = request->id; @@ -62,8 +64,8 @@ struct TextDocumentDocumentSymbolHandler } } - QueueManager::WriteStdout(IpcId::TextDocumentDocumentSymbol, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentDocumentSymbolHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentSymbol); } // namespace diff --git a/src/messages/text_document_formatting.cc b/src/messages/text_document_formatting.cc index 08a8d1a2..55c8f487 100644 --- a/src/messages/text_document_formatting.cc +++ b/src/messages/text_document_formatting.cc @@ -6,19 +6,19 @@ #include namespace { +MethodType kMethodType = "textDocument/formatting"; -struct Ipc_TextDocumentFormatting - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentFormatting; +struct In_TextDocumentFormatting : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } 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); +MAKE_REFLECT_STRUCT(In_TextDocumentFormatting::Params, textDocument, options); +MAKE_REFLECT_STRUCT(In_TextDocumentFormatting, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentFormatting); struct Out_TextDocumentFormatting : public lsOutMessage { @@ -27,9 +27,10 @@ struct Out_TextDocumentFormatting }; MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, result); -struct TextDocumentFormattingHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentFormatting* request) override { +struct Handler_TextDocumentFormatting + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentFormatting* request) override { Out_TextDocumentFormatting response; response.id = request->id; #if USE_CLANG_CXX @@ -54,8 +55,8 @@ struct TextDocumentFormattingHandler response.result = {}; #endif - QueueManager::WriteStdout(IpcId::TextDocumentFormatting, response); + QueueManager::WriteStdout(kMethodType, response); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentFormattingHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentFormatting); } // namespace diff --git a/src/messages/text_document_hover.cc b/src/messages/text_document_hover.cc index 9af5f077..2dbf26a1 100644 --- a/src/messages/text_document_hover.cc +++ b/src/messages/text_document_hover.cc @@ -3,6 +3,7 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "textDocument/hover"; std::pair GetCommentsAndHover( QueryDatabase* db, @@ -41,12 +42,12 @@ std::pair GetCommentsAndHover( return {"", ""}; } -struct Ipc_TextDocumentHover : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentHover; +struct In_TextDocumentHover : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentHover); +MAKE_REFLECT_STRUCT(In_TextDocumentHover, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentHover); struct Out_TextDocumentHover : public lsOutMessage { struct Result { @@ -73,8 +74,9 @@ void Reflect(Writer& visitor, Out_TextDocumentHover& value) { REFLECT_MEMBER_END(); } -struct TextDocumentHoverHandler : BaseMessageHandler { - void Run(Ipc_TextDocumentHover* request) override { +struct Handler_TextDocumentHover : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentHover* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -111,8 +113,8 @@ struct TextDocumentHoverHandler : BaseMessageHandler { } } - QueueManager::WriteStdout(IpcId::TextDocumentHover, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentHoverHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentHover); } // namespace diff --git a/src/messages/text_document_range_formatting.cc b/src/messages/text_document_range_formatting.cc index 93608905..29605e50 100644 --- a/src/messages/text_document_range_formatting.cc +++ b/src/messages/text_document_range_formatting.cc @@ -7,6 +7,7 @@ #include namespace { +MethodType kMethodType = "textDocument/rangeFormatting"; struct lsTextDocumentRangeFormattingParams { lsTextDocumentIdentifier textDocument; @@ -18,13 +19,12 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams, range, options); -struct Ipc_TextDocumentRangeFormatting - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting; +struct In_TextDocumentRangeFormatting : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentRangeFormattingParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting); +MAKE_REFLECT_STRUCT(In_TextDocumentRangeFormatting, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentRangeFormatting); struct Out_TextDocumentRangeFormatting : public lsOutMessage { @@ -33,9 +33,11 @@ struct Out_TextDocumentRangeFormatting }; MAKE_REFLECT_STRUCT(Out_TextDocumentRangeFormatting, jsonrpc, id, result); -struct TextDocumentRangeFormattingHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentRangeFormatting* request) override { +struct Handler_TextDocumentRangeFormatting + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentRangeFormatting* request) override { Out_TextDocumentRangeFormatting response; response.id = request->id; #if USE_CLANG_CXX @@ -62,8 +64,8 @@ struct TextDocumentRangeFormattingHandler response.result = {}; #endif - QueueManager::WriteStdout(IpcId::TextDocumentRangeFormatting, response); + QueueManager::WriteStdout(kMethodType, response); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentRangeFormattingHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRangeFormatting); } // namespace diff --git a/src/messages/text_document_references.cc b/src/messages/text_document_references.cc index f905dcb2..bd6896d7 100644 --- a/src/messages/text_document_references.cc +++ b/src/messages/text_document_references.cc @@ -5,9 +5,10 @@ #include namespace { -struct Ipc_TextDocumentReferences - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentReferences; +MethodType kMethodType = "textDocument/references"; + +struct In_TextDocumentReferences : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } struct lsReferenceContext { // Include the declaration of the current symbol. bool includeDeclaration; @@ -22,15 +23,15 @@ struct Ipc_TextDocumentReferences Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext, +MAKE_REFLECT_STRUCT(In_TextDocumentReferences::lsReferenceContext, includeDeclaration, role); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::Params, +MAKE_REFLECT_STRUCT(In_TextDocumentReferences::Params, textDocument, position, context); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentReferences); +MAKE_REFLECT_STRUCT(In_TextDocumentReferences, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentReferences); struct Out_TextDocumentReferences : public lsOutMessage { @@ -39,9 +40,11 @@ struct Out_TextDocumentReferences }; MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result); -struct TextDocumentReferencesHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentReferences* request) override { +struct Handler_TextDocumentReferences + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + + void Run(In_TextDocumentReferences* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { @@ -93,8 +96,8 @@ struct TextDocumentReferencesHandler if ((int)out.result.size() >= config->xref.maxNum) out.result.resize(config->xref.maxNum); - QueueManager::WriteStdout(IpcId::TextDocumentReferences, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentReferencesHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentReferences); } // namespace diff --git a/src/messages/text_document_rename.cc b/src/messages/text_document_rename.cc index 719eddfe..b44048ad 100644 --- a/src/messages/text_document_rename.cc +++ b/src/messages/text_document_rename.cc @@ -3,6 +3,7 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "textDocument/rename"; lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db, WorkingFiles* working_files, @@ -47,8 +48,8 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db, return edit; } -struct Ipc_TextDocumentRename : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentRename; +struct In_TextDocumentRename : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } struct Params { // The document to format. lsTextDocumentIdentifier textDocument; @@ -63,12 +64,12 @@ struct Ipc_TextDocumentRename : public RequestMessage { }; Params params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename::Params, +MAKE_REFLECT_STRUCT(In_TextDocumentRename::Params, textDocument, position, newName); -MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentRename); +MAKE_REFLECT_STRUCT(In_TextDocumentRename, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentRename); struct Out_TextDocumentRename : public lsOutMessage { lsRequestId id; @@ -76,8 +77,9 @@ struct Out_TextDocumentRename : public lsOutMessage { }; MAKE_REFLECT_STRUCT(Out_TextDocumentRename, jsonrpc, id, result); -struct TextDocumentRenameHandler : BaseMessageHandler { - void Run(Ipc_TextDocumentRename* request) override { +struct Handler_TextDocumentRename : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentRename* request) override { QueryFileId file_id; QueryFile* file; if (!FindFileOrFail(db, project, request->id, @@ -100,8 +102,8 @@ struct TextDocumentRenameHandler : BaseMessageHandler { break; } - QueueManager::WriteStdout(IpcId::TextDocumentRename, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentRenameHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRename); } // namespace diff --git a/src/messages/text_document_signature_help.cc b/src/messages/text_document_signature_help.cc index ec1a9c90..c4e74029 100644 --- a/src/messages/text_document_signature_help.cc +++ b/src/messages/text_document_signature_help.cc @@ -7,13 +7,14 @@ #include namespace { -struct Ipc_TextDocumentSignatureHelp - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentSignatureHelp; +MethodType kMethodType = "textDocument/signatureHelp"; + +struct In_TextDocumentSignatureHelp : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentSignatureHelp, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentSignatureHelp); +MAKE_REFLECT_STRUCT(In_TextDocumentSignatureHelp, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentSignatureHelp); // Represents a parameter of a callable-signature. A parameter can // have a label and a doc-comment. @@ -82,11 +83,11 @@ struct Out_TextDocumentSignatureHelp }; MAKE_REFLECT_STRUCT(Out_TextDocumentSignatureHelp, jsonrpc, id, result); -struct TextDocumentSignatureHelpHandler : MessageHandler { - IpcId GetId() const override { return IpcId::TextDocumentSignatureHelp; } +struct Handler_TextDocumentSignatureHelp : MessageHandler { + MethodType GetMethodType() const override { return kMethodType; } void Run(std::unique_ptr message) override { - auto request = message->As(); + auto request = static_cast(message.get()); lsTextDocumentPositionParams& params = request->params; WorkingFile* file = working_files->GetFileByFilename(params.textDocument.uri.GetPath()); @@ -105,7 +106,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler { [this](BaseIpcMessage* message, std::string search, int active_param, const std::vector& results, bool is_cached_result) { - auto msg = message->As(); + auto msg = static_cast(message); Out_TextDocumentSignatureHelp out; out.id = msg->id; @@ -142,7 +143,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler { out.result.activeParameter = active_param; Timer timer; - QueueManager::WriteStdout(IpcId::TextDocumentSignatureHelp, out); + QueueManager::WriteStdout(kMethodType, out); if (!is_cached_result) { signature_cache->WithLock([&]() { @@ -168,5 +169,5 @@ struct TextDocumentSignatureHelpHandler : MessageHandler { } } }; -REGISTER_MESSAGE_HANDLER(TextDocumentSignatureHelpHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentSignatureHelp); } // namespace diff --git a/src/messages/text_document_type_definition.cc b/src/messages/text_document_type_definition.cc index dac467ae..9797af8a 100644 --- a/src/messages/text_document_type_definition.cc +++ b/src/messages/text_document_type_definition.cc @@ -3,14 +3,14 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "textDocument/typeDefinition"; -struct Ipc_TextDocumentTypeDefinition - : public RequestMessage { - const static IpcId kIpcId = IpcId::TextDocumentTypeDefinition; +struct In_TextDocumentTypeDefinition : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsTextDocumentPositionParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentTypeDefinition, id, params); -REGISTER_IPC_MESSAGE(Ipc_TextDocumentTypeDefinition); +MAKE_REFLECT_STRUCT(In_TextDocumentTypeDefinition, id, params); +REGISTER_IN_MESSAGE(In_TextDocumentTypeDefinition); struct Out_TextDocumentTypeDefinition : public lsOutMessage { @@ -19,9 +19,10 @@ struct Out_TextDocumentTypeDefinition }; MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result); -struct TextDocumentTypeDefinitionHandler - : BaseMessageHandler { - void Run(Ipc_TextDocumentTypeDefinition* request) override { +struct Handler_TextDocumentTypeDefinition + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_TextDocumentTypeDefinition* request) override { QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file, @@ -59,9 +60,9 @@ struct TextDocumentTypeDefinitionHandler } } - QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler); +REGISTER_MESSAGE_HANDLER(Handler_TextDocumentTypeDefinition); } // namespace diff --git a/src/messages/workspace_did_change_configuration.cc b/src/messages/workspace_did_change_configuration.cc index 3506cf59..8714217a 100644 --- a/src/messages/workspace_did_change_configuration.cc +++ b/src/messages/workspace_did_change_configuration.cc @@ -9,22 +9,24 @@ #include namespace { +MethodType kMethodType = "workspace/didChangeConfiguration"; + struct lsDidChangeConfigurationParams { bool placeholder; }; MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder); -struct Ipc_WorkspaceDidChangeConfiguration - : public NotificationMessage { - const static IpcId kIpcId = IpcId::WorkspaceDidChangeConfiguration; +struct In_WorkspaceDidChangeConfiguration : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } lsDidChangeConfigurationParams params; }; -MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeConfiguration, params); -REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeConfiguration); +MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeConfiguration, params); +REGISTER_IN_MESSAGE(In_WorkspaceDidChangeConfiguration); -struct WorkspaceDidChangeConfigurationHandler - : BaseMessageHandler { - void Run(Ipc_WorkspaceDidChangeConfiguration* request) override { +struct Handler_WorkspaceDidChangeConfiguration + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_WorkspaceDidChangeConfiguration* request) override { Timer time; project->Load(config, config->projectRoot); time.ResetAndPrint("[perf] Loaded compilation entries (" + @@ -40,5 +42,5 @@ struct WorkspaceDidChangeConfigurationHandler LOG_S(INFO) << "Flushed all clang complete sessions"; } }; -REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeConfigurationHandler); +REGISTER_MESSAGE_HANDLER(Handler_WorkspaceDidChangeConfiguration); } // namespace diff --git a/src/messages/workspace_did_change_watched_files.cc b/src/messages/workspace_did_change_watched_files.cc index 18e58d0c..88471b94 100644 --- a/src/messages/workspace_did_change_watched_files.cc +++ b/src/messages/workspace_did_change_watched_files.cc @@ -8,6 +8,8 @@ #include namespace { +MethodType kMethodType = "workspace/didChangeWatchedFiles"; + enum class lsFileChangeType { Created = 1, Changed = 2, @@ -26,17 +28,17 @@ struct lsDidChangeWatchedFilesParams { }; MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes); -struct Ipc_WorkspaceDidChangeWatchedFiles - : public NotificationMessage { - const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles; +struct In_WorkspaceDidChangeWatchedFiles : public NotificationMessage { + MethodType GetMethodType() const override { return kMethodType; } lsDidChangeWatchedFilesParams params; }; -MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeWatchedFiles, params); -REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeWatchedFiles); +MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeWatchedFiles, params); +REGISTER_IN_MESSAGE(In_WorkspaceDidChangeWatchedFiles); -struct WorkspaceDidChangeWatchedFilesHandler - : BaseMessageHandler { - void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override { +struct Handler_WorkspaceDidChangeWatchedFiles + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_WorkspaceDidChangeWatchedFiles* request) override { for (lsFileEvent& event : request->params.changes) { std::string path = event.uri.GetPath(); auto it = project->absolute_path_to_entry_index_.find(path); @@ -69,5 +71,5 @@ struct WorkspaceDidChangeWatchedFilesHandler } } }; -REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeWatchedFilesHandler); +REGISTER_MESSAGE_HANDLER(Handler_WorkspaceDidChangeWatchedFiles); } // namespace diff --git a/src/messages/workspace_execute_command.cc b/src/messages/workspace_execute_command.cc index adb405f4..f1600d89 100644 --- a/src/messages/workspace_execute_command.cc +++ b/src/messages/workspace_execute_command.cc @@ -4,14 +4,14 @@ #include "queue_manager.h" namespace { +MethodType kMethodType = "workspace/executeCommand"; -struct Ipc_WorkspaceExecuteCommand - : public RequestMessage { - const static IpcId kIpcId = IpcId::WorkspaceExecuteCommand; +struct In_WorkspaceExecuteCommand : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } lsCommand params; }; -MAKE_REFLECT_STRUCT(Ipc_WorkspaceExecuteCommand, id, params); -REGISTER_IPC_MESSAGE(Ipc_WorkspaceExecuteCommand); +MAKE_REFLECT_STRUCT(In_WorkspaceExecuteCommand, id, params); +REGISTER_IN_MESSAGE(In_WorkspaceExecuteCommand); struct Out_WorkspaceExecuteCommand : public lsOutMessage { @@ -28,9 +28,10 @@ void Reflect(Writer& visitor, Out_WorkspaceExecuteCommand& value) { REFLECT_MEMBER_END(); } -struct WorkspaceExecuteCommandHandler - : BaseMessageHandler { - void Run(Ipc_WorkspaceExecuteCommand* request) override { +struct Handler_WorkspaceExecuteCommand + : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_WorkspaceExecuteCommand* request) override { const auto& params = request->params; Out_WorkspaceExecuteCommand out; out.id = request->id; @@ -41,9 +42,9 @@ struct WorkspaceExecuteCommandHandler out.result = params.arguments.locations; } - QueueManager::WriteStdout(IpcId::WorkspaceExecuteCommand, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(WorkspaceExecuteCommandHandler); +REGISTER_MESSAGE_HANDLER(Handler_WorkspaceExecuteCommand); } // namespace diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index 09216712..68d0abca 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -12,6 +12,7 @@ #include namespace { +MethodType kMethodType = "workspace/symbol"; // Lookup |symbol| in |db| and insert the value into |result|. bool InsertSymbolIntoResult(QueryDatabase* db, @@ -42,16 +43,16 @@ bool InsertSymbolIntoResult(QueryDatabase* db, return true; } -struct Ipc_WorkspaceSymbol : public RequestMessage { - const static IpcId kIpcId = IpcId::WorkspaceSymbol; +struct In_WorkspaceSymbol : public RequestMessage { + MethodType GetMethodType() const override { return kMethodType; } 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); +MAKE_REFLECT_STRUCT(In_WorkspaceSymbol::Params, query); +MAKE_REFLECT_STRUCT(In_WorkspaceSymbol, id, params); +REGISTER_IN_MESSAGE(In_WorkspaceSymbol); struct Out_WorkspaceSymbol : public lsOutMessage { lsRequestId id; @@ -61,8 +62,9 @@ MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result); ///// Fuzzy matching -struct WorkspaceSymbolHandler : BaseMessageHandler { - void Run(Ipc_WorkspaceSymbol* request) override { +struct Handler_WorkspaceSymbol : BaseMessageHandler { + MethodType GetMethodType() const override { return kMethodType; } + void Run(In_WorkspaceSymbol* request) override { Out_WorkspaceSymbol out; out.id = request->id; @@ -151,8 +153,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler { LOG_S(INFO) << "[querydb] Found " << out.result.size() << " results for query " << query; - QueueManager::WriteStdout(IpcId::WorkspaceSymbol, out); + QueueManager::WriteStdout(kMethodType, out); } }; -REGISTER_MESSAGE_HANDLER(WorkspaceSymbolHandler); +REGISTER_MESSAGE_HANDLER(Handler_WorkspaceSymbol); } // namespace diff --git a/src/methods.inc b/src/methods.inc deleted file mode 100644 index 8298c0d6..00000000 --- a/src/methods.inc +++ /dev/null @@ -1,60 +0,0 @@ -// General -CASE(Initialize, "initialize") -CASE(Shutdown, "shutdown") - -CASE(CodeLensResolve, "codeLens/resolve") -CASE(TextDocumentCodeAction, "textDocument/codeAction") -CASE(TextDocumentCodeLens, "textDocument/codeLens") -CASE(TextDocumentCompletion, "textDocument/completion") -CASE(TextDocumentDefinition, "textDocument/definition") -CASE(TextDocumentDidChange, "textDocument/didChange") -CASE(TextDocumentDidClose, "textDocument/didClose") -CASE(TextDocumentDidOpen, "textDocument/didOpen") -CASE(TextDocumentDidSave, "textDocument/didSave") -CASE(TextDocumentDocumentHighlight, "textDocument/documentHighlight") -CASE(TextDocumentDocumentLink, "textDocument/documentLink") -CASE(TextDocumentDocumentSymbol, "textDocument/documentSymbol") -CASE(TextDocumentFormatting, "textDocument/formatting") -CASE(TextDocumentHover, "textDocument/hover") -CASE(TextDocumentOnTypeFormatting, "textDocument/onTypeFormatting") -CASE(TextDocumentPublishDiagnostics, "textDocument/publishDiagnostics") -CASE(TextDocumentRangeFormatting, "textDocument/rangeFormatting") -CASE(TextDocumentReferences, "textDocument/references") -CASE(TextDocumentRename, "textDocument/rename") -CASE(TextDocumentSignatureHelp, "textDocument/signatureHelp") -CASE(TextDocumentTypeDefinition, "textDocument/typeDefinition") -CASE(WorkspaceDidChangeConfiguration, "workspace/didChangeConfiguration") -CASE(WorkspaceDidChangeWatchedFiles, "workspace/didChangeWatchedFiles") -CASE(WorkspaceExecuteCommand, "workspace/executeCommand") -CASE(WorkspaceSymbol, "workspace/symbol") - -// Notification extensions -CASE(CqueryTextDocumentDidView, "$cquery/textDocumentDidView") -CASE(CqueryPublishInactiveRegions, "$cquery/publishInactiveRegions") -CASE(CqueryPublishSemanticHighlighting, "$cquery/publishSemanticHighlighting") - -// Request extensions -CASE(CqueryFileInfo, "$cquery/fileInfo") -CASE(CqueryFreshenIndex, "$cquery/freshenIndex") - -CASE(CqueryCallHierarchy, "$cquery/callHierarchy") -CASE(CqueryInheritanceHierarchy, "$cquery/inheritanceHierarchy") -CASE(CqueryMemberHierarchy, "$cquery/memberHierarchy") - -// Cross reference extensions. -// Show all variables of a type. -CASE(CqueryVars, "$cquery/vars") -// Show all callers of a function. -CASE(CqueryCallers, "$cquery/callers") -// Show base types/method. -CASE(CqueryBase, "$cquery/base") -// Show all derived types/methods. -CASE(CqueryDerived, "$cquery/derived") -// Show random definition. -CASE(CqueryRandom, "$cquery/random") - -// Messages for testing. -// Index the given file contents. -CASE(CqueryIndexFile, "$cquery/indexFile") -// Wait until all cquery threads are idle. -CASE(CqueryWait, "$cquery/wait") diff --git a/src/queue_manager.cc b/src/queue_manager.cc index c3a24cfd..edcec6d2 100644 --- a/src/queue_manager.cc +++ b/src/queue_manager.cc @@ -63,13 +63,13 @@ void QueueManager::Init(MultiQueueWaiter* querydb_waiter, } // static -void QueueManager::WriteStdout(IpcId id, lsBaseOutMessage& response) { +void QueueManager::WriteStdout(MethodType method, lsBaseOutMessage& response) { std::ostringstream sstream; response.Write(sstream); Stdout_Request out; out.content = sstream.str(); - out.id = id; + out.method = method; instance()->for_stdout.PushBack(std::move(out)); } diff --git a/src/queue_manager.h b/src/queue_manager.h index 61db1d23..34cc3b00 100644 --- a/src/queue_manager.h +++ b/src/queue_manager.h @@ -11,7 +11,7 @@ struct ICacheManager; struct lsBaseOutMessage; struct Stdout_Request { - IpcId id; + MethodType method; std::string content; }; @@ -86,7 +86,7 @@ class QueueManager { static void Init(MultiQueueWaiter* querydb_waiter, MultiQueueWaiter* indexer_waiter, MultiQueueWaiter* stdout_waiter); - static void WriteStdout(IpcId id, lsBaseOutMessage& response); + static void WriteStdout(MethodType method, lsBaseOutMessage& response); bool HasWork();