mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
Remove atomic_object.h and add workspace/didChangeConfiguration placeholder
This commit is contained in:
parent
56f57fc38e
commit
0ba8f2a42c
@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
// A object which can be stored and taken from atomically.
|
||||
template <class T>
|
||||
struct AtomicObject {
|
||||
void Set(std::unique_ptr<T> t) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
value_ = std::move(t);
|
||||
cv_.notify_one();
|
||||
}
|
||||
|
||||
void SetIfEmpty(std::unique_ptr<T> t) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (value_)
|
||||
return;
|
||||
|
||||
value_ = std::move(t);
|
||||
cv_.notify_one();
|
||||
}
|
||||
|
||||
std::unique_ptr<T> Take() {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (!value_) {
|
||||
// release lock as long as the wait and reaquire it afterwards.
|
||||
cv_.wait(lock);
|
||||
}
|
||||
|
||||
return std::move(value_);
|
||||
}
|
||||
|
||||
template <typename TAction>
|
||||
void WithLock(TAction action) {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
bool had_value = !!value_;
|
||||
action(value_);
|
||||
bool has_value = !!value_;
|
||||
|
||||
if (had_value != has_value)
|
||||
cv_.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<T> value_;
|
||||
mutable std::mutex mutex_;
|
||||
std::condition_variable cv_;
|
||||
};
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "atomic_object.h"
|
||||
#include "clang_index.h"
|
||||
#include "clang_translation_unit.h"
|
||||
#include "lsp_completion.h"
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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> data;
|
||||
|
||||
void Write(Writer& visitor);
|
||||
};
|
||||
|
27
src/messages/workspace_did_change_configuration.cc
Normal file
27
src/messages/workspace_did_change_configuration.cc
Normal file
@ -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<Ipc_WorkspaceDidChangeConfiguration> {
|
||||
const static IpcId kIpcId = IpcId::WorkspaceDidChangeConfiguration;
|
||||
lsDidChangeConfigurationParams params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeConfiguration, params);
|
||||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeConfiguration);
|
||||
|
||||
struct WorkspaceDidChangeConfigurationHandler
|
||||
: BaseMessageHandler<Ipc_WorkspaceDidChangeConfiguration> {
|
||||
void Run(Ipc_WorkspaceDidChangeConfiguration* request) override {
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeConfigurationHandler);
|
||||
} // namespace
|
Loading…
Reference in New Issue
Block a user