ccls/src/ipc.h

113 lines
3.0 KiB
C
Raw Normal View History

2017-03-25 23:58:11 +00:00
#pragma once
#include "serializer.h"
2017-09-22 01:14:57 +00:00
#include "utils.h"
2017-03-25 23:58:11 +00:00
#include <string>
enum class IpcId : int {
// Language server specific requests.
CancelRequest = 0,
Initialize,
Initialized,
2017-05-03 06:45:10 +00:00
Exit,
TextDocumentDidOpen,
TextDocumentDidChange,
TextDocumentDidClose,
TextDocumentDidSave,
2017-05-10 06:13:13 +00:00
TextDocumentPublishDiagnostics,
TextDocumentRename,
TextDocumentCompletion,
TextDocumentSignatureHelp,
TextDocumentDefinition,
TextDocumentDocumentHighlight,
TextDocumentHover,
2017-04-10 05:34:06 +00:00
TextDocumentReferences,
2017-03-25 23:58:11 +00:00
TextDocumentDocumentSymbol,
2017-05-21 04:30:59 +00:00
TextDocumentDocumentLink,
TextDocumentCodeAction,
2017-03-25 23:58:11 +00:00
TextDocumentCodeLens,
CodeLensResolve,
WorkspaceSymbol,
// Custom notifications
CqueryPublishInactiveRegions,
// Custom messages
CqueryFreshenIndex,
// Messages used in tree views.
CqueryTypeHierarchyTree,
CqueryCallTreeInitial,
CqueryCallTreeExpand,
// These are like DocumentReferences but show different types of data.
2017-09-22 01:14:57 +00:00
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.
2017-03-25 23:58:11 +00:00
// Internal implementation detail.
2017-09-13 03:35:27 +00:00
Cout,
// Index the given file contents. Used in tests.
CqueryIndexFile,
// Make querydb wait for the indexer to be idle. Used in tests.
CqueryQueryDbWaitForIdleIndexer,
// Exit after all messages have been read/processes. Used in tests.
CqueryExitWhenIdle
2017-03-25 23:58:11 +00:00
};
MAKE_ENUM_HASHABLE(IpcId)
MAKE_REFLECT_TYPE_PROXY(IpcId, int)
const char* IpcIdToString(IpcId id);
struct BaseIpcMessage {
const IpcId method_id;
BaseIpcMessage(IpcId method_id);
2017-06-09 06:20:29 +00:00
virtual ~BaseIpcMessage();
2017-09-22 01:32:55 +00:00
template <typename T>
T* As() {
assert(method_id == T::kIpcId);
return static_cast<T*>(this);
}
2017-03-25 23:58:11 +00:00
};
template <typename T>
struct IpcMessage : public BaseIpcMessage {
IpcMessage() : BaseIpcMessage(T::kIpcId) {}
};
struct Ipc_Cout : public IpcMessage<Ipc_Cout> {
static constexpr IpcId kIpcId = IpcId::Cout;
std::string content;
IpcId original_ipc_id;
2017-03-25 23:58:11 +00:00
};
2017-09-13 03:35:27 +00:00
MAKE_REFLECT_STRUCT(Ipc_Cout, content);
struct Ipc_CqueryIndexFile : public IpcMessage<Ipc_CqueryIndexFile> {
static constexpr IpcId kIpcId = IpcId::CqueryIndexFile;
struct Params {
std::string path;
std::vector<std::string> args;
bool is_interactive = false;
std::string contents;
};
Params params;
};
2017-09-22 01:14:57 +00:00
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile::Params,
path,
args,
is_interactive,
contents);
2017-09-13 03:35:27 +00:00
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile, params);
2017-09-22 01:14:57 +00:00
struct Ipc_CqueryQueryDbWaitForIdleIndexer
: public IpcMessage<Ipc_CqueryQueryDbWaitForIdleIndexer> {
2017-09-13 03:35:27 +00:00
static constexpr IpcId kIpcId = IpcId::CqueryQueryDbWaitForIdleIndexer;
};
MAKE_REFLECT_EMPTY_STRUCT(Ipc_CqueryQueryDbWaitForIdleIndexer);
struct Ipc_CqueryExitWhenIdle : public IpcMessage<Ipc_CqueryExitWhenIdle> {
static constexpr IpcId kIpcId = IpcId::CqueryExitWhenIdle;
};
MAKE_REFLECT_EMPTY_STRUCT(Ipc_CqueryExitWhenIdle);