mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Use X macros
This commit is contained in:
parent
0ba8f2a42c
commit
3e3bf885eb
@ -317,46 +317,12 @@ void LaunchStdinLoop(Config* config,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IpcId::Shutdown:
|
|
||||||
case IpcId::Exit:
|
case IpcId::Exit:
|
||||||
case IpcId::Initialize:
|
#define CASE(name, method) case IpcId::name:
|
||||||
case IpcId::TextDocumentDidOpen:
|
#include "methods.inc"
|
||||||
case IpcId::CqueryTextDocumentDidView:
|
#undef CASE
|
||||||
case IpcId::TextDocumentDidChange:
|
|
||||||
case IpcId::TextDocumentDidClose:
|
|
||||||
case IpcId::TextDocumentDidSave:
|
|
||||||
case IpcId::TextDocumentFormatting:
|
|
||||||
case IpcId::TextDocumentRangeFormatting:
|
|
||||||
case IpcId::TextDocumentOnTypeFormatting:
|
|
||||||
case IpcId::TextDocumentRename:
|
|
||||||
case IpcId::TextDocumentCompletion:
|
|
||||||
case IpcId::TextDocumentSignatureHelp:
|
|
||||||
case IpcId::TextDocumentDefinition:
|
|
||||||
case IpcId::TextDocumentDocumentHighlight:
|
|
||||||
case IpcId::TextDocumentHover:
|
|
||||||
case IpcId::TextDocumentReferences:
|
|
||||||
case IpcId::TextDocumentDocumentSymbol:
|
|
||||||
case IpcId::TextDocumentDocumentLink:
|
|
||||||
case IpcId::TextDocumentCodeAction:
|
|
||||||
case IpcId::TextDocumentCodeLens:
|
|
||||||
case IpcId::WorkspaceDidChangeConfiguration:
|
|
||||||
case IpcId::WorkspaceDidChangeWatchedFiles:
|
|
||||||
case IpcId::WorkspaceSymbol:
|
|
||||||
case IpcId::CqueryFileInfo:
|
|
||||||
case IpcId::CqueryFreshenIndex:
|
|
||||||
case IpcId::CqueryCallHierarchy:
|
|
||||||
case IpcId::CqueryInheritanceHierarchy:
|
|
||||||
case IpcId::CqueryMemberHierarchy:
|
|
||||||
case IpcId::CqueryVars:
|
|
||||||
case IpcId::CqueryCallers:
|
|
||||||
case IpcId::CqueryBase:
|
|
||||||
case IpcId::CqueryDerived:
|
|
||||||
case IpcId::CqueryIndexFile:
|
|
||||||
case IpcId::CqueryRandom:
|
|
||||||
case IpcId::CqueryWait: {
|
|
||||||
queue->for_querydb.PushBack(std::move(message));
|
queue->for_querydb.PushBack(std::move(message));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
LOG_S(ERROR) << "Unhandled IPC message " << IpcIdToString(method_id);
|
LOG_S(ERROR) << "Unhandled IPC message " << IpcIdToString(method_id);
|
||||||
|
85
src/ipc.cc
85
src/ipc.cc
@ -6,93 +6,14 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
switch (id) {
|
switch (id) {
|
||||||
case IpcId::CancelRequest:
|
case IpcId::CancelRequest:
|
||||||
return "$/cancelRequest";
|
return "$/cancelRequest";
|
||||||
case IpcId::Initialize:
|
|
||||||
return "initialize";
|
|
||||||
case IpcId::Initialized:
|
case IpcId::Initialized:
|
||||||
return "initialized";
|
return "initialized";
|
||||||
case IpcId::Shutdown:
|
|
||||||
return "shutdown";
|
|
||||||
case IpcId::Exit:
|
case IpcId::Exit:
|
||||||
return "exit";
|
return "exit";
|
||||||
case IpcId::CodeLensResolve:
|
|
||||||
return "codeLens/resolve";
|
|
||||||
case IpcId::TextDocumentDidOpen:
|
|
||||||
return "textDocument/didOpen";
|
|
||||||
case IpcId::TextDocumentDidChange:
|
|
||||||
return "textDocument/didChange";
|
|
||||||
case IpcId::TextDocumentDidClose:
|
|
||||||
return "textDocument/didClose";
|
|
||||||
case IpcId::TextDocumentDidSave:
|
|
||||||
return "textDocument/didSave";
|
|
||||||
case IpcId::TextDocumentPublishDiagnostics:
|
|
||||||
return "textDocument/publishDiagnostics";
|
|
||||||
case IpcId::TextDocumentRename:
|
|
||||||
return "textDocument/rename";
|
|
||||||
case IpcId::TextDocumentCompletion:
|
|
||||||
return "textDocument/completion";
|
|
||||||
case IpcId::TextDocumentSignatureHelp:
|
|
||||||
return "textDocument/signatureHelp";
|
|
||||||
case IpcId::TextDocumentDefinition:
|
|
||||||
return "textDocument/definition";
|
|
||||||
case IpcId::TextDocumentDocumentHighlight:
|
|
||||||
return "textDocument/documentHighlight";
|
|
||||||
case IpcId::TextDocumentHover:
|
|
||||||
return "textDocument/hover";
|
|
||||||
case IpcId::TextDocumentFormatting:
|
|
||||||
return "textDocument/formatting";
|
|
||||||
case IpcId::TextDocumentRangeFormatting:
|
|
||||||
return "textDocument/rangeFormatting";
|
|
||||||
case IpcId::TextDocumentOnTypeFormatting:
|
|
||||||
return "textDocument/onTypeFormatting";
|
|
||||||
case IpcId::TextDocumentReferences:
|
|
||||||
return "textDocument/references";
|
|
||||||
case IpcId::TextDocumentDocumentSymbol:
|
|
||||||
return "textDocument/documentSymbol";
|
|
||||||
case IpcId::TextDocumentDocumentLink:
|
|
||||||
return "textDocument/documentLink";
|
|
||||||
case IpcId::TextDocumentCodeAction:
|
|
||||||
return "textDocument/codeAction";
|
|
||||||
case IpcId::TextDocumentCodeLens:
|
|
||||||
return "textDocument/codeLens";
|
|
||||||
case IpcId::WorkspaceDidChangeConfiguration:
|
|
||||||
return "workspace/didChangeConfiguration";
|
|
||||||
case IpcId::WorkspaceDidChangeWatchedFiles:
|
|
||||||
return "workspace/didChangeWatchedFiles";
|
|
||||||
case IpcId::WorkspaceSymbol:
|
|
||||||
return "workspace/symbol";
|
|
||||||
|
|
||||||
case IpcId::CqueryTextDocumentDidView:
|
#define CASE(name, method) case IpcId::name: return method;
|
||||||
return "$cquery/textDocumentDidView";
|
#include "methods.inc"
|
||||||
case IpcId::CqueryPublishInactiveRegions:
|
#undef CASE
|
||||||
return "$cquery/publishInactiveRegions";
|
|
||||||
case IpcId::CqueryPublishSemanticHighlighting:
|
|
||||||
return "$cquery/publishSemanticHighlighting";
|
|
||||||
|
|
||||||
case IpcId::CqueryFileInfo:
|
|
||||||
return "$cquery/fileInfo";
|
|
||||||
case IpcId::CqueryFreshenIndex:
|
|
||||||
return "$cquery/freshenIndex";
|
|
||||||
case IpcId::CqueryCallHierarchy:
|
|
||||||
return "$cquery/callHierarchy";
|
|
||||||
case IpcId::CqueryInheritanceHierarchy:
|
|
||||||
return "$cquery/inheritanceHierarchy";
|
|
||||||
case IpcId::CqueryMemberHierarchy:
|
|
||||||
return "$cquery/memberHierarchy";
|
|
||||||
case IpcId::CqueryVars:
|
|
||||||
return "$cquery/vars";
|
|
||||||
case IpcId::CqueryCallers:
|
|
||||||
return "$cquery/callers";
|
|
||||||
case IpcId::CqueryBase:
|
|
||||||
return "$cquery/base";
|
|
||||||
case IpcId::CqueryDerived:
|
|
||||||
return "$cquery/derived";
|
|
||||||
case IpcId::CqueryRandom:
|
|
||||||
return "$cquery/random";
|
|
||||||
|
|
||||||
case IpcId::CqueryIndexFile:
|
|
||||||
return "$cquery/indexFile";
|
|
||||||
case IpcId::CqueryWait:
|
|
||||||
return "$cquery/wait";
|
|
||||||
|
|
||||||
case IpcId::Unknown:
|
case IpcId::Unknown:
|
||||||
return "$unknown";
|
return "$unknown";
|
||||||
|
53
src/ipc.h
53
src/ipc.h
@ -10,59 +10,12 @@ using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
|||||||
enum class IpcId : int {
|
enum class IpcId : int {
|
||||||
// Language server specific requests.
|
// Language server specific requests.
|
||||||
CancelRequest = 0,
|
CancelRequest = 0,
|
||||||
Initialize,
|
|
||||||
Initialized,
|
Initialized,
|
||||||
Exit,
|
Exit,
|
||||||
Shutdown,
|
|
||||||
|
|
||||||
CodeLensResolve,
|
#define CASE(x, _) x,
|
||||||
TextDocumentDidOpen,
|
#include "methods.inc"
|
||||||
TextDocumentDidChange,
|
#undef CASE
|
||||||
TextDocumentDidClose,
|
|
||||||
TextDocumentDidSave,
|
|
||||||
TextDocumentPublishDiagnostics,
|
|
||||||
TextDocumentRename,
|
|
||||||
TextDocumentCompletion,
|
|
||||||
TextDocumentSignatureHelp,
|
|
||||||
TextDocumentDefinition,
|
|
||||||
TextDocumentDocumentHighlight,
|
|
||||||
TextDocumentHover,
|
|
||||||
TextDocumentFormatting,
|
|
||||||
TextDocumentRangeFormatting,
|
|
||||||
TextDocumentOnTypeFormatting,
|
|
||||||
TextDocumentReferences,
|
|
||||||
TextDocumentDocumentSymbol,
|
|
||||||
TextDocumentDocumentLink,
|
|
||||||
TextDocumentCodeAction,
|
|
||||||
TextDocumentCodeLens,
|
|
||||||
WorkspaceDidChangeConfiguration,
|
|
||||||
WorkspaceDidChangeWatchedFiles,
|
|
||||||
WorkspaceSymbol,
|
|
||||||
|
|
||||||
// Custom notifications
|
|
||||||
// Comes from the client. Does various things, like update semantic
|
|
||||||
// highlighting.
|
|
||||||
CqueryTextDocumentDidView,
|
|
||||||
CqueryPublishInactiveRegions,
|
|
||||||
CqueryPublishSemanticHighlighting,
|
|
||||||
|
|
||||||
// Custom messages
|
|
||||||
CqueryFileInfo,
|
|
||||||
CqueryFreshenIndex,
|
|
||||||
// Messages used in tree views.
|
|
||||||
CqueryCallHierarchy,
|
|
||||||
CqueryInheritanceHierarchy,
|
|
||||||
CqueryMemberHierarchy,
|
|
||||||
// cquery cross reference extension.
|
|
||||||
CqueryVars, // Show all variables of a type.
|
|
||||||
CqueryCallers, // Show all callers of a function.
|
|
||||||
CqueryBase, // Show base types/method.
|
|
||||||
CqueryDerived, // Show all derived types/methods.
|
|
||||||
CqueryRandom, // Show random definition.
|
|
||||||
|
|
||||||
// Messages for testing.
|
|
||||||
CqueryIndexFile, // Index the given file contents.
|
|
||||||
CqueryWait, // Wait until all cquery threads are idle.
|
|
||||||
|
|
||||||
// Internal implementation detail.
|
// Internal implementation detail.
|
||||||
Unknown,
|
Unknown,
|
||||||
|
29
src/messages/text_document_type_definition.cc
Normal file
29
src/messages/text_document_type_definition.cc
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "message_handler.h"
|
||||||
|
#include "query_utils.h"
|
||||||
|
#include "queue_manager.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct Ipc_TextDocumentTypeDefinition
|
||||||
|
: public RequestMessage<Ipc_TextDocumentTypeDefinition> {
|
||||||
|
const static IpcId kIpcId = IpcId::TextDocumentTypeDefinition;
|
||||||
|
lsTextDocumentPositionParams params;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentTypeDefinition, id, params);
|
||||||
|
REGISTER_IPC_MESSAGE(Ipc_TextDocumentTypeDefinition);
|
||||||
|
|
||||||
|
struct Out_TextDocumentTypeDefinition
|
||||||
|
: public lsOutMessage<Out_TextDocumentTypeDefinition> {
|
||||||
|
lsRequestId id;
|
||||||
|
std::vector<lsLocationEx> result;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result);
|
||||||
|
|
||||||
|
struct TextDocumentTypeDefinitionHandler
|
||||||
|
: BaseMessageHandler<Ipc_TextDocumentTypeDefinition> {
|
||||||
|
void Run(Ipc_TextDocumentTypeDefinition* request) override {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler);
|
||||||
|
|
||||||
|
} // namespace
|
59
src/methods.inc
Normal file
59
src/methods.inc
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// 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(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")
|
Loading…
Reference in New Issue
Block a user