Switch to {Request,Notification}Message

This commit is contained in:
Fangrui Song 2018-01-19 00:56:09 -08:00
parent 148a8b3f20
commit 0e2b2cfb0c
17 changed files with 40 additions and 63 deletions

View File

@ -251,7 +251,7 @@ optional<lsTextEdit> BuildAutoImplementForFunction(QueryDatabase* db,
}
struct Ipc_TextDocumentCodeAction
: public IpcMessage<Ipc_TextDocumentCodeAction> {
: public RequestMessage<Ipc_TextDocumentCodeAction> {
const static IpcId kIpcId = IpcId::TextDocumentCodeAction;
// Contains additional diagnostic information about the context in which
// a code action is run.
@ -268,8 +268,6 @@ struct Ipc_TextDocumentCodeAction
// Context carrying additional information.
lsCodeActionContext context;
};
lsRequestId id;
lsCodeActionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionContext,

View File

@ -36,9 +36,9 @@ void Reflect(Reader& visitor, lsCodeLensCommandArguments& value) {
#endif
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
struct Ipc_TextDocumentCodeLens : public IpcMessage<Ipc_TextDocumentCodeLens> {
struct Ipc_TextDocumentCodeLens
: public RequestMessage<Ipc_TextDocumentCodeLens> {
const static IpcId kIpcId = IpcId::TextDocumentCodeLens;
lsRequestId id;
lsDocumentCodeLensParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params);

View File

@ -45,10 +45,9 @@ struct lsCompletionParams : lsTextDocumentPositionParams {
};
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context);
struct Ipc_TextDocumentComplete : public IpcMessage<Ipc_TextDocumentComplete> {
struct Ipc_TextDocumentComplete
: public RequestMessage<Ipc_TextDocumentComplete> {
const static IpcId kIpcId = IpcId::TextDocumentCompletion;
lsRequestId id;
lsCompletionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentComplete, id, params);

View File

@ -4,7 +4,7 @@
namespace {
struct Ipc_TextDocumentDidChange
: public IpcMessage<Ipc_TextDocumentDidChange> {
: public NotificationMessage<Ipc_TextDocumentDidChange> {
const static IpcId kIpcId = IpcId::TextDocumentDidChange;
lsTextDocumentDidChangeParams params;
};

View File

@ -4,12 +4,12 @@
#include "working_files.h"
namespace {
struct Ipc_TextDocumentDidClose : public IpcMessage<Ipc_TextDocumentDidClose> {
struct Ipc_TextDocumentDidClose
: public NotificationMessage<Ipc_TextDocumentDidClose> {
const static IpcId kIpcId = IpcId::TextDocumentDidClose;
struct Params {
lsTextDocumentIdentifier textDocument;
};
const static IpcId kIpcId = IpcId::TextDocumentDidClose;
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose::Params, textDocument);

View File

@ -9,12 +9,12 @@
namespace {
// Open, view, change, close file
struct Ipc_TextDocumentDidOpen : public IpcMessage<Ipc_TextDocumentDidOpen> {
struct Ipc_TextDocumentDidOpen
: public NotificationMessage<Ipc_TextDocumentDidOpen> {
const static IpcId kIpcId = IpcId::TextDocumentDidOpen;
struct Params {
lsTextDocumentItem textDocument;
};
const static IpcId kIpcId = IpcId::TextDocumentDidOpen;
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument);

View File

@ -6,7 +6,9 @@
#include <loguru/loguru.hpp>
namespace {
struct Ipc_TextDocumentDidSave : public IpcMessage<Ipc_TextDocumentDidSave> {
struct Ipc_TextDocumentDidSave
: public NotificationMessage<Ipc_TextDocumentDidSave> {
const static IpcId kIpcId = IpcId::TextDocumentDidSave;
struct Params {
// The document that was saved.
lsTextDocumentIdentifier textDocument;
@ -15,8 +17,6 @@ struct Ipc_TextDocumentDidSave : public IpcMessage<Ipc_TextDocumentDidSave> {
// when the save notifcation was requested.
// std::string text;
};
const static IpcId kIpcId = IpcId::TextDocumentDidSave;
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave::Params, textDocument);

View File

@ -7,18 +7,15 @@
namespace {
struct Ipc_TextDocumentDocumentLink
: public IpcMessage<Ipc_TextDocumentDocumentLink> {
: public RequestMessage<Ipc_TextDocumentDocumentLink> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentLink;
struct DocumentLinkParams {
struct Params {
// The document to provide document links for.
lsTextDocumentIdentifier textDocument;
};
lsRequestId id;
DocumentLinkParams params;
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::DocumentLinkParams,
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::Params,
textDocument);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentLink);

View File

@ -9,10 +9,8 @@ struct lsDocumentSymbolParams {
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
struct Ipc_TextDocumentDocumentSymbol
: public IpcMessage<Ipc_TextDocumentDocumentSymbol> {
: public RequestMessage<Ipc_TextDocumentDocumentSymbol> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol;
lsRequestId id;
lsDocumentSymbolParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params);

View File

@ -7,19 +7,16 @@
namespace {
struct lsTextDocumentFormattingParams {
lsTextDocumentIdentifier textDocument;
lsFormattingOptions options;
};
MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options);
struct Ipc_TextDocumentFormatting
: public IpcMessage<Ipc_TextDocumentFormatting> {
: public RequestMessage<Ipc_TextDocumentFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
lsRequestId id;
lsTextDocumentFormattingParams params;
struct Params {
lsTextDocumentIdentifier textDocument;
lsFormattingOptions options;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting::Params, textDocument, options);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting);

View File

@ -4,10 +4,8 @@
namespace {
struct Ipc_TextDocumentDocumentHighlight
: public IpcMessage<Ipc_TextDocumentDocumentHighlight> {
: public RequestMessage<Ipc_TextDocumentDocumentHighlight> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentHighlight;
lsRequestId id;
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentHighlight, id, params);

View File

@ -38,10 +38,8 @@ std::pair<optional<std::string>, std::string> GetCommentsAndHover(
return {nullopt, ""};
}
struct Ipc_TextDocumentHover : public IpcMessage<Ipc_TextDocumentHover> {
struct Ipc_TextDocumentHover : public RequestMessage<Ipc_TextDocumentHover> {
const static IpcId kIpcId = IpcId::TextDocumentHover;
lsRequestId id;
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params);

View File

@ -19,10 +19,8 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
options);
struct Ipc_TextDocumentRangeFormatting
: public IpcMessage<Ipc_TextDocumentRangeFormatting> {
: public RequestMessage<Ipc_TextDocumentRangeFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
lsRequestId id;
lsTextDocumentRangeFormattingParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params);

View File

@ -49,7 +49,8 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
return edit;
}
struct Ipc_TextDocumentRename : public IpcMessage<Ipc_TextDocumentRename> {
struct Ipc_TextDocumentRename : public RequestMessage<Ipc_TextDocumentRename> {
const static IpcId kIpcId = IpcId::TextDocumentRename;
struct Params {
// The document to format.
lsTextDocumentIdentifier textDocument;
@ -62,9 +63,6 @@ struct Ipc_TextDocumentRename : public IpcMessage<Ipc_TextDocumentRename> {
// appropriate message set.
std::string newName;
};
const static IpcId kIpcId = IpcId::TextDocumentRename;
lsRequestId id;
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename::Params,

View File

@ -6,10 +6,8 @@
namespace {
struct Ipc_TextDocumentSignatureHelp
: public IpcMessage<Ipc_TextDocumentSignatureHelp> {
: public RequestMessage<Ipc_TextDocumentSignatureHelp> {
const static IpcId kIpcId = IpcId::TextDocumentSignatureHelp;
lsRequestId id;
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentSignatureHelp, id, params);

View File

@ -22,7 +22,7 @@ struct lsDidChangeWatchedFilesParams {
MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes);
struct Ipc_WorkspaceDidChangeWatchedFiles
: public IpcMessage<Ipc_WorkspaceDidChangeWatchedFiles> {
: public NotificationMessage<Ipc_WorkspaceDidChangeWatchedFiles> {
const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles;
lsDidChangeWatchedFilesParams params;
};

View File

@ -39,16 +39,14 @@ bool InsertSymbolIntoResult(QueryDatabase* db,
return true;
}
struct lsWorkspaceSymbolParams {
std::string query;
};
MAKE_REFLECT_STRUCT(lsWorkspaceSymbolParams, query);
struct Ipc_WorkspaceSymbol : public IpcMessage<Ipc_WorkspaceSymbol> {
struct Ipc_WorkspaceSymbol : public RequestMessage<Ipc_WorkspaceSymbol> {
const static IpcId kIpcId = IpcId::WorkspaceSymbol;
lsRequestId id;
lsWorkspaceSymbolParams params;
struct Params {
std::string query;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol::Params, query);
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params);
REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol);