mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 00:25:07 +00:00
Remove global list of message ids.
Also do some naming cleanup. Also remove xmacros.
This commit is contained in:
parent
5f085729bd
commit
cad6dcda0c
@ -57,20 +57,15 @@ namespace {
|
|||||||
std::vector<std::string> kEmptyArgs;
|
std::vector<std::string> kEmptyArgs;
|
||||||
|
|
||||||
// This function returns true if e2e timing should be displayed for the given
|
// This function returns true if e2e timing should be displayed for the given
|
||||||
// IpcId.
|
// MethodId.
|
||||||
bool ShouldDisplayIpcTiming(IpcId id) {
|
bool ShouldDisplayMethodTiming(MethodType type) {
|
||||||
switch (id) {
|
return
|
||||||
case IpcId::TextDocumentPublishDiagnostics:
|
type != kMethodType_TextDocumentPublishDiagnostics &&
|
||||||
case IpcId::CqueryPublishInactiveRegions:
|
type != kMethodType_CqueryPublishInactiveRegions &&
|
||||||
case IpcId::Unknown:
|
type != kMethodType_Unknown;
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CancelRequest);
|
|
||||||
|
|
||||||
void PrintHelp() {
|
void PrintHelp() {
|
||||||
std::cout
|
std::cout
|
||||||
<< R"help(cquery is a low-latency C/C++/Objective-C language server.
|
<< R"help(cquery is a low-latency C/C++/Objective-C language server.
|
||||||
@ -146,16 +141,16 @@ bool QueryDbMainLoop(Config* config,
|
|||||||
queue->for_querydb.DequeueAll();
|
queue->for_querydb.DequeueAll();
|
||||||
bool did_work = messages.size();
|
bool did_work = messages.size();
|
||||||
for (auto& message : messages) {
|
for (auto& message : messages) {
|
||||||
|
// TODO: Consider using std::unordered_map to lookup the handler
|
||||||
for (MessageHandler* handler : *MessageHandler::message_handlers) {
|
for (MessageHandler* handler : *MessageHandler::message_handlers) {
|
||||||
if (handler->GetId() == message->method_id) {
|
if (handler->GetMethodType() == message->GetMethodType()) {
|
||||||
handler->Run(std::move(message));
|
handler->Run(std::move(message));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
LOG_S(FATAL) << "Exiting; unhandled IPC message "
|
LOG_S(FATAL) << "Exiting; no handler for " << message->GetMethodType();
|
||||||
<< IpcIdToString(message->method_id);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +194,7 @@ void RunQueryDbThread(const std::string& bin_name,
|
|||||||
out.error.message =
|
out.error.message =
|
||||||
"Dropping completion request; a newer request "
|
"Dropping completion request; a newer request "
|
||||||
"has come in that will be serviced instead.";
|
"has come in that will be serviced instead.";
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(kMethodType_Unknown, out);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -278,7 +273,7 @@ void RunQueryDbThread(const std::string& bin_name,
|
|||||||
//
|
//
|
||||||
// |ipc| is connected to a server.
|
// |ipc| is connected to a server.
|
||||||
void LaunchStdinLoop(Config* config,
|
void LaunchStdinLoop(Config* config,
|
||||||
std::unordered_map<IpcId, Timer>* request_times) {
|
std::unordered_map<MethodType, Timer>* request_times) {
|
||||||
// If flushing cin requires flushing cout there could be deadlocks in some
|
// If flushing cin requires flushing cout there could be deadlocks in some
|
||||||
// clients.
|
// clients.
|
||||||
std::cin.tie(nullptr);
|
std::cin.tie(nullptr);
|
||||||
@ -301,47 +296,28 @@ void LaunchStdinLoop(Config* config,
|
|||||||
out.id = id;
|
out.id = id;
|
||||||
out.error.code = lsErrorCodes::InvalidParams;
|
out.error.code = lsErrorCodes::InvalidParams;
|
||||||
out.error.message = std::move(*err);
|
out.error.message = std::move(*err);
|
||||||
queue->WriteStdout(IpcId::Unknown, out);
|
queue->WriteStdout(kMethodType_Unknown, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache |method_id| so we can access it after moving |message|.
|
// Cache |method_id| so we can access it after moving |message|.
|
||||||
IpcId method_id = message->method_id;
|
MethodType method_type = message->GetMethodType();
|
||||||
(*request_times)[method_id] = Timer();
|
(*request_times)[method_type] = Timer();
|
||||||
|
|
||||||
switch (method_id) {
|
LOG_S(ERROR) << "!! Got message of type " << method_type;
|
||||||
case IpcId::Initialized: {
|
|
||||||
// TODO: don't send output until we get this notification
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case IpcId::CancelRequest: {
|
|
||||||
// TODO: support cancellation
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case IpcId::Exit:
|
|
||||||
#define CASE(name, method) case IpcId::name:
|
|
||||||
#include "methods.inc"
|
|
||||||
#undef CASE
|
|
||||||
queue->for_querydb.PushBack(std::move(message));
|
queue->for_querydb.PushBack(std::move(message));
|
||||||
break;
|
|
||||||
|
|
||||||
case IpcId::Unknown:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the message was to exit then querydb will take care of the actual
|
// If the message was to exit then querydb will take care of the actual
|
||||||
// exit. Stop reading from stdin since it might be detached.
|
// exit. Stop reading from stdin since it might be detached.
|
||||||
if (method_id == IpcId::Exit)
|
if (method_type == kMethodType_Exit)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
|
void LaunchStdoutThread(std::unordered_map<MethodType, Timer>* request_times,
|
||||||
MultiQueueWaiter* waiter) {
|
MultiQueueWaiter* waiter) {
|
||||||
WorkThread::StartThread("stdout", [=]() {
|
WorkThread::StartThread("stdout", [=]() {
|
||||||
auto* queue = QueueManager::instance();
|
auto* queue = QueueManager::instance();
|
||||||
@ -354,10 +330,9 @@ void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& message : messages) {
|
for (auto& message : messages) {
|
||||||
if (ShouldDisplayIpcTiming(message.id)) {
|
if (ShouldDisplayMethodTiming(message.method)) {
|
||||||
Timer time = (*request_times)[message.id];
|
Timer time = (*request_times)[message.method];
|
||||||
time.ResetAndPrint("[e2e] Running " +
|
time.ResetAndPrint("[e2e] Running " + std::string(message.method));
|
||||||
std::string(IpcIdToString(message.id)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordOutput(message.content);
|
RecordOutput(message.content);
|
||||||
@ -374,7 +349,7 @@ void LanguageServerMain(const std::string& bin_name,
|
|||||||
MultiQueueWaiter* querydb_waiter,
|
MultiQueueWaiter* querydb_waiter,
|
||||||
MultiQueueWaiter* indexer_waiter,
|
MultiQueueWaiter* indexer_waiter,
|
||||||
MultiQueueWaiter* stdout_waiter) {
|
MultiQueueWaiter* stdout_waiter) {
|
||||||
std::unordered_map<IpcId, Timer> request_times;
|
std::unordered_map<MethodType, Timer> request_times;
|
||||||
|
|
||||||
LaunchStdinLoop(config, &request_times);
|
LaunchStdinLoop(config, &request_times);
|
||||||
|
|
||||||
|
@ -30,6 +30,6 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files,
|
|||||||
Out_TextDocumentPublishDiagnostics out;
|
Out_TextDocumentPublishDiagnostics out;
|
||||||
out.params.uri = lsDocumentUri::FromPath(path);
|
out.params.uri = lsDocumentUri::FromPath(path);
|
||||||
out.params.diagnostics = diagnostics;
|
out.params.diagnostics = diagnostics;
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out);
|
QueueManager::WriteStdout(kMethodType_TextDocumentPublishDiagnostics, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ struct ActiveThread {
|
|||||||
GetCurrentTimeInMilliseconds() + config_->progressReportFrequencyMs;
|
GetCurrentTimeInMilliseconds() + config_->progressReportFrequencyMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(kMethodType_Unknown, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config* config_;
|
Config* config_;
|
||||||
@ -400,7 +400,7 @@ void ParseFile(Config* config,
|
|||||||
out.id = request.id;
|
out.id = request.id;
|
||||||
out.error.code = lsErrorCodes::InternalError;
|
out.error.code = lsErrorCodes::InternalError;
|
||||||
out.error.message = "Failed to index " + path_to_index;
|
out.error.message = "Failed to index " + path_to_index;
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(kMethodType_Unknown, out);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
30
src/ipc.cc
30
src/ipc.cc
@ -1,30 +1,10 @@
|
|||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
|
||||||
#include <cassert>
|
const char* kMethodType_Unknown = "$unknown";
|
||||||
|
const char* kMethodType_Exit = "exit";
|
||||||
const char* IpcIdToString(IpcId id) {
|
const char* kMethodType_TextDocumentPublishDiagnostics = "textDocument/publishDiagnostics";
|
||||||
switch (id) {
|
const char* kMethodType_CqueryPublishInactiveRegions = "$cquery/publishInactiveRegions";
|
||||||
case IpcId::CancelRequest:
|
const char* kMethodType_CqueryPublishSemanticHighlighting = "$cquery/publishSemanticHighlighting";
|
||||||
return "$/cancelRequest";
|
|
||||||
case IpcId::Initialized:
|
|
||||||
return "initialized";
|
|
||||||
case IpcId::Exit:
|
|
||||||
return "exit";
|
|
||||||
|
|
||||||
#define CASE(name, method) \
|
|
||||||
case IpcId::name: \
|
|
||||||
return method;
|
|
||||||
#include "methods.inc"
|
|
||||||
#undef CASE
|
|
||||||
|
|
||||||
case IpcId::Unknown:
|
|
||||||
return "$unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
CQUERY_UNREACHABLE("missing IpcId string name");
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {}
|
|
||||||
|
|
||||||
BaseIpcMessage::~BaseIpcMessage() = default;
|
BaseIpcMessage::~BaseIpcMessage() = default;
|
||||||
|
|
||||||
|
40
src/ipc.h
40
src/ipc.h
@ -7,48 +7,26 @@
|
|||||||
|
|
||||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||||
|
|
||||||
enum class IpcId : int {
|
using MethodType = std::string;
|
||||||
// Language server specific requests.
|
|
||||||
CancelRequest = 0,
|
|
||||||
Initialized,
|
|
||||||
Exit,
|
|
||||||
|
|
||||||
#define CASE(x, _) x,
|
extern const char* kMethodType_Unknown;
|
||||||
#include "methods.inc"
|
extern const char* kMethodType_Exit;
|
||||||
#undef CASE
|
extern const char* kMethodType_TextDocumentPublishDiagnostics;
|
||||||
|
extern const char* kMethodType_CqueryPublishInactiveRegions;
|
||||||
// Internal implementation detail.
|
extern const char* kMethodType_CqueryPublishSemanticHighlighting;
|
||||||
Unknown,
|
|
||||||
};
|
|
||||||
MAKE_ENUM_HASHABLE(IpcId)
|
|
||||||
MAKE_REFLECT_TYPE_PROXY(IpcId)
|
|
||||||
const char* IpcIdToString(IpcId id);
|
|
||||||
|
|
||||||
struct BaseIpcMessage {
|
struct BaseIpcMessage {
|
||||||
const IpcId method_id;
|
|
||||||
BaseIpcMessage(IpcId method_id);
|
|
||||||
virtual ~BaseIpcMessage();
|
virtual ~BaseIpcMessage();
|
||||||
|
|
||||||
|
virtual MethodType GetMethodType() const = 0;
|
||||||
virtual lsRequestId GetRequestId();
|
virtual lsRequestId GetRequestId();
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T* As() {
|
|
||||||
assert(method_id == T::kIpcId);
|
|
||||||
return static_cast<T*>(this);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct RequestMessage : public BaseIpcMessage {
|
struct RequestMessage : public BaseIpcMessage {
|
||||||
// number | string, actually no null
|
// number or string, actually no null
|
||||||
lsRequestId id;
|
lsRequestId id;
|
||||||
RequestMessage() : BaseIpcMessage(T::kIpcId) {}
|
|
||||||
|
|
||||||
lsRequestId GetRequestId() override { return id; }
|
lsRequestId GetRequestId() override { return id; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// NotificationMessage does not have |id|.
|
// NotificationMessage does not have |id|.
|
||||||
template <typename T>
|
struct NotificationMessage : public BaseIpcMessage {};
|
||||||
struct NotificationMessage : public BaseIpcMessage {
|
|
||||||
NotificationMessage() : BaseIpcMessage(T::kIpcId) {}
|
|
||||||
};
|
|
||||||
|
11
src/lsp.h
11
src/lsp.h
@ -24,7 +24,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define REGISTER_IPC_MESSAGE(type) \
|
#define REGISTER_IN_MESSAGE(type) \
|
||||||
static MessageRegistryRegister<type> type##message_handler_instance_;
|
static MessageRegistryRegister<type> type##message_handler_instance_;
|
||||||
|
|
||||||
struct MessageRegistry {
|
struct MessageRegistry {
|
||||||
@ -44,7 +44,8 @@ struct MessageRegistry {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct MessageRegistryRegister {
|
struct MessageRegistryRegister {
|
||||||
MessageRegistryRegister() {
|
MessageRegistryRegister() {
|
||||||
std::string method_name = IpcIdToString(T::kIpcId);
|
T dummy;
|
||||||
|
std::string method_name = dummy.GetMethodType();
|
||||||
MessageRegistry::instance()->allocators[method_name] =
|
MessageRegistry::instance()->allocators[method_name] =
|
||||||
[](Reader& visitor, std::unique_ptr<BaseIpcMessage>* message) {
|
[](Reader& visitor, std::unique_ptr<BaseIpcMessage>* message) {
|
||||||
*message = std::make_unique<T>();
|
*message = std::make_unique<T>();
|
||||||
@ -334,12 +335,6 @@ struct lsFormattingOptions {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces);
|
MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces);
|
||||||
|
|
||||||
// Cancel an existing request.
|
|
||||||
struct Ipc_CancelRequest : public RequestMessage<Ipc_CancelRequest> {
|
|
||||||
static const IpcId kIpcId = IpcId::CancelRequest;
|
|
||||||
};
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CancelRequest, id);
|
|
||||||
|
|
||||||
// MarkedString can be used to render human readable text. It is either a
|
// MarkedString can be used to render human readable text. It is either a
|
||||||
// markdown string or a code-block that provides a language and a code snippet.
|
// markdown string or a code-block that provides a language and a code snippet.
|
||||||
// The language identifier is sematically equal to the optional language
|
// The language identifier is sematically equal to the optional language
|
||||||
|
@ -32,7 +32,7 @@ optional<Matcher> Matcher::Create(const std::string& search) {
|
|||||||
out.params.type = lsMessageType::Error;
|
out.params.type = lsMessageType::Error;
|
||||||
out.params.message = "cquery: Parsing EMCAScript regex \"" + search +
|
out.params.message = "cquery: Parsing EMCAScript regex \"" + search +
|
||||||
"\" failed; " + e.what();
|
"\" failed; " + e.what();
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(kMethodType_Unknown, out);
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ bool FindFileOrFail(QueryDatabase* db,
|
|||||||
out.error.code = lsErrorCodes::InternalError;
|
out.error.code = lsErrorCodes::InternalError;
|
||||||
out.error.message = "Unable to find file " + absolute_path;
|
out.error.message = "Unable to find file " + absolute_path;
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(kMethodType_Unknown, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -114,7 +114,7 @@ void EmitInactiveLines(WorkingFile* working_file,
|
|||||||
if (ls_skipped)
|
if (ls_skipped)
|
||||||
out.params.inactiveRegions.push_back(*ls_skipped);
|
out.params.inactiveRegions.push_back(*ls_skipped);
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryPublishInactiveRegions, out);
|
QueueManager::WriteStdout(kMethodType_CqueryPublishInactiveRegions, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitSemanticHighlighting(QueryDatabase* db,
|
void EmitSemanticHighlighting(QueryDatabase* db,
|
||||||
@ -277,7 +277,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
for (auto& entry : grouped_symbols)
|
for (auto& entry : grouped_symbols)
|
||||||
if (entry.second.ranges.size())
|
if (entry.second.ranges.size())
|
||||||
out.params.symbols.push_back(entry.second);
|
out.params.symbols.push_back(entry.second);
|
||||||
QueueManager::WriteStdout(IpcId::CqueryPublishSemanticHighlighting, out);
|
QueueManager::WriteStdout(kMethodType_CqueryPublishSemanticHighlighting, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldIgnoreFileForIndexing(const std::string& path) {
|
bool ShouldIgnoreFileForIndexing(const std::string& path) {
|
||||||
|
@ -86,7 +86,7 @@ struct MessageHandler {
|
|||||||
CodeCompleteCache* non_global_code_complete_cache = nullptr;
|
CodeCompleteCache* non_global_code_complete_cache = nullptr;
|
||||||
CodeCompleteCache* signature_cache = nullptr;
|
CodeCompleteCache* signature_cache = nullptr;
|
||||||
|
|
||||||
virtual IpcId GetId() const = 0;
|
virtual MethodType GetMethodType() const = 0;
|
||||||
virtual void Run(std::unique_ptr<BaseIpcMessage> message) = 0;
|
virtual void Run(std::unique_ptr<BaseIpcMessage> message) = 0;
|
||||||
|
|
||||||
static std::vector<MessageHandler*>* message_handlers;
|
static std::vector<MessageHandler*>* message_handlers;
|
||||||
@ -100,9 +100,8 @@ struct BaseMessageHandler : MessageHandler {
|
|||||||
virtual void Run(TMessage* message) = 0;
|
virtual void Run(TMessage* message) = 0;
|
||||||
|
|
||||||
// MessageHandler:
|
// MessageHandler:
|
||||||
IpcId GetId() const override { return TMessage::kIpcId; }
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||||
Run(message->As<TMessage>());
|
Run(static_cast<TMessage*>(message.get()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,15 +3,21 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryBase : public RequestMessage<Ipc_CqueryBase> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryBase;
|
MethodType kMethodType = "$cquery/base";
|
||||||
|
|
||||||
|
struct In_CqueryBase : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryBase, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryBase, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryBase);
|
REGISTER_IN_MESSAGE(In_CqueryBase);
|
||||||
|
|
||||||
struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
|
struct Handler_CqueryBase : BaseMessageHandler<In_CqueryBase> {
|
||||||
void Run(Ipc_CqueryBase* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_CqueryBase* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -39,8 +45,8 @@ struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryBase, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryBaseHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryBase);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
MethodType kMethodType = "$cquery/callHierarchy";
|
||||||
|
|
||||||
enum class CallType : uint8_t {
|
enum class CallType : uint8_t {
|
||||||
Direct = 0,
|
Direct = 0,
|
||||||
Base = 1,
|
Base = 1,
|
||||||
@ -17,9 +20,9 @@ bool operator&(CallType lhs, CallType rhs) {
|
|||||||
return uint8_t(lhs) & uint8_t(rhs);
|
return uint8_t(lhs) & uint8_t(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_CqueryCallHierarchy
|
struct In_CqueryCallHierarchy : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_CqueryCallHierarchy> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::CqueryCallHierarchy;
|
|
||||||
struct Params {
|
struct Params {
|
||||||
// If id is specified, expand a node; otherwise textDocument+position should
|
// If id is specified, expand a node; otherwise textDocument+position should
|
||||||
// be specified for building the root and |levels| of nodes below.
|
// be specified for building the root and |levels| of nodes below.
|
||||||
@ -38,8 +41,9 @@ struct Ipc_CqueryCallHierarchy
|
|||||||
int levels = 1;
|
int levels = 1;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
|
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params,
|
MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
id,
|
id,
|
||||||
@ -47,8 +51,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params,
|
|||||||
callType,
|
callType,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchy);
|
REGISTER_IN_MESSAGE(In_CqueryCallHierarchy);
|
||||||
|
|
||||||
struct Out_CqueryCallHierarchy : public lsOutMessage<Out_CqueryCallHierarchy> {
|
struct Out_CqueryCallHierarchy : public lsOutMessage<Out_CqueryCallHierarchy> {
|
||||||
struct Entry {
|
struct Entry {
|
||||||
@ -155,8 +159,10 @@ bool Expand(MessageHandler* m,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryCallHierarchyHandler
|
struct Handler_CqueryCallHierarchy
|
||||||
: BaseMessageHandler<Ipc_CqueryCallHierarchy> {
|
: BaseMessageHandler<In_CqueryCallHierarchy> {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
optional<Out_CqueryCallHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
optional<Out_CqueryCallHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
||||||
bool callee,
|
bool callee,
|
||||||
CallType call_type,
|
CallType call_type,
|
||||||
@ -178,7 +184,7 @@ struct CqueryCallHierarchyHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryCallHierarchy* request) override {
|
void Run(In_CqueryCallHierarchy* request) override {
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
Out_CqueryCallHierarchy out;
|
Out_CqueryCallHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
@ -209,9 +215,9 @@ struct CqueryCallHierarchyHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryCallHierarchy, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryCallHierarchyHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryCallHierarchy);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,15 +3,18 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryCallers : public RequestMessage<Ipc_CqueryCallers> {
|
MethodType kMethodType = "$cquery/callers";
|
||||||
const static IpcId kIpcId = IpcId::CqueryCallers;
|
|
||||||
|
struct In_CqueryCallers : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryCallers, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryCallers, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryCallers);
|
REGISTER_IN_MESSAGE(In_CqueryCallers);
|
||||||
|
|
||||||
struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
|
struct Handler_CqueryCallers : BaseMessageHandler<In_CqueryCallers> {
|
||||||
void Run(Ipc_CqueryCallers* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryCallers* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -38,8 +41,8 @@ struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryCallers, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryCallersHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryCallers);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,15 +3,18 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryDerived : public RequestMessage<Ipc_CqueryDerived> {
|
MethodType kMethodType = "$cquery/derived";
|
||||||
const static IpcId kIpcId = IpcId::CqueryDerived;
|
|
||||||
|
struct In_CqueryDerived : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryDerived, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryDerived, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryDerived);
|
REGISTER_IN_MESSAGE(In_CqueryDerived);
|
||||||
|
|
||||||
struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
struct Handler_CqueryDerived : BaseMessageHandler<In_CqueryDerived> {
|
||||||
void Run(Ipc_CqueryDerived* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryDerived* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -39,8 +42,8 @@ struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryDerived, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryDerivedHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryDerived);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,21 +3,23 @@
|
|||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryTextDocumentDidView
|
MethodType kMethodType = "$cquery/textDocumentDidView";
|
||||||
: public NotificationMessage<Ipc_CqueryTextDocumentDidView> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryTextDocumentDidView;
|
struct In_CqueryTextDocumentDidView : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
lsDocumentUri textDocumentUri;
|
lsDocumentUri textDocumentUri;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView::Params, textDocumentUri);
|
MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView::Params, textDocumentUri);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView, params);
|
MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryTextDocumentDidView);
|
REGISTER_IN_MESSAGE(In_CqueryTextDocumentDidView);
|
||||||
|
|
||||||
struct CqueryDidViewHandler
|
struct Handler_CqueryDidView
|
||||||
: BaseMessageHandler<Ipc_CqueryTextDocumentDidView> {
|
: BaseMessageHandler<In_CqueryTextDocumentDidView> {
|
||||||
void Run(Ipc_CqueryTextDocumentDidView* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryTextDocumentDidView* request) override {
|
||||||
std::string path = request->params.textDocumentUri.GetPath();
|
std::string path = request->params.textDocumentUri.GetPath();
|
||||||
|
|
||||||
WorkingFile* working_file = working_files->GetFileByFilename(path);
|
WorkingFile* working_file = working_files->GetFileByFilename(path);
|
||||||
@ -34,5 +36,5 @@ struct CqueryDidViewHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryDidViewHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryDidView);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,17 +3,19 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "$cquery/fileInfo";
|
||||||
|
|
||||||
struct lsDocumentSymbolParams {
|
struct lsDocumentSymbolParams {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
||||||
|
|
||||||
struct Ipc_CqueryFileInfo : public RequestMessage<Ipc_CqueryFileInfo> {
|
struct In_CqueryFileInfo : public RequestMessage {
|
||||||
const static IpcId kIpcId = IpcId::CqueryFileInfo;
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsDocumentSymbolParams params;
|
lsDocumentSymbolParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryFileInfo, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryFileInfo, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryFileInfo);
|
REGISTER_IN_MESSAGE(In_CqueryFileInfo);
|
||||||
|
|
||||||
struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
|
struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
|
||||||
lsRequestId id;
|
lsRequestId id;
|
||||||
@ -21,8 +23,9 @@ struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result);
|
||||||
|
|
||||||
struct CqueryFileInfoHandler : BaseMessageHandler<Ipc_CqueryFileInfo> {
|
struct Handler_CqueryFileInfo : BaseMessageHandler<In_CqueryFileInfo> {
|
||||||
void Run(Ipc_CqueryFileInfo* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryFileInfo* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -37,8 +40,8 @@ struct CqueryFileInfoHandler : BaseMessageHandler<Ipc_CqueryFileInfo> {
|
|||||||
out.result.language = file->def->language;
|
out.result.language = file->def->language;
|
||||||
out.result.includes = file->def->includes;
|
out.result.includes = file->def->includes;
|
||||||
out.result.inactive_regions = file->def->inactive_regions;
|
out.result.inactive_regions = file->def->inactive_regions;
|
||||||
QueueManager::WriteStdout(IpcId::CqueryFileInfo, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryFileInfoHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryFileInfo);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryFreshenIndex
|
MethodType kMethodType = "$cquery/freshenIndex";
|
||||||
: public NotificationMessage<Ipc_CqueryFreshenIndex> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryFreshenIndex;
|
struct In_CqueryFreshenIndex : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
bool dependencies = true;
|
bool dependencies = true;
|
||||||
std::vector<std::string> whitelist;
|
std::vector<std::string> whitelist;
|
||||||
@ -23,15 +24,16 @@ struct Ipc_CqueryFreshenIndex
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex::Params,
|
MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex::Params,
|
||||||
dependencies,
|
dependencies,
|
||||||
whitelist,
|
whitelist,
|
||||||
blacklist);
|
blacklist);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex, params);
|
MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryFreshenIndex);
|
REGISTER_IN_MESSAGE(In_CqueryFreshenIndex);
|
||||||
|
|
||||||
struct CqueryFreshenIndexHandler : BaseMessageHandler<Ipc_CqueryFreshenIndex> {
|
struct Handler_CqueryFreshenIndex : BaseMessageHandler<In_CqueryFreshenIndex> {
|
||||||
void Run(Ipc_CqueryFreshenIndex* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryFreshenIndex* request) override {
|
||||||
LOG_S(INFO) << "Freshening " << project->entries.size() << " files";
|
LOG_S(INFO) << "Freshening " << project->entries.size() << " files";
|
||||||
|
|
||||||
// TODO: think about this flow and test it more.
|
// TODO: think about this flow and test it more.
|
||||||
@ -90,5 +92,5 @@ struct CqueryFreshenIndexHandler : BaseMessageHandler<Ipc_CqueryFreshenIndex> {
|
|||||||
time.ResetAndPrint("[perf] Dispatched $cquery/freshenIndex index requests");
|
time.ResetAndPrint("[perf] Dispatched $cquery/freshenIndex index requests");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryFreshenIndexHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryFreshenIndex);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
#include <loguru/loguru.hpp>
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryIndexFile : public NotificationMessage<Ipc_CqueryIndexFile> {
|
MethodType kMethodType = "$cquery/indexFile";
|
||||||
static constexpr IpcId kIpcId = IpcId::CqueryIndexFile;
|
|
||||||
|
struct In_CqueryIndexFile : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
std::string path;
|
std::string path;
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
@ -16,16 +18,17 @@ struct Ipc_CqueryIndexFile : public NotificationMessage<Ipc_CqueryIndexFile> {
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile::Params,
|
MAKE_REFLECT_STRUCT(In_CqueryIndexFile::Params,
|
||||||
path,
|
path,
|
||||||
args,
|
args,
|
||||||
is_interactive,
|
is_interactive,
|
||||||
contents);
|
contents);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile, params);
|
MAKE_REFLECT_STRUCT(In_CqueryIndexFile, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryIndexFile);
|
REGISTER_IN_MESSAGE(In_CqueryIndexFile);
|
||||||
|
|
||||||
struct CqueryIndexFileHandler : BaseMessageHandler<Ipc_CqueryIndexFile> {
|
struct Handler_CqueryIndexFile : BaseMessageHandler<In_CqueryIndexFile> {
|
||||||
void Run(Ipc_CqueryIndexFile* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_CqueryIndexFile* request) override {
|
||||||
LOG_S(INFO) << "Indexing file " << request->params.path;
|
LOG_S(INFO) << "Indexing file " << request->params.path;
|
||||||
QueueManager::instance()->index_request.PushBack(
|
QueueManager::instance()->index_request.PushBack(
|
||||||
Index_Request(NormalizePath(request->params.path), request->params.args,
|
Index_Request(NormalizePath(request->params.path), request->params.args,
|
||||||
@ -33,5 +36,5 @@ struct CqueryIndexFileHandler : BaseMessageHandler<Ipc_CqueryIndexFile> {
|
|||||||
ICacheManager::Make(config)));
|
ICacheManager::Make(config)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryIndexFileHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryIndexFile);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryInheritanceHierarchy
|
MethodType kMethodType = "$cquery/inheritanceHierarchy";
|
||||||
: public RequestMessage<Ipc_CqueryInheritanceHierarchy> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy;
|
struct In_CqueryInheritanceHierarchy : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
// If id+kind are specified, expand a node; otherwise textDocument+position
|
// If id+kind are specified, expand a node; otherwise textDocument+position
|
||||||
// should be specified for building the root and |levels| of nodes below.
|
// should be specified for building the root and |levels| of nodes below.
|
||||||
@ -23,7 +24,7 @@ struct Ipc_CqueryInheritanceHierarchy
|
|||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params,
|
MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
id,
|
id,
|
||||||
@ -31,8 +32,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params,
|
|||||||
derived,
|
derived,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchy);
|
REGISTER_IN_MESSAGE(In_CqueryInheritanceHierarchy);
|
||||||
|
|
||||||
struct Out_CqueryInheritanceHierarchy
|
struct Out_CqueryInheritanceHierarchy
|
||||||
: public lsOutMessage<Out_CqueryInheritanceHierarchy> {
|
: public lsOutMessage<Out_CqueryInheritanceHierarchy> {
|
||||||
@ -127,8 +128,10 @@ bool Expand(MessageHandler* m,
|
|||||||
m->db->types[entry->id.id]);
|
m->db->types[entry->id.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryInheritanceHierarchyHandler
|
struct Handler_CqueryInheritanceHierarchy
|
||||||
: BaseMessageHandler<Ipc_CqueryInheritanceHierarchy> {
|
: BaseMessageHandler<In_CqueryInheritanceHierarchy> {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
optional<Out_CqueryInheritanceHierarchy::Entry>
|
optional<Out_CqueryInheritanceHierarchy::Entry>
|
||||||
BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) {
|
BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) {
|
||||||
Out_CqueryInheritanceHierarchy::Entry entry;
|
Out_CqueryInheritanceHierarchy::Entry entry;
|
||||||
@ -138,7 +141,7 @@ struct CqueryInheritanceHierarchyHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryInheritanceHierarchy* request) override {
|
void Run(In_CqueryInheritanceHierarchy* request) override {
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
Out_CqueryInheritanceHierarchy out;
|
Out_CqueryInheritanceHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
@ -171,9 +174,9 @@ struct CqueryInheritanceHierarchyHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryInheritanceHierarchy, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryInheritanceHierarchyHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryInheritanceHierarchy);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryMemberHierarchy
|
MethodType kMethodType = "$cquery/memberHierarchy";
|
||||||
: public RequestMessage<Ipc_CqueryMemberHierarchy> {
|
|
||||||
const static IpcId kIpcId = IpcId::CqueryMemberHierarchy;
|
struct In_CqueryMemberHierarchy : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
struct Params {
|
struct Params {
|
||||||
// If id is specified, expand a node; otherwise textDocument+position should
|
// If id is specified, expand a node; otherwise textDocument+position should
|
||||||
// be specified for building the root and |levels| of nodes below.
|
// be specified for building the root and |levels| of nodes below.
|
||||||
@ -20,14 +22,14 @@ struct Ipc_CqueryMemberHierarchy
|
|||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy::Params,
|
MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
id,
|
id,
|
||||||
detailedName,
|
detailedName,
|
||||||
levels);
|
levels);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchy);
|
REGISTER_IN_MESSAGE(In_CqueryMemberHierarchy);
|
||||||
|
|
||||||
struct Out_CqueryMemberHierarchy
|
struct Out_CqueryMemberHierarchy
|
||||||
: public lsOutMessage<Out_CqueryMemberHierarchy> {
|
: public lsOutMessage<Out_CqueryMemberHierarchy> {
|
||||||
@ -158,8 +160,10 @@ bool Expand(MessageHandler* m,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryMemberHierarchyHandler
|
struct Handler_CqueryMemberHierarchy
|
||||||
: BaseMessageHandler<Ipc_CqueryMemberHierarchy> {
|
: BaseMessageHandler<In_CqueryMemberHierarchy> {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
optional<Out_CqueryMemberHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
optional<Out_CqueryMemberHierarchy::Entry> BuildInitial(QueryFuncId root_id,
|
||||||
bool detailed_name,
|
bool detailed_name,
|
||||||
int levels) {
|
int levels) {
|
||||||
@ -202,7 +206,7 @@ struct CqueryMemberHierarchyHandler
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(Ipc_CqueryMemberHierarchy* request) override {
|
void Run(In_CqueryMemberHierarchy* request) override {
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
Out_CqueryMemberHierarchy out;
|
Out_CqueryMemberHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
@ -246,9 +250,9 @@ struct CqueryMemberHierarchyHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::CqueryMemberHierarchy, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryMemberHierarchyHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryMemberHierarchy);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryRandom : public RequestMessage<Ipc_CqueryRandom> {
|
MethodType kMethodType = "$cquery/random";
|
||||||
const static IpcId kIpcId = IpcId::CqueryRandom;
|
|
||||||
|
struct In_CqueryRandom : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryRandom, id);
|
MAKE_REFLECT_STRUCT(In_CqueryRandom, id);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryRandom);
|
REGISTER_IN_MESSAGE(In_CqueryRandom);
|
||||||
|
|
||||||
const double kDeclWeight = 3;
|
const double kDeclWeight = 3;
|
||||||
const double kDamping = 0.1;
|
const double kDamping = 0.1;
|
||||||
@ -44,8 +46,10 @@ void Add(const std::unordered_map<SymbolIdx, int>& sym2id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CqueryRandomHandler : BaseMessageHandler<Ipc_CqueryRandom> {
|
struct Handler_CqueryRandom : BaseMessageHandler<In_CqueryRandom> {
|
||||||
void Run(Ipc_CqueryRandom* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_CqueryRandom* request) override {
|
||||||
std::unordered_map<SymbolIdx, int> sym2id;
|
std::unordered_map<SymbolIdx, int> sym2id;
|
||||||
std::vector<SymbolIdx> syms;
|
std::vector<SymbolIdx> syms;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -137,8 +141,8 @@ struct CqueryRandomHandler : BaseMessageHandler<Ipc_CqueryRandom> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryRandom, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryRandomHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryRandom);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,15 +3,20 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryVars : public RequestMessage<Ipc_CqueryVars> {
|
MethodType kMethodType = "$cquery/vars";
|
||||||
const static IpcId kIpcId = IpcId::CqueryVars;
|
|
||||||
|
struct In_CqueryVars : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_CqueryVars, id, params);
|
MAKE_REFLECT_STRUCT(In_CqueryVars, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryVars);
|
REGISTER_IN_MESSAGE(In_CqueryVars);
|
||||||
|
|
||||||
struct CqueryVarsHandler : BaseMessageHandler<Ipc_CqueryVars> {
|
struct Handler_CqueryVars : BaseMessageHandler<In_CqueryVars> {
|
||||||
void Run(Ipc_CqueryVars* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_CqueryVars* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -45,8 +50,8 @@ struct CqueryVarsHandler : BaseMessageHandler<Ipc_CqueryVars> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QueueManager::WriteStdout(IpcId::CqueryVars, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryVarsHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryVars);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -6,14 +6,17 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_CqueryWait : public NotificationMessage<Ipc_CqueryWait> {
|
MethodType kMethodType = "$cquery/wait";
|
||||||
static constexpr IpcId kIpcId = IpcId::CqueryWait;
|
|
||||||
};
|
struct In_CqueryWait : public NotificationMessage {
|
||||||
MAKE_REFLECT_EMPTY_STRUCT(Ipc_CqueryWait);
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
REGISTER_IPC_MESSAGE(Ipc_CqueryWait);
|
};
|
||||||
|
MAKE_REFLECT_EMPTY_STRUCT(In_CqueryWait);
|
||||||
|
REGISTER_IN_MESSAGE(In_CqueryWait);
|
||||||
|
|
||||||
|
struct Handler_CqueryWait : MessageHandler {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
struct CqueryWaitHandler : MessageHandler {
|
|
||||||
IpcId GetId() const override { return IpcId::CqueryWait; }
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
||||||
// TODO: use status message system here, then run querydb as normal? Maybe
|
// TODO: use status message system here, then run querydb as normal? Maybe
|
||||||
// this cannot be a normal message, ie, it needs to be re-entrant.
|
// this cannot be a normal message, ie, it needs to be re-entrant.
|
||||||
@ -40,5 +43,5 @@ struct CqueryWaitHandler : MessageHandler {
|
|||||||
LOG_S(INFO) << "Done waiting for idle";
|
LOG_S(INFO) << "Done waiting for idle";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(CqueryWaitHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_CqueryWait);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_Exit : public NotificationMessage<Ipc_Exit> {
|
struct In_Exit : public NotificationMessage {
|
||||||
static const IpcId kIpcId = IpcId::Exit;
|
MethodType GetMethodType() const override { return kMethodType_Exit; }
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_EMPTY_STRUCT(Ipc_Exit);
|
MAKE_REFLECT_EMPTY_STRUCT(In_Exit);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_Exit);
|
REGISTER_IN_MESSAGE(In_Exit);
|
||||||
|
|
||||||
struct ExitHandler : MessageHandler {
|
struct Handler_Exit : MessageHandler {
|
||||||
IpcId GetId() const override { return IpcId::Exit; }
|
MethodType GetMethodType() const override { return kMethodType_Exit; }
|
||||||
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
||||||
LOG_S(INFO) << "Exiting; got IpcId::Exit";
|
LOG_S(INFO) << "Exiting; got exit message";
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(ExitHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_Exit);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -23,6 +23,8 @@ extern std::string g_init_options;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
MethodType kMethodType = "initialize";
|
||||||
|
|
||||||
// Code Lens options.
|
// Code Lens options.
|
||||||
struct lsCodeLensOptions {
|
struct lsCodeLensOptions {
|
||||||
// Code lens has a resolve provider as well.
|
// Code lens has a resolve provider as well.
|
||||||
@ -460,12 +462,13 @@ struct lsInitializeError {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsInitializeError, retry);
|
MAKE_REFLECT_STRUCT(lsInitializeError, retry);
|
||||||
|
|
||||||
struct Ipc_InitializeRequest : public RequestMessage<Ipc_InitializeRequest> {
|
struct In_InitializeRequest : public RequestMessage {
|
||||||
const static IpcId kIpcId = IpcId::Initialize;
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
lsInitializeParams params;
|
lsInitializeParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_InitializeRequest, id, params);
|
MAKE_REFLECT_STRUCT(In_InitializeRequest, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_InitializeRequest);
|
REGISTER_IN_MESSAGE(In_InitializeRequest);
|
||||||
|
|
||||||
struct Out_InitializeResponse : public lsOutMessage<Out_InitializeResponse> {
|
struct Out_InitializeResponse : public lsOutMessage<Out_InitializeResponse> {
|
||||||
struct InitializeResult {
|
struct InitializeResult {
|
||||||
@ -477,8 +480,10 @@ struct Out_InitializeResponse : public lsOutMessage<Out_InitializeResponse> {
|
|||||||
MAKE_REFLECT_STRUCT(Out_InitializeResponse::InitializeResult, capabilities);
|
MAKE_REFLECT_STRUCT(Out_InitializeResponse::InitializeResult, capabilities);
|
||||||
MAKE_REFLECT_STRUCT(Out_InitializeResponse, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_InitializeResponse, jsonrpc, id, result);
|
||||||
|
|
||||||
struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
struct Handler_Initialize : BaseMessageHandler<In_InitializeRequest> {
|
||||||
void Run(Ipc_InitializeRequest* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_InitializeRequest* request) override {
|
||||||
// Log initialization parameters.
|
// Log initialization parameters.
|
||||||
rapidjson::StringBuffer output;
|
rapidjson::StringBuffer output;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(output);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(output);
|
||||||
@ -573,7 +578,7 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
|||||||
out.result.capabilities.documentRangeFormattingProvider = true;
|
out.result.capabilities.documentRangeFormattingProvider = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::Initialize, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
|
|
||||||
// Set project root.
|
// Set project root.
|
||||||
EnsureEndsInSlash(project_path);
|
EnsureEndsInSlash(project_path);
|
||||||
@ -627,5 +632,5 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(InitializeHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_Initialize);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_Shutdown : public RequestMessage<Ipc_Shutdown> {
|
MethodType kMethodType = "shutdown";
|
||||||
static const IpcId kIpcId = IpcId::Shutdown;
|
|
||||||
|
struct In_Shutdown : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_Shutdown, id);
|
MAKE_REFLECT_STRUCT(In_Shutdown, id);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_Shutdown);
|
REGISTER_IN_MESSAGE(In_Shutdown);
|
||||||
|
|
||||||
struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {
|
struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {
|
||||||
lsRequestId id; // defaults to std::monostate (null)
|
lsRequestId id; // defaults to std::monostate (null)
|
||||||
@ -14,12 +16,13 @@ struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_Shutdown, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_Shutdown, jsonrpc, id, result);
|
||||||
|
|
||||||
struct ShutdownHandler : BaseMessageHandler<Ipc_Shutdown> {
|
struct Handler_Shutdown : BaseMessageHandler<In_Shutdown> {
|
||||||
void Run(Ipc_Shutdown* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_Shutdown* request) override {
|
||||||
Out_Shutdown out;
|
Out_Shutdown out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentDefinition, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(ShutdownHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_Shutdown);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/codeAction";
|
||||||
|
|
||||||
optional<int> FindIncludeLine(const std::vector<std::string>& lines,
|
optional<int> FindIncludeLine(const std::vector<std::string>& lines,
|
||||||
const std::string& full_include_line) {
|
const std::string& full_include_line) {
|
||||||
@ -256,9 +257,9 @@ optional<lsTextEdit> BuildAutoImplementForFunction(QueryDatabase* db,
|
|||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_TextDocumentCodeAction
|
struct In_TextDocumentCodeAction : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentCodeAction> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentCodeAction;
|
|
||||||
// Contains additional diagnostic information about the context in which
|
// Contains additional diagnostic information about the context in which
|
||||||
// a code action is run.
|
// a code action is run.
|
||||||
struct lsCodeActionContext {
|
struct lsCodeActionContext {
|
||||||
@ -276,14 +277,14 @@ struct Ipc_TextDocumentCodeAction
|
|||||||
};
|
};
|
||||||
lsCodeActionParams params;
|
lsCodeActionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionContext,
|
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionContext,
|
||||||
diagnostics);
|
diagnostics);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionParams,
|
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionParams,
|
||||||
textDocument,
|
textDocument,
|
||||||
range,
|
range,
|
||||||
context);
|
context);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeAction);
|
REGISTER_IN_MESSAGE(In_TextDocumentCodeAction);
|
||||||
|
|
||||||
struct Out_TextDocumentCodeAction
|
struct Out_TextDocumentCodeAction
|
||||||
: public lsOutMessage<Out_TextDocumentCodeAction> {
|
: public lsOutMessage<Out_TextDocumentCodeAction> {
|
||||||
@ -294,9 +295,11 @@ struct Out_TextDocumentCodeAction
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentCodeAction, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentCodeAction, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentCodeActionHandler
|
struct Handler_TextDocumentCodeAction
|
||||||
: BaseMessageHandler<Ipc_TextDocumentCodeAction> {
|
: BaseMessageHandler<In_TextDocumentCodeAction> {
|
||||||
void Run(Ipc_TextDocumentCodeAction* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentCodeAction* request) override {
|
||||||
// NOTE: This code snippet will generate some FixIts for testing:
|
// NOTE: This code snippet will generate some FixIts for testing:
|
||||||
//
|
//
|
||||||
// struct origin { int x, int y };
|
// struct origin { int x, int y };
|
||||||
@ -534,10 +537,10 @@ struct TextDocumentCodeActionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentCodeAction, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentCodeActionHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCodeAction);
|
||||||
|
|
||||||
TEST_SUITE("FindIncludeLine") {
|
TEST_SUITE("FindIncludeLine") {
|
||||||
TEST_CASE("in document") {
|
TEST_CASE("in document") {
|
||||||
|
@ -5,19 +5,20 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/codeLens";
|
||||||
|
|
||||||
struct lsDocumentCodeLensParams {
|
struct lsDocumentCodeLensParams {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument);
|
MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument);
|
||||||
|
|
||||||
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
|
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
|
||||||
struct Ipc_TextDocumentCodeLens
|
struct In_TextDocumentCodeLens : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentCodeLens> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentCodeLens;
|
|
||||||
lsDocumentCodeLensParams params;
|
lsDocumentCodeLensParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentCodeLens, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeLens);
|
REGISTER_IN_MESSAGE(In_TextDocumentCodeLens);
|
||||||
|
|
||||||
struct Out_TextDocumentCodeLens
|
struct Out_TextDocumentCodeLens
|
||||||
: public lsOutMessage<Out_TextDocumentCodeLens> {
|
: public lsOutMessage<Out_TextDocumentCodeLens> {
|
||||||
@ -81,9 +82,10 @@ void AddCodeLens(const char* singular,
|
|||||||
common->result->push_back(code_lens);
|
common->result->push_back(code_lens);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextDocumentCodeLensHandler
|
struct Handler_TextDocumentCodeLens
|
||||||
: BaseMessageHandler<Ipc_TextDocumentCodeLens> {
|
: BaseMessageHandler<In_TextDocumentCodeLens> {
|
||||||
void Run(Ipc_TextDocumentCodeLens* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentCodeLens* request) override {
|
||||||
Out_TextDocumentCodeLens out;
|
Out_TextDocumentCodeLens out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
@ -225,8 +227,8 @@ struct TextDocumentCodeLensHandler
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentCodeLens, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentCodeLensHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCodeLens);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/completion";
|
||||||
|
|
||||||
// How a completion was triggered
|
// How a completion was triggered
|
||||||
enum class lsCompletionTriggerKind {
|
enum class lsCompletionTriggerKind {
|
||||||
@ -47,13 +48,12 @@ struct lsCompletionParams : lsTextDocumentPositionParams {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context);
|
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context);
|
||||||
|
|
||||||
struct Ipc_TextDocumentComplete
|
struct In_TextDocumentComplete : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentComplete> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentCompletion;
|
|
||||||
lsCompletionParams params;
|
lsCompletionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentComplete, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentComplete, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentComplete);
|
REGISTER_IN_MESSAGE(In_TextDocumentComplete);
|
||||||
|
|
||||||
struct lsTextDocumentCompleteResult {
|
struct lsTextDocumentCompleteResult {
|
||||||
// This list it not complete. Further typing should result in recomputing
|
// This list it not complete. Further typing should result in recomputing
|
||||||
@ -216,17 +216,17 @@ void FilterAndSortCompletionResponse(
|
|||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextDocumentCompletionHandler : MessageHandler {
|
struct Handler_TextDocumentCompletion : MessageHandler {
|
||||||
IpcId GetId() const override { return IpcId::TextDocumentCompletion; }
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||||
auto request = std::shared_ptr<Ipc_TextDocumentComplete>(
|
auto request = std::shared_ptr<In_TextDocumentComplete>(
|
||||||
static_cast<Ipc_TextDocumentComplete*>(message.release()));
|
static_cast<In_TextDocumentComplete*>(message.release()));
|
||||||
|
|
||||||
auto write_empty_result = [request]() {
|
auto write_empty_result = [request]() {
|
||||||
Out_TextDocumentComplete out;
|
Out_TextDocumentComplete out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string path = request->params.textDocument.uri.GetPath();
|
std::string path = request->params.textDocument.uri.GetPath();
|
||||||
@ -324,7 +324,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
|||||||
item.textEdit->range.end.character = (int)buffer_line.size();
|
item.textEdit->range.end.character = (int)buffer_line.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
} else {
|
} else {
|
||||||
ClangCompleteManager::OnComplete callback = std::bind(
|
ClangCompleteManager::OnComplete callback = std::bind(
|
||||||
[this, is_global_completion, existing_completion, request](
|
[this, is_global_completion, existing_completion, request](
|
||||||
@ -337,7 +337,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
|||||||
// Emit completion results.
|
// Emit completion results.
|
||||||
FilterAndSortCompletionResponse(&out, existing_completion,
|
FilterAndSortCompletionResponse(&out, existing_completion,
|
||||||
config->completion.filterAndSort);
|
config->completion.filterAndSort);
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
|
|
||||||
// Cache completion results.
|
// Cache completion results.
|
||||||
if (!is_cached_result) {
|
if (!is_cached_result) {
|
||||||
@ -395,6 +395,6 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentCompletionHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCompletion);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/definition";
|
||||||
|
|
||||||
struct Ipc_TextDocumentDefinition
|
struct In_TextDocumentDefinition : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentDefinition> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDefinition;
|
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDefinition, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDefinition, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition);
|
REGISTER_IN_MESSAGE(In_TextDocumentDefinition);
|
||||||
|
|
||||||
struct Out_TextDocumentDefinition
|
struct Out_TextDocumentDefinition
|
||||||
: public lsOutMessage<Out_TextDocumentDefinition> {
|
: public lsOutMessage<Out_TextDocumentDefinition> {
|
||||||
@ -46,9 +46,10 @@ std::vector<Use> GetNonDefDeclarationTargets(QueryDatabase* db, SymbolRef sym) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextDocumentDefinitionHandler
|
struct Handler_TextDocumentDefinition
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDefinition> {
|
: BaseMessageHandler<In_TextDocumentDefinition> {
|
||||||
void Run(Ipc_TextDocumentDefinition* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentDefinition* request) override {
|
||||||
QueryFileId file_id;
|
QueryFileId file_id;
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
@ -165,8 +166,8 @@ struct TextDocumentDefinitionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentDefinition, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDefinitionHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDefinition);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -8,18 +8,21 @@
|
|||||||
#include <loguru/loguru.hpp>
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentDidChange
|
MethodType kMethodType = "textDocument/didChange";
|
||||||
: public NotificationMessage<Ipc_TextDocumentDidChange> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDidChange;
|
struct In_TextDocumentDidChange : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentDidChangeParams params;
|
lsTextDocumentDidChangeParams params;
|
||||||
};
|
};
|
||||||
|
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidChange, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidChange, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidChange);
|
REGISTER_IN_MESSAGE(In_TextDocumentDidChange);
|
||||||
|
|
||||||
struct TextDocumentDidChangeHandler
|
struct Handler_TextDocumentDidChange
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDidChange> {
|
: BaseMessageHandler<In_TextDocumentDidChange> {
|
||||||
void Run(Ipc_TextDocumentDidChange* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentDidChange* request) override {
|
||||||
std::string path = request->params.textDocument.uri.GetPath();
|
std::string path = request->params.textDocument.uri.GetPath();
|
||||||
working_files->OnChange(request->params);
|
working_files->OnChange(request->params);
|
||||||
if (config->enableIndexOnDidChange) {
|
if (config->enableIndexOnDidChange) {
|
||||||
@ -40,5 +43,5 @@ struct TextDocumentDidChangeHandler
|
|||||||
request->params.textDocument.AsTextDocumentIdentifier());
|
request->params.textDocument.AsTextDocumentIdentifier());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidChangeHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidChange);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -4,32 +4,35 @@
|
|||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentDidClose
|
MethodType kMethodType = "textDocument/didClose";
|
||||||
: public NotificationMessage<Ipc_TextDocumentDidClose> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDidClose;
|
struct In_TextDocumentDidClose : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose::Params, textDocument);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose::Params, textDocument);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidClose);
|
REGISTER_IN_MESSAGE(In_TextDocumentDidClose);
|
||||||
|
|
||||||
struct TextDocumentDidCloseHandler
|
struct Handler_TextDocumentDidClose
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDidClose> {
|
: BaseMessageHandler<In_TextDocumentDidClose> {
|
||||||
void Run(Ipc_TextDocumentDidClose* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentDidClose* request) override {
|
||||||
std::string path = request->params.textDocument.uri.GetPath();
|
std::string path = request->params.textDocument.uri.GetPath();
|
||||||
|
|
||||||
// Clear any diagnostics for the file.
|
// Clear any diagnostics for the file.
|
||||||
Out_TextDocumentPublishDiagnostics out;
|
Out_TextDocumentPublishDiagnostics out;
|
||||||
out.params.uri = request->params.textDocument.uri;
|
out.params.uri = request->params.textDocument.uri;
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
|
|
||||||
// Remove internal state.
|
// Remove internal state.
|
||||||
working_files->OnClose(request->params.textDocument);
|
working_files->OnClose(request->params.textDocument);
|
||||||
clang_complete->NotifyClose(path);
|
clang_complete->NotifyClose(path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidCloseHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidClose);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/didOpen";
|
||||||
|
|
||||||
// Open, view, change, close file
|
// Open, view, change, close file
|
||||||
struct Ipc_TextDocumentDidOpen
|
struct In_TextDocumentDidOpen : public NotificationMessage {
|
||||||
: public NotificationMessage<Ipc_TextDocumentDidOpen> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDidOpen;
|
|
||||||
struct Params {
|
struct Params {
|
||||||
lsTextDocumentItem textDocument;
|
lsTextDocumentItem textDocument;
|
||||||
|
|
||||||
@ -24,13 +26,15 @@ struct Ipc_TextDocumentDidOpen
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument, args);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen::Params, textDocument, args);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidOpen);
|
REGISTER_IN_MESSAGE(In_TextDocumentDidOpen);
|
||||||
|
|
||||||
struct TextDocumentDidOpenHandler
|
struct Handler_TextDocumentDidOpen
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDidOpen> {
|
: BaseMessageHandler<In_TextDocumentDidOpen> {
|
||||||
void Run(Ipc_TextDocumentDidOpen* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentDidOpen* request) override {
|
||||||
// NOTE: This function blocks code lens. If it starts taking a long time
|
// NOTE: This function blocks code lens. If it starts taking a long time
|
||||||
// we will need to find a way to unblock the code lens request.
|
// we will need to find a way to unblock the code lens request.
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
@ -75,5 +79,5 @@ struct TextDocumentDidOpenHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidOpenHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidOpen);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
#include <loguru/loguru.hpp>
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentDidSave
|
MethodType kMethodType = "textDocument/didSave";
|
||||||
: public NotificationMessage<Ipc_TextDocumentDidSave> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDidSave;
|
struct In_TextDocumentDidSave : public NotificationMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
struct Params {
|
struct Params {
|
||||||
// The document that was saved.
|
// The document that was saved.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
@ -20,13 +22,15 @@ struct Ipc_TextDocumentDidSave
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave::Params, textDocument);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidSave::Params, textDocument);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDidSave, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidSave);
|
REGISTER_IN_MESSAGE(In_TextDocumentDidSave);
|
||||||
|
|
||||||
struct TextDocumentDidSaveHandler
|
struct Handler_TextDocumentDidSave
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDidSave> {
|
: BaseMessageHandler<In_TextDocumentDidSave> {
|
||||||
void Run(Ipc_TextDocumentDidSave* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentDidSave* request) override {
|
||||||
std::string path = request->params.textDocument.uri.GetPath();
|
std::string path = request->params.textDocument.uri.GetPath();
|
||||||
if (ShouldIgnoreFileForIndexing(path))
|
if (ShouldIgnoreFileForIndexing(path))
|
||||||
return;
|
return;
|
||||||
@ -61,5 +65,5 @@ struct TextDocumentDidSaveHandler
|
|||||||
clang_complete->NotifySave(path);
|
clang_complete->NotifySave(path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDidSaveHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentDocumentHighlight
|
MethodType kMethodType = "textDocument/documentHighlight";
|
||||||
: public RequestMessage<Ipc_TextDocumentDocumentHighlight> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDocumentHighlight;
|
struct In_TextDocumentDocumentHighlight : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentHighlight, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentHighlight, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentHighlight);
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentHighlight);
|
||||||
|
|
||||||
struct Out_TextDocumentDocumentHighlight
|
struct Out_TextDocumentDocumentHighlight
|
||||||
: public lsOutMessage<Out_TextDocumentDocumentHighlight> {
|
: public lsOutMessage<Out_TextDocumentDocumentHighlight> {
|
||||||
@ -19,9 +20,10 @@ struct Out_TextDocumentDocumentHighlight
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentDocumentHighlightHandler
|
struct Handler_TextDocumentDocumentHighlight
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDocumentHighlight> {
|
: BaseMessageHandler<In_TextDocumentDocumentHighlight> {
|
||||||
void Run(Ipc_TextDocumentDocumentHighlight* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentDocumentHighlight* request) override {
|
||||||
QueryFileId file_id;
|
QueryFileId file_id;
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
@ -59,8 +61,8 @@ struct TextDocumentDocumentHighlightHandler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentDocumentHighlight, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentHighlightHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentHighlight);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -6,18 +6,19 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentDocumentLink
|
MethodType kMethodType = "textDocument/documentLink";
|
||||||
: public RequestMessage<Ipc_TextDocumentDocumentLink> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDocumentLink;
|
struct In_TextDocumentDocumentLink : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
// The document to provide document links for.
|
// The document to provide document links for.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::Params, textDocument);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink::Params, textDocument);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentLink);
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentLink);
|
||||||
|
|
||||||
// A document link is a range in a text document that links to an internal or
|
// A document link is a range in a text document that links to an internal or
|
||||||
// external resource, like another text document or a web site.
|
// external resource, like another text document or a web site.
|
||||||
@ -36,9 +37,10 @@ struct Out_TextDocumentDocumentLink
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentDocumentLinkHandler
|
struct Handler_TextDocumentDocumentLink
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDocumentLink> {
|
: BaseMessageHandler<In_TextDocumentDocumentLink> {
|
||||||
void Run(Ipc_TextDocumentDocumentLink* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentDocumentLink* request) override {
|
||||||
Out_TextDocumentDocumentLink out;
|
Out_TextDocumentDocumentLink out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
@ -76,8 +78,8 @@ struct TextDocumentDocumentLinkHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentDocumentLink, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentLinkHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentLink);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,18 +3,19 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/documentSymbol";
|
||||||
|
|
||||||
struct lsDocumentSymbolParams {
|
struct lsDocumentSymbolParams {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
||||||
|
|
||||||
struct Ipc_TextDocumentDocumentSymbol
|
struct In_TextDocumentDocumentSymbol : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentDocumentSymbol> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol;
|
|
||||||
lsDocumentSymbolParams params;
|
lsDocumentSymbolParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol);
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol);
|
||||||
|
|
||||||
struct Out_TextDocumentDocumentSymbol
|
struct Out_TextDocumentDocumentSymbol
|
||||||
: public lsOutMessage<Out_TextDocumentDocumentSymbol> {
|
: public lsOutMessage<Out_TextDocumentDocumentSymbol> {
|
||||||
@ -23,9 +24,10 @@ struct Out_TextDocumentDocumentSymbol
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentDocumentSymbolHandler
|
struct Handler_TextDocumentDocumentSymbol
|
||||||
: BaseMessageHandler<Ipc_TextDocumentDocumentSymbol> {
|
: BaseMessageHandler<In_TextDocumentDocumentSymbol> {
|
||||||
void Run(Ipc_TextDocumentDocumentSymbol* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentDocumentSymbol* request) override {
|
||||||
Out_TextDocumentDocumentSymbol out;
|
Out_TextDocumentDocumentSymbol out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
@ -62,8 +64,8 @@ struct TextDocumentDocumentSymbolHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentDocumentSymbol, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentSymbolHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentSymbol);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -6,19 +6,19 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/formatting";
|
||||||
|
|
||||||
struct Ipc_TextDocumentFormatting
|
struct In_TextDocumentFormatting : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentFormatting> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
|
|
||||||
struct Params {
|
struct Params {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsFormattingOptions options;
|
lsFormattingOptions options;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting::Params, textDocument, options);
|
MAKE_REFLECT_STRUCT(In_TextDocumentFormatting::Params, textDocument, options);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentFormatting, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting);
|
REGISTER_IN_MESSAGE(In_TextDocumentFormatting);
|
||||||
|
|
||||||
struct Out_TextDocumentFormatting
|
struct Out_TextDocumentFormatting
|
||||||
: public lsOutMessage<Out_TextDocumentFormatting> {
|
: public lsOutMessage<Out_TextDocumentFormatting> {
|
||||||
@ -27,9 +27,10 @@ struct Out_TextDocumentFormatting
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentFormattingHandler
|
struct Handler_TextDocumentFormatting
|
||||||
: BaseMessageHandler<Ipc_TextDocumentFormatting> {
|
: BaseMessageHandler<In_TextDocumentFormatting> {
|
||||||
void Run(Ipc_TextDocumentFormatting* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentFormatting* request) override {
|
||||||
Out_TextDocumentFormatting response;
|
Out_TextDocumentFormatting response;
|
||||||
response.id = request->id;
|
response.id = request->id;
|
||||||
#if USE_CLANG_CXX
|
#if USE_CLANG_CXX
|
||||||
@ -54,8 +55,8 @@ struct TextDocumentFormattingHandler
|
|||||||
response.result = {};
|
response.result = {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentFormatting, response);
|
QueueManager::WriteStdout(kMethodType, response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentFormattingHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentFormatting);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/hover";
|
||||||
|
|
||||||
std::pair<std::string_view, std::string_view> GetCommentsAndHover(
|
std::pair<std::string_view, std::string_view> GetCommentsAndHover(
|
||||||
QueryDatabase* db,
|
QueryDatabase* db,
|
||||||
@ -41,12 +42,12 @@ std::pair<std::string_view, std::string_view> GetCommentsAndHover(
|
|||||||
return {"", ""};
|
return {"", ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_TextDocumentHover : public RequestMessage<Ipc_TextDocumentHover> {
|
struct In_TextDocumentHover : public RequestMessage {
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentHover;
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentHover, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentHover);
|
REGISTER_IN_MESSAGE(In_TextDocumentHover);
|
||||||
|
|
||||||
struct Out_TextDocumentHover : public lsOutMessage<Out_TextDocumentHover> {
|
struct Out_TextDocumentHover : public lsOutMessage<Out_TextDocumentHover> {
|
||||||
struct Result {
|
struct Result {
|
||||||
@ -73,8 +74,9 @@ void Reflect(Writer& visitor, Out_TextDocumentHover& value) {
|
|||||||
REFLECT_MEMBER_END();
|
REFLECT_MEMBER_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextDocumentHoverHandler : BaseMessageHandler<Ipc_TextDocumentHover> {
|
struct Handler_TextDocumentHover : BaseMessageHandler<In_TextDocumentHover> {
|
||||||
void Run(Ipc_TextDocumentHover* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentHover* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -111,8 +113,8 @@ struct TextDocumentHoverHandler : BaseMessageHandler<Ipc_TextDocumentHover> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentHover, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentHoverHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentHover);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/rangeFormatting";
|
||||||
|
|
||||||
struct lsTextDocumentRangeFormattingParams {
|
struct lsTextDocumentRangeFormattingParams {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
@ -18,13 +19,12 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
|
|||||||
range,
|
range,
|
||||||
options);
|
options);
|
||||||
|
|
||||||
struct Ipc_TextDocumentRangeFormatting
|
struct In_TextDocumentRangeFormatting : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentRangeFormatting> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
|
|
||||||
lsTextDocumentRangeFormattingParams params;
|
lsTextDocumentRangeFormattingParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentRangeFormatting, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting);
|
REGISTER_IN_MESSAGE(In_TextDocumentRangeFormatting);
|
||||||
|
|
||||||
struct Out_TextDocumentRangeFormatting
|
struct Out_TextDocumentRangeFormatting
|
||||||
: public lsOutMessage<Out_TextDocumentRangeFormatting> {
|
: public lsOutMessage<Out_TextDocumentRangeFormatting> {
|
||||||
@ -33,9 +33,11 @@ struct Out_TextDocumentRangeFormatting
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentRangeFormatting, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentRangeFormatting, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentRangeFormattingHandler
|
struct Handler_TextDocumentRangeFormatting
|
||||||
: BaseMessageHandler<Ipc_TextDocumentRangeFormatting> {
|
: BaseMessageHandler<In_TextDocumentRangeFormatting> {
|
||||||
void Run(Ipc_TextDocumentRangeFormatting* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentRangeFormatting* request) override {
|
||||||
Out_TextDocumentRangeFormatting response;
|
Out_TextDocumentRangeFormatting response;
|
||||||
response.id = request->id;
|
response.id = request->id;
|
||||||
#if USE_CLANG_CXX
|
#if USE_CLANG_CXX
|
||||||
@ -62,8 +64,8 @@ struct TextDocumentRangeFormattingHandler
|
|||||||
response.result = {};
|
response.result = {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentRangeFormatting, response);
|
QueueManager::WriteStdout(kMethodType, response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentRangeFormattingHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRangeFormatting);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentReferences
|
MethodType kMethodType = "textDocument/references";
|
||||||
: public RequestMessage<Ipc_TextDocumentReferences> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentReferences;
|
struct In_TextDocumentReferences : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct lsReferenceContext {
|
struct lsReferenceContext {
|
||||||
// Include the declaration of the current symbol.
|
// Include the declaration of the current symbol.
|
||||||
bool includeDeclaration;
|
bool includeDeclaration;
|
||||||
@ -22,15 +23,15 @@ struct Ipc_TextDocumentReferences
|
|||||||
|
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext,
|
MAKE_REFLECT_STRUCT(In_TextDocumentReferences::lsReferenceContext,
|
||||||
includeDeclaration,
|
includeDeclaration,
|
||||||
role);
|
role);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::Params,
|
MAKE_REFLECT_STRUCT(In_TextDocumentReferences::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
context);
|
context);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentReferences, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentReferences);
|
REGISTER_IN_MESSAGE(In_TextDocumentReferences);
|
||||||
|
|
||||||
struct Out_TextDocumentReferences
|
struct Out_TextDocumentReferences
|
||||||
: public lsOutMessage<Out_TextDocumentReferences> {
|
: public lsOutMessage<Out_TextDocumentReferences> {
|
||||||
@ -39,9 +40,11 @@ struct Out_TextDocumentReferences
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentReferencesHandler
|
struct Handler_TextDocumentReferences
|
||||||
: BaseMessageHandler<Ipc_TextDocumentReferences> {
|
: BaseMessageHandler<In_TextDocumentReferences> {
|
||||||
void Run(Ipc_TextDocumentReferences* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
|
void Run(In_TextDocumentReferences* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file)) {
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
@ -93,8 +96,8 @@ struct TextDocumentReferencesHandler
|
|||||||
|
|
||||||
if ((int)out.result.size() >= config->xref.maxNum)
|
if ((int)out.result.size() >= config->xref.maxNum)
|
||||||
out.result.resize(config->xref.maxNum);
|
out.result.resize(config->xref.maxNum);
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentReferences, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentReferencesHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentReferences);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/rename";
|
||||||
|
|
||||||
lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
|
lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
|
||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
@ -47,8 +48,8 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
|
|||||||
return edit;
|
return edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_TextDocumentRename : public RequestMessage<Ipc_TextDocumentRename> {
|
struct In_TextDocumentRename : public RequestMessage {
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentRename;
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
// The document to format.
|
// The document to format.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
@ -63,12 +64,12 @@ struct Ipc_TextDocumentRename : public RequestMessage<Ipc_TextDocumentRename> {
|
|||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename::Params,
|
MAKE_REFLECT_STRUCT(In_TextDocumentRename::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
newName);
|
newName);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentRename, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRename);
|
REGISTER_IN_MESSAGE(In_TextDocumentRename);
|
||||||
|
|
||||||
struct Out_TextDocumentRename : public lsOutMessage<Out_TextDocumentRename> {
|
struct Out_TextDocumentRename : public lsOutMessage<Out_TextDocumentRename> {
|
||||||
lsRequestId id;
|
lsRequestId id;
|
||||||
@ -76,8 +77,9 @@ struct Out_TextDocumentRename : public lsOutMessage<Out_TextDocumentRename> {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentRename, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentRename, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
|
struct Handler_TextDocumentRename : BaseMessageHandler<In_TextDocumentRename> {
|
||||||
void Run(Ipc_TextDocumentRename* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentRename* request) override {
|
||||||
QueryFileId file_id;
|
QueryFileId file_id;
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
@ -100,8 +102,8 @@ struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentRename, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentRenameHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRename);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentSignatureHelp
|
MethodType kMethodType = "textDocument/signatureHelp";
|
||||||
: public RequestMessage<Ipc_TextDocumentSignatureHelp> {
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentSignatureHelp;
|
struct In_TextDocumentSignatureHelp : public RequestMessage {
|
||||||
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentSignatureHelp, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentSignatureHelp, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentSignatureHelp);
|
REGISTER_IN_MESSAGE(In_TextDocumentSignatureHelp);
|
||||||
|
|
||||||
// Represents a parameter of a callable-signature. A parameter can
|
// Represents a parameter of a callable-signature. A parameter can
|
||||||
// have a label and a doc-comment.
|
// have a label and a doc-comment.
|
||||||
@ -82,11 +83,11 @@ struct Out_TextDocumentSignatureHelp
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentSignatureHelp, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentSignatureHelp, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentSignatureHelpHandler : MessageHandler {
|
struct Handler_TextDocumentSignatureHelp : MessageHandler {
|
||||||
IpcId GetId() const override { return IpcId::TextDocumentSignatureHelp; }
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
|
||||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||||
auto request = message->As<Ipc_TextDocumentSignatureHelp>();
|
auto request = static_cast<In_TextDocumentSignatureHelp*>(message.get());
|
||||||
lsTextDocumentPositionParams& params = request->params;
|
lsTextDocumentPositionParams& params = request->params;
|
||||||
WorkingFile* file =
|
WorkingFile* file =
|
||||||
working_files->GetFileByFilename(params.textDocument.uri.GetPath());
|
working_files->GetFileByFilename(params.textDocument.uri.GetPath());
|
||||||
@ -105,7 +106,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
|
|||||||
[this](BaseIpcMessage* message, std::string search, int active_param,
|
[this](BaseIpcMessage* message, std::string search, int active_param,
|
||||||
const std::vector<lsCompletionItem>& results,
|
const std::vector<lsCompletionItem>& results,
|
||||||
bool is_cached_result) {
|
bool is_cached_result) {
|
||||||
auto msg = message->As<Ipc_TextDocumentSignatureHelp>();
|
auto msg = static_cast<In_TextDocumentSignatureHelp*>(message);
|
||||||
|
|
||||||
Out_TextDocumentSignatureHelp out;
|
Out_TextDocumentSignatureHelp out;
|
||||||
out.id = msg->id;
|
out.id = msg->id;
|
||||||
@ -142,7 +143,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
|
|||||||
out.result.activeParameter = active_param;
|
out.result.activeParameter = active_param;
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentSignatureHelp, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
|
|
||||||
if (!is_cached_result) {
|
if (!is_cached_result) {
|
||||||
signature_cache->WithLock([&]() {
|
signature_cache->WithLock([&]() {
|
||||||
@ -168,5 +169,5 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentSignatureHelpHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentSignatureHelp);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "textDocument/typeDefinition";
|
||||||
|
|
||||||
struct Ipc_TextDocumentTypeDefinition
|
struct In_TextDocumentTypeDefinition : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_TextDocumentTypeDefinition> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentTypeDefinition;
|
|
||||||
lsTextDocumentPositionParams params;
|
lsTextDocumentPositionParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentTypeDefinition, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentTypeDefinition, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentTypeDefinition);
|
REGISTER_IN_MESSAGE(In_TextDocumentTypeDefinition);
|
||||||
|
|
||||||
struct Out_TextDocumentTypeDefinition
|
struct Out_TextDocumentTypeDefinition
|
||||||
: public lsOutMessage<Out_TextDocumentTypeDefinition> {
|
: public lsOutMessage<Out_TextDocumentTypeDefinition> {
|
||||||
@ -19,9 +19,10 @@ struct Out_TextDocumentTypeDefinition
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result);
|
||||||
|
|
||||||
struct TextDocumentTypeDefinitionHandler
|
struct Handler_TextDocumentTypeDefinition
|
||||||
: BaseMessageHandler<Ipc_TextDocumentTypeDefinition> {
|
: BaseMessageHandler<In_TextDocumentTypeDefinition> {
|
||||||
void Run(Ipc_TextDocumentTypeDefinition* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_TextDocumentTypeDefinition* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file,
|
request->params.textDocument.uri.GetPath(), &file,
|
||||||
@ -59,9 +60,9 @@ struct TextDocumentTypeDefinitionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentTypeDefinition);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -9,22 +9,24 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "workspace/didChangeConfiguration";
|
||||||
|
|
||||||
struct lsDidChangeConfigurationParams {
|
struct lsDidChangeConfigurationParams {
|
||||||
bool placeholder;
|
bool placeholder;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder);
|
MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder);
|
||||||
|
|
||||||
struct Ipc_WorkspaceDidChangeConfiguration
|
struct In_WorkspaceDidChangeConfiguration : public NotificationMessage {
|
||||||
: public NotificationMessage<Ipc_WorkspaceDidChangeConfiguration> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::WorkspaceDidChangeConfiguration;
|
|
||||||
lsDidChangeConfigurationParams params;
|
lsDidChangeConfigurationParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeConfiguration, params);
|
MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeConfiguration, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeConfiguration);
|
REGISTER_IN_MESSAGE(In_WorkspaceDidChangeConfiguration);
|
||||||
|
|
||||||
struct WorkspaceDidChangeConfigurationHandler
|
struct Handler_WorkspaceDidChangeConfiguration
|
||||||
: BaseMessageHandler<Ipc_WorkspaceDidChangeConfiguration> {
|
: BaseMessageHandler<In_WorkspaceDidChangeConfiguration> {
|
||||||
void Run(Ipc_WorkspaceDidChangeConfiguration* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_WorkspaceDidChangeConfiguration* request) override {
|
||||||
Timer time;
|
Timer time;
|
||||||
project->Load(config, config->projectRoot);
|
project->Load(config, config->projectRoot);
|
||||||
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
||||||
@ -40,5 +42,5 @@ struct WorkspaceDidChangeConfigurationHandler
|
|||||||
LOG_S(INFO) << "Flushed all clang complete sessions";
|
LOG_S(INFO) << "Flushed all clang complete sessions";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeConfigurationHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceDidChangeConfiguration);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <loguru/loguru.hpp>
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "workspace/didChangeWatchedFiles";
|
||||||
|
|
||||||
enum class lsFileChangeType {
|
enum class lsFileChangeType {
|
||||||
Created = 1,
|
Created = 1,
|
||||||
Changed = 2,
|
Changed = 2,
|
||||||
@ -26,17 +28,17 @@ struct lsDidChangeWatchedFilesParams {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes);
|
MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes);
|
||||||
|
|
||||||
struct Ipc_WorkspaceDidChangeWatchedFiles
|
struct In_WorkspaceDidChangeWatchedFiles : public NotificationMessage {
|
||||||
: public NotificationMessage<Ipc_WorkspaceDidChangeWatchedFiles> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles;
|
|
||||||
lsDidChangeWatchedFilesParams params;
|
lsDidChangeWatchedFilesParams params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeWatchedFiles, params);
|
MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeWatchedFiles, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeWatchedFiles);
|
REGISTER_IN_MESSAGE(In_WorkspaceDidChangeWatchedFiles);
|
||||||
|
|
||||||
struct WorkspaceDidChangeWatchedFilesHandler
|
struct Handler_WorkspaceDidChangeWatchedFiles
|
||||||
: BaseMessageHandler<Ipc_WorkspaceDidChangeWatchedFiles> {
|
: BaseMessageHandler<In_WorkspaceDidChangeWatchedFiles> {
|
||||||
void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_WorkspaceDidChangeWatchedFiles* request) override {
|
||||||
for (lsFileEvent& event : request->params.changes) {
|
for (lsFileEvent& event : request->params.changes) {
|
||||||
std::string path = event.uri.GetPath();
|
std::string path = event.uri.GetPath();
|
||||||
auto it = project->absolute_path_to_entry_index_.find(path);
|
auto it = project->absolute_path_to_entry_index_.find(path);
|
||||||
@ -69,5 +71,5 @@ struct WorkspaceDidChangeWatchedFilesHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeWatchedFilesHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceDidChangeWatchedFiles);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "workspace/executeCommand";
|
||||||
|
|
||||||
struct Ipc_WorkspaceExecuteCommand
|
struct In_WorkspaceExecuteCommand : public RequestMessage {
|
||||||
: public RequestMessage<Ipc_WorkspaceExecuteCommand> {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
const static IpcId kIpcId = IpcId::WorkspaceExecuteCommand;
|
|
||||||
lsCommand<lsCodeLensCommandArguments> params;
|
lsCommand<lsCodeLensCommandArguments> params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceExecuteCommand, id, params);
|
MAKE_REFLECT_STRUCT(In_WorkspaceExecuteCommand, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceExecuteCommand);
|
REGISTER_IN_MESSAGE(In_WorkspaceExecuteCommand);
|
||||||
|
|
||||||
struct Out_WorkspaceExecuteCommand
|
struct Out_WorkspaceExecuteCommand
|
||||||
: public lsOutMessage<Out_WorkspaceExecuteCommand> {
|
: public lsOutMessage<Out_WorkspaceExecuteCommand> {
|
||||||
@ -28,9 +28,10 @@ void Reflect(Writer& visitor, Out_WorkspaceExecuteCommand& value) {
|
|||||||
REFLECT_MEMBER_END();
|
REFLECT_MEMBER_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WorkspaceExecuteCommandHandler
|
struct Handler_WorkspaceExecuteCommand
|
||||||
: BaseMessageHandler<Ipc_WorkspaceExecuteCommand> {
|
: BaseMessageHandler<In_WorkspaceExecuteCommand> {
|
||||||
void Run(Ipc_WorkspaceExecuteCommand* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_WorkspaceExecuteCommand* request) override {
|
||||||
const auto& params = request->params;
|
const auto& params = request->params;
|
||||||
Out_WorkspaceExecuteCommand out;
|
Out_WorkspaceExecuteCommand out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
@ -41,9 +42,9 @@ struct WorkspaceExecuteCommandHandler
|
|||||||
out.result = params.arguments.locations;
|
out.result = params.arguments.locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::WorkspaceExecuteCommand, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(WorkspaceExecuteCommandHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceExecuteCommand);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
MethodType kMethodType = "workspace/symbol";
|
||||||
|
|
||||||
// Lookup |symbol| in |db| and insert the value into |result|.
|
// Lookup |symbol| in |db| and insert the value into |result|.
|
||||||
bool InsertSymbolIntoResult(QueryDatabase* db,
|
bool InsertSymbolIntoResult(QueryDatabase* db,
|
||||||
@ -42,16 +43,16 @@ bool InsertSymbolIntoResult(QueryDatabase* db,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Ipc_WorkspaceSymbol : public RequestMessage<Ipc_WorkspaceSymbol> {
|
struct In_WorkspaceSymbol : public RequestMessage {
|
||||||
const static IpcId kIpcId = IpcId::WorkspaceSymbol;
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
struct Params {
|
struct Params {
|
||||||
std::string query;
|
std::string query;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol::Params, query);
|
MAKE_REFLECT_STRUCT(In_WorkspaceSymbol::Params, query);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params);
|
MAKE_REFLECT_STRUCT(In_WorkspaceSymbol, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol);
|
REGISTER_IN_MESSAGE(In_WorkspaceSymbol);
|
||||||
|
|
||||||
struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> {
|
struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> {
|
||||||
lsRequestId id;
|
lsRequestId id;
|
||||||
@ -61,8 +62,9 @@ MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result);
|
|||||||
|
|
||||||
///// Fuzzy matching
|
///// Fuzzy matching
|
||||||
|
|
||||||
struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
struct Handler_WorkspaceSymbol : BaseMessageHandler<In_WorkspaceSymbol> {
|
||||||
void Run(Ipc_WorkspaceSymbol* request) override {
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
|
void Run(In_WorkspaceSymbol* request) override {
|
||||||
Out_WorkspaceSymbol out;
|
Out_WorkspaceSymbol out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
|
||||||
@ -151,8 +153,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
|||||||
|
|
||||||
LOG_S(INFO) << "[querydb] Found " << out.result.size()
|
LOG_S(INFO) << "[querydb] Found " << out.result.size()
|
||||||
<< " results for query " << query;
|
<< " results for query " << query;
|
||||||
QueueManager::WriteStdout(IpcId::WorkspaceSymbol, out);
|
QueueManager::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(WorkspaceSymbolHandler);
|
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceSymbol);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
// General
|
|
||||||
CASE(Initialize, "initialize")
|
|
||||||
CASE(Shutdown, "shutdown")
|
|
||||||
|
|
||||||
CASE(CodeLensResolve, "codeLens/resolve")
|
|
||||||
CASE(TextDocumentCodeAction, "textDocument/codeAction")
|
|
||||||
CASE(TextDocumentCodeLens, "textDocument/codeLens")
|
|
||||||
CASE(TextDocumentCompletion, "textDocument/completion")
|
|
||||||
CASE(TextDocumentDefinition, "textDocument/definition")
|
|
||||||
CASE(TextDocumentDidChange, "textDocument/didChange")
|
|
||||||
CASE(TextDocumentDidClose, "textDocument/didClose")
|
|
||||||
CASE(TextDocumentDidOpen, "textDocument/didOpen")
|
|
||||||
CASE(TextDocumentDidSave, "textDocument/didSave")
|
|
||||||
CASE(TextDocumentDocumentHighlight, "textDocument/documentHighlight")
|
|
||||||
CASE(TextDocumentDocumentLink, "textDocument/documentLink")
|
|
||||||
CASE(TextDocumentDocumentSymbol, "textDocument/documentSymbol")
|
|
||||||
CASE(TextDocumentFormatting, "textDocument/formatting")
|
|
||||||
CASE(TextDocumentHover, "textDocument/hover")
|
|
||||||
CASE(TextDocumentOnTypeFormatting, "textDocument/onTypeFormatting")
|
|
||||||
CASE(TextDocumentPublishDiagnostics, "textDocument/publishDiagnostics")
|
|
||||||
CASE(TextDocumentRangeFormatting, "textDocument/rangeFormatting")
|
|
||||||
CASE(TextDocumentReferences, "textDocument/references")
|
|
||||||
CASE(TextDocumentRename, "textDocument/rename")
|
|
||||||
CASE(TextDocumentSignatureHelp, "textDocument/signatureHelp")
|
|
||||||
CASE(TextDocumentTypeDefinition, "textDocument/typeDefinition")
|
|
||||||
CASE(WorkspaceDidChangeConfiguration, "workspace/didChangeConfiguration")
|
|
||||||
CASE(WorkspaceDidChangeWatchedFiles, "workspace/didChangeWatchedFiles")
|
|
||||||
CASE(WorkspaceExecuteCommand, "workspace/executeCommand")
|
|
||||||
CASE(WorkspaceSymbol, "workspace/symbol")
|
|
||||||
|
|
||||||
// Notification extensions
|
|
||||||
CASE(CqueryTextDocumentDidView, "$cquery/textDocumentDidView")
|
|
||||||
CASE(CqueryPublishInactiveRegions, "$cquery/publishInactiveRegions")
|
|
||||||
CASE(CqueryPublishSemanticHighlighting, "$cquery/publishSemanticHighlighting")
|
|
||||||
|
|
||||||
// Request extensions
|
|
||||||
CASE(CqueryFileInfo, "$cquery/fileInfo")
|
|
||||||
CASE(CqueryFreshenIndex, "$cquery/freshenIndex")
|
|
||||||
|
|
||||||
CASE(CqueryCallHierarchy, "$cquery/callHierarchy")
|
|
||||||
CASE(CqueryInheritanceHierarchy, "$cquery/inheritanceHierarchy")
|
|
||||||
CASE(CqueryMemberHierarchy, "$cquery/memberHierarchy")
|
|
||||||
|
|
||||||
// Cross reference extensions.
|
|
||||||
// Show all variables of a type.
|
|
||||||
CASE(CqueryVars, "$cquery/vars")
|
|
||||||
// Show all callers of a function.
|
|
||||||
CASE(CqueryCallers, "$cquery/callers")
|
|
||||||
// Show base types/method.
|
|
||||||
CASE(CqueryBase, "$cquery/base")
|
|
||||||
// Show all derived types/methods.
|
|
||||||
CASE(CqueryDerived, "$cquery/derived")
|
|
||||||
// Show random definition.
|
|
||||||
CASE(CqueryRandom, "$cquery/random")
|
|
||||||
|
|
||||||
// Messages for testing.
|
|
||||||
// Index the given file contents.
|
|
||||||
CASE(CqueryIndexFile, "$cquery/indexFile")
|
|
||||||
// Wait until all cquery threads are idle.
|
|
||||||
CASE(CqueryWait, "$cquery/wait")
|
|
@ -63,13 +63,13 @@ void QueueManager::Init(MultiQueueWaiter* querydb_waiter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void QueueManager::WriteStdout(IpcId id, lsBaseOutMessage& response) {
|
void QueueManager::WriteStdout(MethodType method, lsBaseOutMessage& response) {
|
||||||
std::ostringstream sstream;
|
std::ostringstream sstream;
|
||||||
response.Write(sstream);
|
response.Write(sstream);
|
||||||
|
|
||||||
Stdout_Request out;
|
Stdout_Request out;
|
||||||
out.content = sstream.str();
|
out.content = sstream.str();
|
||||||
out.id = id;
|
out.method = method;
|
||||||
instance()->for_stdout.PushBack(std::move(out));
|
instance()->for_stdout.PushBack(std::move(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ struct ICacheManager;
|
|||||||
struct lsBaseOutMessage;
|
struct lsBaseOutMessage;
|
||||||
|
|
||||||
struct Stdout_Request {
|
struct Stdout_Request {
|
||||||
IpcId id;
|
MethodType method;
|
||||||
std::string content;
|
std::string content;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class QueueManager {
|
|||||||
static void Init(MultiQueueWaiter* querydb_waiter,
|
static void Init(MultiQueueWaiter* querydb_waiter,
|
||||||
MultiQueueWaiter* indexer_waiter,
|
MultiQueueWaiter* indexer_waiter,
|
||||||
MultiQueueWaiter* stdout_waiter);
|
MultiQueueWaiter* stdout_waiter);
|
||||||
static void WriteStdout(IpcId id, lsBaseOutMessage& response);
|
static void WriteStdout(MethodType method, lsBaseOutMessage& response);
|
||||||
|
|
||||||
bool HasWork();
|
bool HasWork();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user