diff --git a/src/atomic_object.h b/src/atomic_object.h deleted file mode 100644 index a953f37c..00000000 --- a/src/atomic_object.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -// A object which can be stored and taken from atomically. -template -struct AtomicObject { - void Set(std::unique_ptr t) { - std::lock_guard lock(mutex_); - value_ = std::move(t); - cv_.notify_one(); - } - - void SetIfEmpty(std::unique_ptr t) { - std::lock_guard lock(mutex_); - if (value_) - return; - - value_ = std::move(t); - cv_.notify_one(); - } - - std::unique_ptr Take() { - std::unique_lock lock(mutex_); - while (!value_) { - // release lock as long as the wait and reaquire it afterwards. - cv_.wait(lock); - } - - return std::move(value_); - } - - template - void WithLock(TAction action) { - std::unique_lock lock(mutex_); - bool had_value = !!value_; - action(value_); - bool has_value = !!value_; - - if (had_value != has_value) - cv_.notify_one(); - } - - private: - std::unique_ptr value_; - mutable std::mutex mutex_; - std::condition_variable cv_; -}; diff --git a/src/clang_complete.h b/src/clang_complete.h index 5df97256..cf752417 100644 --- a/src/clang_complete.h +++ b/src/clang_complete.h @@ -1,6 +1,5 @@ #pragma once -#include "atomic_object.h" #include "clang_index.h" #include "clang_translation_unit.h" #include "lsp_completion.h" diff --git a/src/indexer.cc b/src/clang_indexer.cc similarity index 100% rename from src/indexer.cc rename to src/clang_indexer.cc diff --git a/src/command_line.cc b/src/command_line.cc index 070d19e1..837a9f61 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -339,6 +339,7 @@ void LaunchStdinLoop(Config* config, case IpcId::TextDocumentDocumentLink: case IpcId::TextDocumentCodeAction: case IpcId::TextDocumentCodeLens: + case IpcId::WorkspaceDidChangeConfiguration: case IpcId::WorkspaceDidChangeWatchedFiles: case IpcId::WorkspaceSymbol: case IpcId::CqueryFileInfo: diff --git a/src/ipc.cc b/src/ipc.cc index f208d260..0c86e432 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -14,6 +14,8 @@ const char* IpcIdToString(IpcId id) { return "shutdown"; case IpcId::Exit: return "exit"; + case IpcId::CodeLensResolve: + return "codeLens/resolve"; case IpcId::TextDocumentDidOpen: return "textDocument/didOpen"; case IpcId::TextDocumentDidChange: @@ -52,8 +54,8 @@ const char* IpcIdToString(IpcId id) { return "textDocument/codeAction"; case IpcId::TextDocumentCodeLens: return "textDocument/codeLens"; - case IpcId::CodeLensResolve: - return "codeLens/resolve"; + case IpcId::WorkspaceDidChangeConfiguration: + return "workspace/didChangeConfiguration"; case IpcId::WorkspaceDidChangeWatchedFiles: return "workspace/didChangeWatchedFiles"; case IpcId::WorkspaceSymbol: diff --git a/src/ipc.h b/src/ipc.h index 93a57b00..97813fba 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -12,8 +12,10 @@ enum class IpcId : int { CancelRequest = 0, Initialize, Initialized, - Shutdown, Exit, + Shutdown, + + CodeLensResolve, TextDocumentDidOpen, TextDocumentDidChange, TextDocumentDidClose, @@ -33,7 +35,7 @@ enum class IpcId : int { TextDocumentDocumentLink, TextDocumentCodeAction, TextDocumentCodeLens, - CodeLensResolve, + WorkspaceDidChangeConfiguration, WorkspaceDidChangeWatchedFiles, WorkspaceSymbol, @@ -51,7 +53,7 @@ enum class IpcId : int { CqueryCallHierarchy, CqueryInheritanceHierarchy, CqueryMemberHierarchy, - // These are like DocumentReferences but show different types of data. + // cquery cross reference extension. CqueryVars, // Show all variables of a type. CqueryCallers, // Show all callers of a function. CqueryBase, // Show base types/method. diff --git a/src/lsp.cc b/src/lsp.cc index 32bc3844..47d869ea 100644 --- a/src/lsp.cc +++ b/src/lsp.cc @@ -195,10 +195,6 @@ void lsResponseError::Write(Writer& visitor) { visitor.StartObject(); REFLECT_MEMBER2("code", code2); REFLECT_MEMBER(message); - if (data) { - visitor.Key("data"); - data->Write(visitor); - } visitor.EndObject(); } diff --git a/src/lsp.h b/src/lsp.h index 2a7fbfd2..55527a2c 100644 --- a/src/lsp.h +++ b/src/lsp.h @@ -73,10 +73,6 @@ struct lsOutMessage : lsBaseOutMessage { }; struct lsResponseError { - struct Data { - virtual void Write(Writer& writer) = 0; - }; - enum class lsErrorCodes : int { ParseError = -32700, InvalidRequest = -32600, @@ -86,13 +82,13 @@ struct lsResponseError { serverErrorStart = -32099, serverErrorEnd = -32000, ServerNotInitialized = -32002, - UnknownErrorCode = -32001 + UnknownErrorCode = -32001, + RequestCancelled = -32800, }; lsErrorCodes code; // Short description. std::string message; - std::unique_ptr data; void Write(Writer& visitor); }; diff --git a/src/messages/workspace_did_change_configuration.cc b/src/messages/workspace_did_change_configuration.cc new file mode 100644 index 00000000..2e672996 --- /dev/null +++ b/src/messages/workspace_did_change_configuration.cc @@ -0,0 +1,27 @@ +#include "cache_manager.h" +#include "message_handler.h" +#include "project.h" +#include "queue_manager.h" +#include "working_files.h" + +namespace { +struct lsDidChangeConfigurationParams { + bool placeholder; +}; +MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder); + +struct Ipc_WorkspaceDidChangeConfiguration + : public NotificationMessage { + const static IpcId kIpcId = IpcId::WorkspaceDidChangeConfiguration; + lsDidChangeConfigurationParams params; +}; +MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeConfiguration, params); +REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeConfiguration); + +struct WorkspaceDidChangeConfigurationHandler + : BaseMessageHandler { + void Run(Ipc_WorkspaceDidChangeConfiguration* request) override { + } +}; +REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeConfigurationHandler); +} // namespace