From 3e076b41117157b9aa72478bccfeae3aa211f01f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 9 Jan 2018 21:11:30 -0800 Subject: [PATCH] workspace/didChangeWatchedFiles placeholder --- src/command_line.cc | 1 + src/ipc.cc | 2 + src/ipc.h | 1 + .../workspace_did_change_watched_files.cc | 51 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 src/messages/workspace_did_change_watched_files.cc diff --git a/src/command_line.cc b/src/command_line.cc index 123f62a5..ab6c45c1 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -286,6 +286,7 @@ void LaunchStdinLoop(Config* config, case IpcId::TextDocumentDocumentLink: case IpcId::TextDocumentCodeAction: case IpcId::TextDocumentCodeLens: + case IpcId::WorkspaceDidChangeWatchedFiles: case IpcId::WorkspaceSymbol: case IpcId::CqueryFreshenIndex: case IpcId::CqueryTypeHierarchyTree: diff --git a/src/ipc.cc b/src/ipc.cc index 767528fe..53919f7c 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -54,6 +54,8 @@ const char* IpcIdToString(IpcId id) { return "textDocument/codeLens"; case IpcId::CodeLensResolve: return "codeLens/resolve"; + case IpcId::WorkspaceDidChangeWatchedFiles: + return "workspace/didChangeWatchedFiles"; case IpcId::WorkspaceSymbol: return "workspace/symbol"; diff --git a/src/ipc.h b/src/ipc.h index c626c7a8..714c6431 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -32,6 +32,7 @@ enum class IpcId : int { TextDocumentCodeAction, TextDocumentCodeLens, CodeLensResolve, + WorkspaceDidChangeWatchedFiles, WorkspaceSymbol, // Custom notifications diff --git a/src/messages/workspace_did_change_watched_files.cc b/src/messages/workspace_did_change_watched_files.cc new file mode 100644 index 00000000..04e05ce0 --- /dev/null +++ b/src/messages/workspace_did_change_watched_files.cc @@ -0,0 +1,51 @@ +#include "message_handler.h" +#include "queue_manager.h" + +namespace { +enum class lsFileChangeType { + Created = 1, + Changed = 2, + Deleted = 3, +}; +MAKE_REFLECT_TYPE_PROXY(lsFileChangeType, + std::underlying_type::type); + +struct lsFileEvent { + lsDocumentUri uri; + lsFileChangeType type; +}; +MAKE_REFLECT_STRUCT(lsFileEvent, uri, type); + +struct lsDidChangeWatchedFilesParams { + std::vector changes; +}; +MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes); + +struct Ipc_WorkspaceDidChangeWatchedFiles + : public IpcMessage { + const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles; + lsDidChangeWatchedFilesParams params; +}; +MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeWatchedFiles, params); +REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeWatchedFiles); + +struct WorkspaceDidChangeWatchedFilesHandler + : BaseMessageHandler { + void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override { + for (lsFileEvent& event : request->params.changes) { + switch (event.type) { + case lsFileChangeType::Created: + // TODO + break; + case lsFileChangeType::Deleted: + // TODO + break; + case lsFileChangeType::Changed: + // TODO + break; + } + } + } +}; +REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeWatchedFilesHandler); +} // namespace