mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Add {Request,Notification}Message
This commit is contained in:
parent
162f995344
commit
148a8b3f20
15
src/ipc.h
15
src/ipc.h
@ -5,6 +5,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||
|
||||
enum class IpcId : int {
|
||||
// Language server specific requests.
|
||||
CancelRequest = 0,
|
||||
@ -84,3 +86,16 @@ template <typename T>
|
||||
struct IpcMessage : public BaseIpcMessage {
|
||||
IpcMessage() : BaseIpcMessage(T::kIpcId) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RequestMessage : public BaseIpcMessage {
|
||||
// number | string, actually no null
|
||||
lsRequestId id;
|
||||
RequestMessage() : BaseIpcMessage(T::kIpcId) {}
|
||||
};
|
||||
|
||||
// NotificationMessage does not have |id|.
|
||||
template <typename T>
|
||||
struct NotificationMessage : public BaseIpcMessage {
|
||||
NotificationMessage() : BaseIpcMessage(T::kIpcId) {}
|
||||
};
|
||||
|
@ -24,8 +24,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -9,10 +9,8 @@ void PushBack(std::vector<lsLocation>* result, optional<lsLocation> location) {
|
||||
}
|
||||
|
||||
struct Ipc_TextDocumentDefinition
|
||||
: public IpcMessage<Ipc_TextDocumentDefinition> {
|
||||
: public RequestMessage<Ipc_TextDocumentDefinition> {
|
||||
const static IpcId kIpcId = IpcId::TextDocumentDefinition;
|
||||
|
||||
lsRequestId id;
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDefinition, id, params);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace {
|
||||
struct Ipc_TextDocumentReferences
|
||||
: public IpcMessage<Ipc_TextDocumentReferences> {
|
||||
: public RequestMessage<Ipc_TextDocumentReferences> {
|
||||
struct lsReferenceContext {
|
||||
// Include the declaration of the current symbol.
|
||||
bool includeDeclaration;
|
||||
@ -19,7 +19,6 @@ struct Ipc_TextDocumentReferences
|
||||
|
||||
const static IpcId kIpcId = IpcId::TextDocumentReferences;
|
||||
|
||||
lsRequestId id;
|
||||
lsReferenceParams params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext,
|
||||
|
Loading…
Reference in New Issue
Block a user