Remove global list of message ids.

Also do some naming cleanup. Also remove xmacros.
This commit is contained in:
Jacob Dufault 2018-03-21 21:05:25 -07:00 committed by Fangrui Song
parent ee87d6cb97
commit e37a6c814b
50 changed files with 517 additions and 550 deletions

View File

@ -57,20 +57,15 @@ namespace {
std::vector<std::string> kEmptyArgs;
// This function returns true if e2e timing should be displayed for the given
// IpcId.
bool ShouldDisplayIpcTiming(IpcId id) {
switch (id) {
case IpcId::TextDocumentPublishDiagnostics:
case IpcId::CqueryPublishInactiveRegions:
case IpcId::Unknown:
return false;
default:
// MethodId.
bool ShouldDisplayMethodTiming(MethodType type) {
return
type != kMethodType_TextDocumentPublishDiagnostics &&
type != kMethodType_CqueryPublishInactiveRegions &&
type != kMethodType_Unknown;
return true;
}
}
REGISTER_IPC_MESSAGE(Ipc_CancelRequest);
void PrintHelp() {
std::cout
<< 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();
bool did_work = messages.size();
for (auto& message : messages) {
// TODO: Consider using std::unordered_map to lookup the handler
for (MessageHandler* handler : *MessageHandler::message_handlers) {
if (handler->GetId() == message->method_id) {
if (handler->GetMethodType() == message->GetMethodType()) {
handler->Run(std::move(message));
break;
}
}
if (message) {
LOG_S(FATAL) << "Exiting; unhandled IPC message "
<< IpcIdToString(message->method_id);
LOG_S(FATAL) << "Exiting; no handler for " << message->GetMethodType();
exit(1);
}
}
@ -199,7 +194,7 @@ void RunQueryDbThread(const std::string& bin_name,
out.error.message =
"Dropping completion request; a newer request "
"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.
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
// clients.
std::cin.tie(nullptr);
@ -301,47 +296,28 @@ void LaunchStdinLoop(Config* config,
out.id = id;
out.error.code = lsErrorCodes::InvalidParams;
out.error.message = std::move(*err);
queue->WriteStdout(IpcId::Unknown, out);
queue->WriteStdout(kMethodType_Unknown, out);
}
}
continue;
}
// Cache |method_id| so we can access it after moving |message|.
IpcId method_id = message->method_id;
(*request_times)[method_id] = Timer();
MethodType method_type = message->GetMethodType();
(*request_times)[method_type] = Timer();
switch (method_id) {
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
LOG_S(ERROR) << "!! Got message of type " << method_type;
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
// exit. Stop reading from stdin since it might be detached.
if (method_id == IpcId::Exit)
if (method_type == kMethodType_Exit)
break;
}
});
}
void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
void LaunchStdoutThread(std::unordered_map<MethodType, Timer>* request_times,
MultiQueueWaiter* waiter) {
WorkThread::StartThread("stdout", [=]() {
auto* queue = QueueManager::instance();
@ -354,10 +330,9 @@ void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
}
for (auto& message : messages) {
if (ShouldDisplayIpcTiming(message.id)) {
Timer time = (*request_times)[message.id];
time.ResetAndPrint("[e2e] Running " +
std::string(IpcIdToString(message.id)));
if (ShouldDisplayMethodTiming(message.method)) {
Timer time = (*request_times)[message.method];
time.ResetAndPrint("[e2e] Running " + std::string(message.method));
}
RecordOutput(message.content);
@ -374,7 +349,7 @@ void LanguageServerMain(const std::string& bin_name,
MultiQueueWaiter* querydb_waiter,
MultiQueueWaiter* indexer_waiter,
MultiQueueWaiter* stdout_waiter) {
std::unordered_map<IpcId, Timer> request_times;
std::unordered_map<MethodType, Timer> request_times;
LaunchStdinLoop(config, &request_times);

View File

@ -30,6 +30,6 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files,
Out_TextDocumentPublishDiagnostics out;
out.params.uri = lsDocumentUri::FromPath(path);
out.params.diagnostics = diagnostics;
QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out);
QueueManager::WriteStdout(kMethodType_TextDocumentPublishDiagnostics, out);
}
}

View File

@ -136,7 +136,7 @@ struct ActiveThread {
GetCurrentTimeInMilliseconds() + config_->progressReportFrequencyMs;
}
QueueManager::WriteStdout(IpcId::Unknown, out);
QueueManager::WriteStdout(kMethodType_Unknown, out);
}
Config* config_;
@ -400,7 +400,7 @@ void ParseFile(Config* config,
out.id = request.id;
out.error.code = lsErrorCodes::InternalError;
out.error.message = "Failed to index " + path_to_index;
QueueManager::WriteStdout(IpcId::Unknown, out);
QueueManager::WriteStdout(kMethodType_Unknown, out);
}
return;
}

View File

@ -1,30 +1,10 @@
#include "ipc.h"
#include <cassert>
const char* IpcIdToString(IpcId id) {
switch (id) {
case IpcId::CancelRequest:
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) {}
const char* kMethodType_Unknown = "$unknown";
const char* kMethodType_Exit = "exit";
const char* kMethodType_TextDocumentPublishDiagnostics = "textDocument/publishDiagnostics";
const char* kMethodType_CqueryPublishInactiveRegions = "$cquery/publishInactiveRegions";
const char* kMethodType_CqueryPublishSemanticHighlighting = "$cquery/publishSemanticHighlighting";
BaseIpcMessage::~BaseIpcMessage() = default;

View File

@ -7,48 +7,26 @@
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
enum class IpcId : int {
// Language server specific requests.
CancelRequest = 0,
Initialized,
Exit,
using MethodType = std::string;
#define CASE(x, _) x,
#include "methods.inc"
#undef CASE
// Internal implementation detail.
Unknown,
};
MAKE_ENUM_HASHABLE(IpcId)
MAKE_REFLECT_TYPE_PROXY(IpcId)
const char* IpcIdToString(IpcId id);
extern const char* kMethodType_Unknown;
extern const char* kMethodType_Exit;
extern const char* kMethodType_TextDocumentPublishDiagnostics;
extern const char* kMethodType_CqueryPublishInactiveRegions;
extern const char* kMethodType_CqueryPublishSemanticHighlighting;
struct BaseIpcMessage {
const IpcId method_id;
BaseIpcMessage(IpcId method_id);
virtual ~BaseIpcMessage();
virtual MethodType GetMethodType() const = 0;
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 {
// number | string, actually no null
// number or string, actually no null
lsRequestId id;
RequestMessage() : BaseIpcMessage(T::kIpcId) {}
lsRequestId GetRequestId() override { return id; }
};
// NotificationMessage does not have |id|.
template <typename T>
struct NotificationMessage : public BaseIpcMessage {
NotificationMessage() : BaseIpcMessage(T::kIpcId) {}
};
struct NotificationMessage : public BaseIpcMessage {};

View File

@ -24,7 +24,7 @@
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#define REGISTER_IPC_MESSAGE(type) \
#define REGISTER_IN_MESSAGE(type) \
static MessageRegistryRegister<type> type##message_handler_instance_;
struct MessageRegistry {
@ -44,7 +44,8 @@ struct MessageRegistry {
template <typename T>
struct MessageRegistryRegister {
MessageRegistryRegister() {
std::string method_name = IpcIdToString(T::kIpcId);
T dummy;
std::string method_name = dummy.GetMethodType();
MessageRegistry::instance()->allocators[method_name] =
[](Reader& visitor, std::unique_ptr<BaseIpcMessage>* message) {
*message = std::make_unique<T>();
@ -334,12 +335,6 @@ struct lsFormattingOptions {
};
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
// markdown string or a code-block that provides a language and a code snippet.
// The language identifier is sematically equal to the optional language

View File

@ -32,7 +32,7 @@ optional<Matcher> Matcher::Create(const std::string& search) {
out.params.type = lsMessageType::Error;
out.params.message = "cquery: Parsing EMCAScript regex \"" + search +
"\" failed; " + e.what();
QueueManager::WriteStdout(IpcId::Unknown, out);
QueueManager::WriteStdout(kMethodType_Unknown, out);
return nullopt;
}
}

View File

@ -99,7 +99,7 @@ bool FindFileOrFail(QueryDatabase* db,
out.error.code = lsErrorCodes::InternalError;
out.error.message = "Unable to find file " + absolute_path;
}
QueueManager::WriteStdout(IpcId::Unknown, out);
QueueManager::WriteStdout(kMethodType_Unknown, out);
}
return false;
@ -114,7 +114,7 @@ void EmitInactiveLines(WorkingFile* working_file,
if (ls_skipped)
out.params.inactiveRegions.push_back(*ls_skipped);
}
QueueManager::WriteStdout(IpcId::CqueryPublishInactiveRegions, out);
QueueManager::WriteStdout(kMethodType_CqueryPublishInactiveRegions, out);
}
void EmitSemanticHighlighting(QueryDatabase* db,
@ -277,7 +277,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
for (auto& entry : grouped_symbols)
if (entry.second.ranges.size())
out.params.symbols.push_back(entry.second);
QueueManager::WriteStdout(IpcId::CqueryPublishSemanticHighlighting, out);
QueueManager::WriteStdout(kMethodType_CqueryPublishSemanticHighlighting, out);
}
bool ShouldIgnoreFileForIndexing(const std::string& path) {

View File

@ -86,7 +86,7 @@ struct MessageHandler {
CodeCompleteCache* non_global_code_complete_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;
static std::vector<MessageHandler*>* message_handlers;
@ -100,9 +100,8 @@ struct BaseMessageHandler : MessageHandler {
virtual void Run(TMessage* message) = 0;
// MessageHandler:
IpcId GetId() const override { return TMessage::kIpcId; }
void Run(std::unique_ptr<BaseIpcMessage> message) override {
Run(message->As<TMessage>());
Run(static_cast<TMessage*>(message.get()));
}
};

View File

@ -3,15 +3,21 @@
#include "queue_manager.h"
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;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryBase, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryBase);
MAKE_REFLECT_STRUCT(In_CqueryBase, id, params);
REGISTER_IN_MESSAGE(In_CqueryBase);
struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
void Run(Ipc_CqueryBase* request) override {
struct Handler_CqueryBase : BaseMessageHandler<In_CqueryBase> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryBase* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
@ -39,8 +45,8 @@ struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
break;
}
}
QueueManager::WriteStdout(IpcId::CqueryBase, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(CqueryBaseHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryBase);
} // namespace

View File

@ -5,6 +5,9 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "$cquery/callHierarchy";
enum class CallType : uint8_t {
Direct = 0,
Base = 1,
@ -17,9 +20,9 @@ bool operator&(CallType lhs, CallType rhs) {
return uint8_t(lhs) & uint8_t(rhs);
}
struct Ipc_CqueryCallHierarchy
: public RequestMessage<Ipc_CqueryCallHierarchy> {
const static IpcId kIpcId = IpcId::CqueryCallHierarchy;
struct In_CqueryCallHierarchy : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// If id is specified, expand a node; otherwise textDocument+position should
// be specified for building the root and |levels| of nodes below.
@ -38,8 +41,9 @@ struct Ipc_CqueryCallHierarchy
int levels = 1;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params,
MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy::Params,
textDocument,
position,
id,
@ -47,8 +51,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy::Params,
callType,
detailedName,
levels);
MAKE_REFLECT_STRUCT(Ipc_CqueryCallHierarchy, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryCallHierarchy);
MAKE_REFLECT_STRUCT(In_CqueryCallHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CqueryCallHierarchy);
struct Out_CqueryCallHierarchy : public lsOutMessage<Out_CqueryCallHierarchy> {
struct Entry {
@ -155,8 +159,10 @@ bool Expand(MessageHandler* m,
return true;
}
struct CqueryCallHierarchyHandler
: BaseMessageHandler<Ipc_CqueryCallHierarchy> {
struct Handler_CqueryCallHierarchy
: BaseMessageHandler<In_CqueryCallHierarchy> {
MethodType GetMethodType() const override { return kMethodType; }
optional<Out_CqueryCallHierarchy::Entry> BuildInitial(QueryFuncId root_id,
bool callee,
CallType call_type,
@ -178,7 +184,7 @@ struct CqueryCallHierarchyHandler
return entry;
}
void Run(Ipc_CqueryCallHierarchy* request) override {
void Run(In_CqueryCallHierarchy* request) override {
const auto& params = request->params;
Out_CqueryCallHierarchy out;
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

View File

@ -3,15 +3,18 @@
#include "queue_manager.h"
namespace {
struct Ipc_CqueryCallers : public RequestMessage<Ipc_CqueryCallers> {
const static IpcId kIpcId = IpcId::CqueryCallers;
MethodType kMethodType = "$cquery/callers";
struct In_CqueryCallers : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryCallers, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryCallers);
MAKE_REFLECT_STRUCT(In_CqueryCallers, id, params);
REGISTER_IN_MESSAGE(In_CqueryCallers);
struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
void Run(Ipc_CqueryCallers* request) override {
struct Handler_CqueryCallers : BaseMessageHandler<In_CqueryCallers> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryCallers* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
@ -38,8 +41,8 @@ struct CqueryCallersHandler : BaseMessageHandler<Ipc_CqueryCallers> {
break;
}
}
QueueManager::WriteStdout(IpcId::CqueryCallers, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(CqueryCallersHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryCallers);
} // namespace

View File

@ -3,15 +3,18 @@
#include "queue_manager.h"
namespace {
struct Ipc_CqueryDerived : public RequestMessage<Ipc_CqueryDerived> {
const static IpcId kIpcId = IpcId::CqueryDerived;
MethodType kMethodType = "$cquery/derived";
struct In_CqueryDerived : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryDerived, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryDerived);
MAKE_REFLECT_STRUCT(In_CqueryDerived, id, params);
REGISTER_IN_MESSAGE(In_CqueryDerived);
struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
void Run(Ipc_CqueryDerived* request) override {
struct Handler_CqueryDerived : BaseMessageHandler<In_CqueryDerived> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryDerived* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
@ -39,8 +42,8 @@ struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
break;
}
}
QueueManager::WriteStdout(IpcId::CqueryDerived, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(CqueryDerivedHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryDerived);
} // namespace

View File

@ -3,21 +3,23 @@
#include "working_files.h"
namespace {
struct Ipc_CqueryTextDocumentDidView
: public NotificationMessage<Ipc_CqueryTextDocumentDidView> {
const static IpcId kIpcId = IpcId::CqueryTextDocumentDidView;
MethodType kMethodType = "$cquery/textDocumentDidView";
struct In_CqueryTextDocumentDidView : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
lsDocumentUri textDocumentUri;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView::Params, textDocumentUri);
MAKE_REFLECT_STRUCT(Ipc_CqueryTextDocumentDidView, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryTextDocumentDidView);
MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView::Params, textDocumentUri);
MAKE_REFLECT_STRUCT(In_CqueryTextDocumentDidView, params);
REGISTER_IN_MESSAGE(In_CqueryTextDocumentDidView);
struct CqueryDidViewHandler
: BaseMessageHandler<Ipc_CqueryTextDocumentDidView> {
void Run(Ipc_CqueryTextDocumentDidView* request) override {
struct Handler_CqueryDidView
: BaseMessageHandler<In_CqueryTextDocumentDidView> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryTextDocumentDidView* request) override {
std::string path = request->params.textDocumentUri.GetPath();
WorkingFile* working_file = working_files->GetFileByFilename(path);
@ -34,5 +36,5 @@ struct CqueryDidViewHandler
}
}
};
REGISTER_MESSAGE_HANDLER(CqueryDidViewHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryDidView);
} // namespace

View File

@ -3,17 +3,19 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "$cquery/fileInfo";
struct lsDocumentSymbolParams {
lsTextDocumentIdentifier textDocument;
};
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
struct Ipc_CqueryFileInfo : public RequestMessage<Ipc_CqueryFileInfo> {
const static IpcId kIpcId = IpcId::CqueryFileInfo;
struct In_CqueryFileInfo : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsDocumentSymbolParams params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryFileInfo, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryFileInfo);
MAKE_REFLECT_STRUCT(In_CqueryFileInfo, id, params);
REGISTER_IN_MESSAGE(In_CqueryFileInfo);
struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
lsRequestId id;
@ -21,8 +23,9 @@ struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
};
MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result);
struct CqueryFileInfoHandler : BaseMessageHandler<Ipc_CqueryFileInfo> {
void Run(Ipc_CqueryFileInfo* request) override {
struct Handler_CqueryFileInfo : BaseMessageHandler<In_CqueryFileInfo> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryFileInfo* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
@ -37,8 +40,8 @@ struct CqueryFileInfoHandler : BaseMessageHandler<Ipc_CqueryFileInfo> {
out.result.language = file->def->language;
out.result.includes = file->def->includes;
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

View File

@ -13,9 +13,10 @@
#include <unordered_set>
namespace {
struct Ipc_CqueryFreshenIndex
: public NotificationMessage<Ipc_CqueryFreshenIndex> {
const static IpcId kIpcId = IpcId::CqueryFreshenIndex;
MethodType kMethodType = "$cquery/freshenIndex";
struct In_CqueryFreshenIndex : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
bool dependencies = true;
std::vector<std::string> whitelist;
@ -23,15 +24,16 @@ struct Ipc_CqueryFreshenIndex
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex::Params,
MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex::Params,
dependencies,
whitelist,
blacklist);
MAKE_REFLECT_STRUCT(Ipc_CqueryFreshenIndex, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryFreshenIndex);
MAKE_REFLECT_STRUCT(In_CqueryFreshenIndex, params);
REGISTER_IN_MESSAGE(In_CqueryFreshenIndex);
struct CqueryFreshenIndexHandler : BaseMessageHandler<Ipc_CqueryFreshenIndex> {
void Run(Ipc_CqueryFreshenIndex* request) override {
struct Handler_CqueryFreshenIndex : BaseMessageHandler<In_CqueryFreshenIndex> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryFreshenIndex* request) override {
LOG_S(INFO) << "Freshening " << project->entries.size() << " files";
// 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");
}
};
REGISTER_MESSAGE_HANDLER(CqueryFreshenIndexHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryFreshenIndex);
} // namespace

View File

@ -6,8 +6,10 @@
#include <loguru/loguru.hpp>
namespace {
struct Ipc_CqueryIndexFile : public NotificationMessage<Ipc_CqueryIndexFile> {
static constexpr IpcId kIpcId = IpcId::CqueryIndexFile;
MethodType kMethodType = "$cquery/indexFile";
struct In_CqueryIndexFile : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
std::string path;
std::vector<std::string> args;
@ -16,16 +18,17 @@ struct Ipc_CqueryIndexFile : public NotificationMessage<Ipc_CqueryIndexFile> {
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile::Params,
MAKE_REFLECT_STRUCT(In_CqueryIndexFile::Params,
path,
args,
is_interactive,
contents);
MAKE_REFLECT_STRUCT(Ipc_CqueryIndexFile, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryIndexFile);
MAKE_REFLECT_STRUCT(In_CqueryIndexFile, params);
REGISTER_IN_MESSAGE(In_CqueryIndexFile);
struct CqueryIndexFileHandler : BaseMessageHandler<Ipc_CqueryIndexFile> {
void Run(Ipc_CqueryIndexFile* request) override {
struct Handler_CqueryIndexFile : BaseMessageHandler<In_CqueryIndexFile> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryIndexFile* request) override {
LOG_S(INFO) << "Indexing file " << request->params.path;
QueueManager::instance()->index_request.PushBack(
Index_Request(NormalizePath(request->params.path), request->params.args,
@ -33,5 +36,5 @@ struct CqueryIndexFileHandler : BaseMessageHandler<Ipc_CqueryIndexFile> {
ICacheManager::Make(config)));
}
};
REGISTER_MESSAGE_HANDLER(CqueryIndexFileHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryIndexFile);
} // namespace

View File

@ -3,9 +3,10 @@
#include "queue_manager.h"
namespace {
struct Ipc_CqueryInheritanceHierarchy
: public RequestMessage<Ipc_CqueryInheritanceHierarchy> {
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy;
MethodType kMethodType = "$cquery/inheritanceHierarchy";
struct In_CqueryInheritanceHierarchy : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// If id+kind are specified, expand a node; otherwise textDocument+position
// should be specified for building the root and |levels| of nodes below.
@ -23,7 +24,7 @@ struct Ipc_CqueryInheritanceHierarchy
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params,
MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy::Params,
textDocument,
position,
id,
@ -31,8 +32,8 @@ MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy::Params,
derived,
detailedName,
levels);
MAKE_REFLECT_STRUCT(Ipc_CqueryInheritanceHierarchy, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryInheritanceHierarchy);
MAKE_REFLECT_STRUCT(In_CqueryInheritanceHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CqueryInheritanceHierarchy);
struct Out_CqueryInheritanceHierarchy
: public lsOutMessage<Out_CqueryInheritanceHierarchy> {
@ -127,8 +128,10 @@ bool Expand(MessageHandler* m,
m->db->types[entry->id.id]);
}
struct CqueryInheritanceHierarchyHandler
: BaseMessageHandler<Ipc_CqueryInheritanceHierarchy> {
struct Handler_CqueryInheritanceHierarchy
: BaseMessageHandler<In_CqueryInheritanceHierarchy> {
MethodType GetMethodType() const override { return kMethodType; }
optional<Out_CqueryInheritanceHierarchy::Entry>
BuildInitial(SymbolRef sym, bool derived, bool detailed_name, int levels) {
Out_CqueryInheritanceHierarchy::Entry entry;
@ -138,7 +141,7 @@ struct CqueryInheritanceHierarchyHandler
return entry;
}
void Run(Ipc_CqueryInheritanceHierarchy* request) override {
void Run(In_CqueryInheritanceHierarchy* request) override {
const auto& params = request->params;
Out_CqueryInheritanceHierarchy out;
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

View File

@ -3,9 +3,11 @@
#include "queue_manager.h"
namespace {
struct Ipc_CqueryMemberHierarchy
: public RequestMessage<Ipc_CqueryMemberHierarchy> {
const static IpcId kIpcId = IpcId::CqueryMemberHierarchy;
MethodType kMethodType = "$cquery/memberHierarchy";
struct In_CqueryMemberHierarchy : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// If id is specified, expand a node; otherwise textDocument+position should
// be specified for building the root and |levels| of nodes below.
@ -20,14 +22,14 @@ struct Ipc_CqueryMemberHierarchy
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy::Params,
MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy::Params,
textDocument,
position,
id,
detailedName,
levels);
MAKE_REFLECT_STRUCT(Ipc_CqueryMemberHierarchy, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryMemberHierarchy);
MAKE_REFLECT_STRUCT(In_CqueryMemberHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CqueryMemberHierarchy);
struct Out_CqueryMemberHierarchy
: public lsOutMessage<Out_CqueryMemberHierarchy> {
@ -158,8 +160,10 @@ bool Expand(MessageHandler* m,
return true;
}
struct CqueryMemberHierarchyHandler
: BaseMessageHandler<Ipc_CqueryMemberHierarchy> {
struct Handler_CqueryMemberHierarchy
: BaseMessageHandler<In_CqueryMemberHierarchy> {
MethodType GetMethodType() const override { return kMethodType; }
optional<Out_CqueryMemberHierarchy::Entry> BuildInitial(QueryFuncId root_id,
bool detailed_name,
int levels) {
@ -202,7 +206,7 @@ struct CqueryMemberHierarchyHandler
return entry;
}
void Run(Ipc_CqueryMemberHierarchy* request) override {
void Run(In_CqueryMemberHierarchy* request) override {
const auto& params = request->params;
Out_CqueryMemberHierarchy out;
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

View File

@ -7,11 +7,13 @@
#include <numeric>
namespace {
struct Ipc_CqueryRandom : public RequestMessage<Ipc_CqueryRandom> {
const static IpcId kIpcId = IpcId::CqueryRandom;
MethodType kMethodType = "$cquery/random";
struct In_CqueryRandom : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
};
MAKE_REFLECT_STRUCT(Ipc_CqueryRandom, id);
REGISTER_IPC_MESSAGE(Ipc_CqueryRandom);
MAKE_REFLECT_STRUCT(In_CqueryRandom, id);
REGISTER_IN_MESSAGE(In_CqueryRandom);
const double kDeclWeight = 3;
const double kDamping = 0.1;
@ -44,8 +46,10 @@ void Add(const std::unordered_map<SymbolIdx, int>& sym2id,
}
}
struct CqueryRandomHandler : BaseMessageHandler<Ipc_CqueryRandom> {
void Run(Ipc_CqueryRandom* request) override {
struct Handler_CqueryRandom : BaseMessageHandler<In_CqueryRandom> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryRandom* request) override {
std::unordered_map<SymbolIdx, int> sym2id;
std::vector<SymbolIdx> syms;
int n = 0;
@ -137,8 +141,8 @@ struct CqueryRandomHandler : BaseMessageHandler<Ipc_CqueryRandom> {
break;
}
}
QueueManager::WriteStdout(IpcId::CqueryRandom, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(CqueryRandomHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryRandom);
} // namespace

View File

@ -3,15 +3,20 @@
#include "queue_manager.h"
namespace {
struct Ipc_CqueryVars : public RequestMessage<Ipc_CqueryVars> {
const static IpcId kIpcId = IpcId::CqueryVars;
MethodType kMethodType = "$cquery/vars";
struct In_CqueryVars : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_CqueryVars, id, params);
REGISTER_IPC_MESSAGE(Ipc_CqueryVars);
MAKE_REFLECT_STRUCT(In_CqueryVars, id, params);
REGISTER_IN_MESSAGE(In_CqueryVars);
struct CqueryVarsHandler : BaseMessageHandler<Ipc_CqueryVars> {
void Run(Ipc_CqueryVars* request) override {
struct Handler_CqueryVars : BaseMessageHandler<In_CqueryVars> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_CqueryVars* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
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

View File

@ -6,14 +6,17 @@
#include <loguru.hpp>
namespace {
struct Ipc_CqueryWait : public NotificationMessage<Ipc_CqueryWait> {
static constexpr IpcId kIpcId = IpcId::CqueryWait;
};
MAKE_REFLECT_EMPTY_STRUCT(Ipc_CqueryWait);
REGISTER_IPC_MESSAGE(Ipc_CqueryWait);
MethodType kMethodType = "$cquery/wait";
struct In_CqueryWait : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
};
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 {
// 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.
@ -40,5 +43,5 @@ struct CqueryWaitHandler : MessageHandler {
LOG_S(INFO) << "Done waiting for idle";
}
};
REGISTER_MESSAGE_HANDLER(CqueryWaitHandler);
REGISTER_MESSAGE_HANDLER(Handler_CqueryWait);
} // namespace

View File

@ -3,19 +3,19 @@
#include <loguru.hpp>
namespace {
struct Ipc_Exit : public NotificationMessage<Ipc_Exit> {
static const IpcId kIpcId = IpcId::Exit;
struct In_Exit : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType_Exit; }
};
MAKE_REFLECT_EMPTY_STRUCT(Ipc_Exit);
REGISTER_IPC_MESSAGE(Ipc_Exit);
MAKE_REFLECT_EMPTY_STRUCT(In_Exit);
REGISTER_IN_MESSAGE(In_Exit);
struct ExitHandler : MessageHandler {
IpcId GetId() const override { return IpcId::Exit; }
struct Handler_Exit : MessageHandler {
MethodType GetMethodType() const override { return kMethodType_Exit; }
void Run(std::unique_ptr<BaseIpcMessage> request) override {
LOG_S(INFO) << "Exiting; got IpcId::Exit";
LOG_S(INFO) << "Exiting; got exit message";
exit(0);
}
};
REGISTER_MESSAGE_HANDLER(ExitHandler);
REGISTER_MESSAGE_HANDLER(Handler_Exit);
} // namespace

View File

@ -23,6 +23,8 @@ extern std::string g_init_options;
namespace {
MethodType kMethodType = "initialize";
// Code Lens options.
struct lsCodeLensOptions {
// Code lens has a resolve provider as well.
@ -460,12 +462,13 @@ struct lsInitializeError {
};
MAKE_REFLECT_STRUCT(lsInitializeError, retry);
struct Ipc_InitializeRequest : public RequestMessage<Ipc_InitializeRequest> {
const static IpcId kIpcId = IpcId::Initialize;
struct In_InitializeRequest : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsInitializeParams params;
};
MAKE_REFLECT_STRUCT(Ipc_InitializeRequest, id, params);
REGISTER_IPC_MESSAGE(Ipc_InitializeRequest);
MAKE_REFLECT_STRUCT(In_InitializeRequest, id, params);
REGISTER_IN_MESSAGE(In_InitializeRequest);
struct Out_InitializeResponse : public lsOutMessage<Out_InitializeResponse> {
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, jsonrpc, id, result);
struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
void Run(Ipc_InitializeRequest* request) override {
struct Handler_Initialize : BaseMessageHandler<In_InitializeRequest> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_InitializeRequest* request) override {
// Log initialization parameters.
rapidjson::StringBuffer output;
rapidjson::Writer<rapidjson::StringBuffer> writer(output);
@ -573,7 +578,7 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
out.result.capabilities.documentRangeFormattingProvider = true;
#endif
QueueManager::WriteStdout(IpcId::Initialize, out);
QueueManager::WriteStdout(kMethodType, out);
// Set project root.
EnsureEndsInSlash(project_path);
@ -627,5 +632,5 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
}
}
};
REGISTER_MESSAGE_HANDLER(InitializeHandler);
REGISTER_MESSAGE_HANDLER(Handler_Initialize);
} // namespace

View File

@ -2,11 +2,13 @@
#include "queue_manager.h"
namespace {
struct Ipc_Shutdown : public RequestMessage<Ipc_Shutdown> {
static const IpcId kIpcId = IpcId::Shutdown;
MethodType kMethodType = "shutdown";
struct In_Shutdown : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
};
MAKE_REFLECT_STRUCT(Ipc_Shutdown, id);
REGISTER_IPC_MESSAGE(Ipc_Shutdown);
MAKE_REFLECT_STRUCT(In_Shutdown, id);
REGISTER_IN_MESSAGE(In_Shutdown);
struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {
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);
struct ShutdownHandler : BaseMessageHandler<Ipc_Shutdown> {
void Run(Ipc_Shutdown* request) override {
struct Handler_Shutdown : BaseMessageHandler<In_Shutdown> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_Shutdown* request) override {
Out_Shutdown out;
out.id = request->id;
QueueManager::WriteStdout(IpcId::TextDocumentDefinition, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(ShutdownHandler);
REGISTER_MESSAGE_HANDLER(Handler_Shutdown);
} // namespace

View File

@ -11,6 +11,7 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "textDocument/codeAction";
optional<int> FindIncludeLine(const std::vector<std::string>& lines,
const std::string& full_include_line) {
@ -256,9 +257,9 @@ optional<lsTextEdit> BuildAutoImplementForFunction(QueryDatabase* db,
return nullopt;
}
struct Ipc_TextDocumentCodeAction
: public RequestMessage<Ipc_TextDocumentCodeAction> {
const static IpcId kIpcId = IpcId::TextDocumentCodeAction;
struct In_TextDocumentCodeAction : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
// Contains additional diagnostic information about the context in which
// a code action is run.
struct lsCodeActionContext {
@ -276,14 +277,14 @@ struct Ipc_TextDocumentCodeAction
};
lsCodeActionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionContext,
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionContext,
diagnostics);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction::lsCodeActionParams,
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction::lsCodeActionParams,
textDocument,
range,
context);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeAction, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeAction);
MAKE_REFLECT_STRUCT(In_TextDocumentCodeAction, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentCodeAction);
struct Out_TextDocumentCodeAction
: public lsOutMessage<Out_TextDocumentCodeAction> {
@ -294,9 +295,11 @@ struct Out_TextDocumentCodeAction
};
MAKE_REFLECT_STRUCT(Out_TextDocumentCodeAction, jsonrpc, id, result);
struct TextDocumentCodeActionHandler
: BaseMessageHandler<Ipc_TextDocumentCodeAction> {
void Run(Ipc_TextDocumentCodeAction* request) override {
struct Handler_TextDocumentCodeAction
: BaseMessageHandler<In_TextDocumentCodeAction> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentCodeAction* request) override {
// NOTE: This code snippet will generate some FixIts for testing:
//
// 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_CASE("in document") {

View File

@ -5,19 +5,20 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "textDocument/codeLens";
struct lsDocumentCodeLensParams {
lsTextDocumentIdentifier textDocument;
};
MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument);
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
struct Ipc_TextDocumentCodeLens
: public RequestMessage<Ipc_TextDocumentCodeLens> {
const static IpcId kIpcId = IpcId::TextDocumentCodeLens;
struct In_TextDocumentCodeLens : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsDocumentCodeLensParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentCodeLens, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeLens);
MAKE_REFLECT_STRUCT(In_TextDocumentCodeLens, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentCodeLens);
struct Out_TextDocumentCodeLens
: public lsOutMessage<Out_TextDocumentCodeLens> {
@ -81,9 +82,10 @@ void AddCodeLens(const char* singular,
common->result->push_back(code_lens);
}
struct TextDocumentCodeLensHandler
: BaseMessageHandler<Ipc_TextDocumentCodeLens> {
void Run(Ipc_TextDocumentCodeLens* request) override {
struct Handler_TextDocumentCodeLens
: BaseMessageHandler<In_TextDocumentCodeLens> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentCodeLens* request) override {
Out_TextDocumentCodeLens out;
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

View File

@ -14,6 +14,7 @@
#include <regex>
namespace {
MethodType kMethodType = "textDocument/completion";
// How a completion was triggered
enum class lsCompletionTriggerKind {
@ -47,13 +48,12 @@ struct lsCompletionParams : lsTextDocumentPositionParams {
};
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context);
struct Ipc_TextDocumentComplete
: public RequestMessage<Ipc_TextDocumentComplete> {
const static IpcId kIpcId = IpcId::TextDocumentCompletion;
struct In_TextDocumentComplete : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsCompletionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentComplete, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentComplete);
MAKE_REFLECT_STRUCT(In_TextDocumentComplete, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentComplete);
struct lsTextDocumentCompleteResult {
// This list it not complete. Further typing should result in recomputing
@ -216,17 +216,17 @@ void FilterAndSortCompletionResponse(
finalize();
}
struct TextDocumentCompletionHandler : MessageHandler {
IpcId GetId() const override { return IpcId::TextDocumentCompletion; }
struct Handler_TextDocumentCompletion : MessageHandler {
MethodType GetMethodType() const override { return kMethodType; }
void Run(std::unique_ptr<BaseIpcMessage> message) override {
auto request = std::shared_ptr<Ipc_TextDocumentComplete>(
static_cast<Ipc_TextDocumentComplete*>(message.release()));
auto request = std::shared_ptr<In_TextDocumentComplete>(
static_cast<In_TextDocumentComplete*>(message.release()));
auto write_empty_result = [request]() {
Out_TextDocumentComplete out;
out.id = request->id;
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
QueueManager::WriteStdout(kMethodType, out);
};
std::string path = request->params.textDocument.uri.GetPath();
@ -324,7 +324,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
item.textEdit->range.end.character = (int)buffer_line.size();
}
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
QueueManager::WriteStdout(kMethodType, out);
} else {
ClangCompleteManager::OnComplete callback = std::bind(
[this, is_global_completion, existing_completion, request](
@ -337,7 +337,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
// Emit completion results.
FilterAndSortCompletionResponse(&out, existing_completion,
config->completion.filterAndSort);
QueueManager::WriteStdout(IpcId::TextDocumentCompletion, out);
QueueManager::WriteStdout(kMethodType, out);
// Cache completion results.
if (!is_cached_result) {
@ -395,6 +395,6 @@ struct TextDocumentCompletionHandler : MessageHandler {
}
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentCompletionHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentCompletion);
} // namespace

View File

@ -8,14 +8,14 @@
#include <cstdlib>
namespace {
MethodType kMethodType = "textDocument/definition";
struct Ipc_TextDocumentDefinition
: public RequestMessage<Ipc_TextDocumentDefinition> {
const static IpcId kIpcId = IpcId::TextDocumentDefinition;
struct In_TextDocumentDefinition : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDefinition, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition);
MAKE_REFLECT_STRUCT(In_TextDocumentDefinition, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentDefinition);
struct Out_TextDocumentDefinition
: public lsOutMessage<Out_TextDocumentDefinition> {
@ -46,9 +46,10 @@ std::vector<Use> GetNonDefDeclarationTargets(QueryDatabase* db, SymbolRef sym) {
}
}
struct TextDocumentDefinitionHandler
: BaseMessageHandler<Ipc_TextDocumentDefinition> {
void Run(Ipc_TextDocumentDefinition* request) override {
struct Handler_TextDocumentDefinition
: BaseMessageHandler<In_TextDocumentDefinition> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDefinition* request) override {
QueryFileId file_id;
QueryFile* file;
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

View File

@ -8,18 +8,21 @@
#include <loguru/loguru.hpp>
namespace {
struct Ipc_TextDocumentDidChange
: public NotificationMessage<Ipc_TextDocumentDidChange> {
const static IpcId kIpcId = IpcId::TextDocumentDidChange;
MethodType kMethodType = "textDocument/didChange";
struct In_TextDocumentDidChange : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentDidChangeParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidChange, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidChange);
MAKE_REFLECT_STRUCT(In_TextDocumentDidChange, params);
REGISTER_IN_MESSAGE(In_TextDocumentDidChange);
struct TextDocumentDidChangeHandler
: BaseMessageHandler<Ipc_TextDocumentDidChange> {
void Run(Ipc_TextDocumentDidChange* request) override {
struct Handler_TextDocumentDidChange
: BaseMessageHandler<In_TextDocumentDidChange> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDidChange* request) override {
std::string path = request->params.textDocument.uri.GetPath();
working_files->OnChange(request->params);
if (config->enableIndexOnDidChange) {
@ -40,5 +43,5 @@ struct TextDocumentDidChangeHandler
request->params.textDocument.AsTextDocumentIdentifier());
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentDidChangeHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidChange);
} // namespace

View File

@ -4,32 +4,35 @@
#include "working_files.h"
namespace {
struct Ipc_TextDocumentDidClose
: public NotificationMessage<Ipc_TextDocumentDidClose> {
const static IpcId kIpcId = IpcId::TextDocumentDidClose;
MethodType kMethodType = "textDocument/didClose";
struct In_TextDocumentDidClose : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
lsTextDocumentIdentifier textDocument;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose::Params, textDocument);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidClose, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidClose);
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose::Params, textDocument);
MAKE_REFLECT_STRUCT(In_TextDocumentDidClose, params);
REGISTER_IN_MESSAGE(In_TextDocumentDidClose);
struct TextDocumentDidCloseHandler
: BaseMessageHandler<Ipc_TextDocumentDidClose> {
void Run(Ipc_TextDocumentDidClose* request) override {
struct Handler_TextDocumentDidClose
: BaseMessageHandler<In_TextDocumentDidClose> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDidClose* request) override {
std::string path = request->params.textDocument.uri.GetPath();
// Clear any diagnostics for the file.
Out_TextDocumentPublishDiagnostics out;
out.params.uri = request->params.textDocument.uri;
QueueManager::WriteStdout(IpcId::TextDocumentPublishDiagnostics, out);
QueueManager::WriteStdout(kMethodType, out);
// Remove internal state.
working_files->OnClose(request->params.textDocument);
clang_complete->NotifyClose(path);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentDidCloseHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidClose);
} // namespace

View File

@ -10,10 +10,12 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "textDocument/didOpen";
// Open, view, change, close file
struct Ipc_TextDocumentDidOpen
: public NotificationMessage<Ipc_TextDocumentDidOpen> {
const static IpcId kIpcId = IpcId::TextDocumentDidOpen;
struct In_TextDocumentDidOpen : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
lsTextDocumentItem textDocument;
@ -24,13 +26,15 @@ struct Ipc_TextDocumentDidOpen
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen::Params, textDocument, args);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidOpen, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidOpen);
MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen::Params, textDocument, args);
MAKE_REFLECT_STRUCT(In_TextDocumentDidOpen, params);
REGISTER_IN_MESSAGE(In_TextDocumentDidOpen);
struct TextDocumentDidOpenHandler
: BaseMessageHandler<Ipc_TextDocumentDidOpen> {
void Run(Ipc_TextDocumentDidOpen* request) override {
struct Handler_TextDocumentDidOpen
: BaseMessageHandler<In_TextDocumentDidOpen> {
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
// we will need to find a way to unblock the code lens request.
const auto& params = request->params;
@ -75,5 +79,5 @@ struct TextDocumentDidOpenHandler
}
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentDidOpenHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidOpen);
} // namespace

View File

@ -7,9 +7,11 @@
#include <loguru/loguru.hpp>
namespace {
struct Ipc_TextDocumentDidSave
: public NotificationMessage<Ipc_TextDocumentDidSave> {
const static IpcId kIpcId = IpcId::TextDocumentDidSave;
MethodType kMethodType = "textDocument/didSave";
struct In_TextDocumentDidSave : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// The document that was saved.
lsTextDocumentIdentifier textDocument;
@ -20,13 +22,15 @@ struct Ipc_TextDocumentDidSave
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave::Params, textDocument);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDidSave, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDidSave);
MAKE_REFLECT_STRUCT(In_TextDocumentDidSave::Params, textDocument);
MAKE_REFLECT_STRUCT(In_TextDocumentDidSave, params);
REGISTER_IN_MESSAGE(In_TextDocumentDidSave);
struct TextDocumentDidSaveHandler
: BaseMessageHandler<Ipc_TextDocumentDidSave> {
void Run(Ipc_TextDocumentDidSave* request) override {
struct Handler_TextDocumentDidSave
: BaseMessageHandler<In_TextDocumentDidSave> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDidSave* request) override {
std::string path = request->params.textDocument.uri.GetPath();
if (ShouldIgnoreFileForIndexing(path))
return;
@ -61,5 +65,5 @@ struct TextDocumentDidSaveHandler
clang_complete->NotifySave(path);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentDidSaveHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDidSave);
} // namespace

View File

@ -4,13 +4,14 @@
#include "symbol.h"
namespace {
struct Ipc_TextDocumentDocumentHighlight
: public RequestMessage<Ipc_TextDocumentDocumentHighlight> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentHighlight;
MethodType kMethodType = "textDocument/documentHighlight";
struct In_TextDocumentDocumentHighlight : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentHighlight, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentHighlight);
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentHighlight, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentDocumentHighlight);
struct Out_TextDocumentDocumentHighlight
: public lsOutMessage<Out_TextDocumentDocumentHighlight> {
@ -19,9 +20,10 @@ struct Out_TextDocumentDocumentHighlight
};
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result);
struct TextDocumentDocumentHighlightHandler
: BaseMessageHandler<Ipc_TextDocumentDocumentHighlight> {
void Run(Ipc_TextDocumentDocumentHighlight* request) override {
struct Handler_TextDocumentDocumentHighlight
: BaseMessageHandler<In_TextDocumentDocumentHighlight> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDocumentHighlight* request) override {
QueryFileId file_id;
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
@ -59,8 +61,8 @@ struct TextDocumentDocumentHighlightHandler
break;
}
QueueManager::WriteStdout(IpcId::TextDocumentDocumentHighlight, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentDocumentHighlightHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentHighlight);
} // namespace

View File

@ -6,18 +6,19 @@
#include <loguru.hpp>
namespace {
struct Ipc_TextDocumentDocumentLink
: public RequestMessage<Ipc_TextDocumentDocumentLink> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentLink;
MethodType kMethodType = "textDocument/documentLink";
struct In_TextDocumentDocumentLink : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// The document to provide document links for.
lsTextDocumentIdentifier textDocument;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink::Params, textDocument);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentLink, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentLink);
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink::Params, textDocument);
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentLink, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentDocumentLink);
// 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.
@ -36,9 +37,10 @@ struct Out_TextDocumentDocumentLink
};
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result);
struct TextDocumentDocumentLinkHandler
: BaseMessageHandler<Ipc_TextDocumentDocumentLink> {
void Run(Ipc_TextDocumentDocumentLink* request) override {
struct Handler_TextDocumentDocumentLink
: BaseMessageHandler<In_TextDocumentDocumentLink> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDocumentLink* request) override {
Out_TextDocumentDocumentLink out;
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

View File

@ -3,18 +3,19 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "textDocument/documentSymbol";
struct lsDocumentSymbolParams {
lsTextDocumentIdentifier textDocument;
};
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
struct Ipc_TextDocumentDocumentSymbol
: public RequestMessage<Ipc_TextDocumentDocumentSymbol> {
const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol;
struct In_TextDocumentDocumentSymbol : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsDocumentSymbolParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol);
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol);
struct Out_TextDocumentDocumentSymbol
: public lsOutMessage<Out_TextDocumentDocumentSymbol> {
@ -23,9 +24,10 @@ struct Out_TextDocumentDocumentSymbol
};
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result);
struct TextDocumentDocumentSymbolHandler
: BaseMessageHandler<Ipc_TextDocumentDocumentSymbol> {
void Run(Ipc_TextDocumentDocumentSymbol* request) override {
struct Handler_TextDocumentDocumentSymbol
: BaseMessageHandler<In_TextDocumentDocumentSymbol> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentDocumentSymbol* request) override {
Out_TextDocumentDocumentSymbol out;
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

View File

@ -6,19 +6,19 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "textDocument/formatting";
struct Ipc_TextDocumentFormatting
: public RequestMessage<Ipc_TextDocumentFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
struct In_TextDocumentFormatting : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
lsTextDocumentIdentifier textDocument;
lsFormattingOptions options;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting::Params, textDocument, options);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentFormatting, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentFormatting);
MAKE_REFLECT_STRUCT(In_TextDocumentFormatting::Params, textDocument, options);
MAKE_REFLECT_STRUCT(In_TextDocumentFormatting, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentFormatting);
struct Out_TextDocumentFormatting
: public lsOutMessage<Out_TextDocumentFormatting> {
@ -27,9 +27,10 @@ struct Out_TextDocumentFormatting
};
MAKE_REFLECT_STRUCT(Out_TextDocumentFormatting, jsonrpc, id, result);
struct TextDocumentFormattingHandler
: BaseMessageHandler<Ipc_TextDocumentFormatting> {
void Run(Ipc_TextDocumentFormatting* request) override {
struct Handler_TextDocumentFormatting
: BaseMessageHandler<In_TextDocumentFormatting> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentFormatting* request) override {
Out_TextDocumentFormatting response;
response.id = request->id;
#if USE_CLANG_CXX
@ -54,8 +55,8 @@ struct TextDocumentFormattingHandler
response.result = {};
#endif
QueueManager::WriteStdout(IpcId::TextDocumentFormatting, response);
QueueManager::WriteStdout(kMethodType, response);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentFormattingHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentFormatting);
} // namespace

View File

@ -3,6 +3,7 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "textDocument/hover";
std::pair<std::string_view, std::string_view> GetCommentsAndHover(
QueryDatabase* db,
@ -41,12 +42,12 @@ std::pair<std::string_view, std::string_view> GetCommentsAndHover(
return {"", ""};
}
struct Ipc_TextDocumentHover : public RequestMessage<Ipc_TextDocumentHover> {
const static IpcId kIpcId = IpcId::TextDocumentHover;
struct In_TextDocumentHover : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentHover, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentHover);
MAKE_REFLECT_STRUCT(In_TextDocumentHover, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentHover);
struct Out_TextDocumentHover : public lsOutMessage<Out_TextDocumentHover> {
struct Result {
@ -73,8 +74,9 @@ void Reflect(Writer& visitor, Out_TextDocumentHover& value) {
REFLECT_MEMBER_END();
}
struct TextDocumentHoverHandler : BaseMessageHandler<Ipc_TextDocumentHover> {
void Run(Ipc_TextDocumentHover* request) override {
struct Handler_TextDocumentHover : BaseMessageHandler<In_TextDocumentHover> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentHover* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
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

View File

@ -7,6 +7,7 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "textDocument/rangeFormatting";
struct lsTextDocumentRangeFormattingParams {
lsTextDocumentIdentifier textDocument;
@ -18,13 +19,12 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
range,
options);
struct Ipc_TextDocumentRangeFormatting
: public RequestMessage<Ipc_TextDocumentRangeFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
struct In_TextDocumentRangeFormatting : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentRangeFormattingParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting);
MAKE_REFLECT_STRUCT(In_TextDocumentRangeFormatting, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentRangeFormatting);
struct Out_TextDocumentRangeFormatting
: public lsOutMessage<Out_TextDocumentRangeFormatting> {
@ -33,9 +33,11 @@ struct Out_TextDocumentRangeFormatting
};
MAKE_REFLECT_STRUCT(Out_TextDocumentRangeFormatting, jsonrpc, id, result);
struct TextDocumentRangeFormattingHandler
: BaseMessageHandler<Ipc_TextDocumentRangeFormatting> {
void Run(Ipc_TextDocumentRangeFormatting* request) override {
struct Handler_TextDocumentRangeFormatting
: BaseMessageHandler<In_TextDocumentRangeFormatting> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentRangeFormatting* request) override {
Out_TextDocumentRangeFormatting response;
response.id = request->id;
#if USE_CLANG_CXX
@ -62,8 +64,8 @@ struct TextDocumentRangeFormattingHandler
response.result = {};
#endif
QueueManager::WriteStdout(IpcId::TextDocumentRangeFormatting, response);
QueueManager::WriteStdout(kMethodType, response);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentRangeFormattingHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRangeFormatting);
} // namespace

View File

@ -5,9 +5,10 @@
#include <loguru.hpp>
namespace {
struct Ipc_TextDocumentReferences
: public RequestMessage<Ipc_TextDocumentReferences> {
const static IpcId kIpcId = IpcId::TextDocumentReferences;
MethodType kMethodType = "textDocument/references";
struct In_TextDocumentReferences : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct lsReferenceContext {
// Include the declaration of the current symbol.
bool includeDeclaration;
@ -22,15 +23,15 @@ struct Ipc_TextDocumentReferences
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext,
MAKE_REFLECT_STRUCT(In_TextDocumentReferences::lsReferenceContext,
includeDeclaration,
role);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::Params,
MAKE_REFLECT_STRUCT(In_TextDocumentReferences::Params,
textDocument,
position,
context);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentReferences);
MAKE_REFLECT_STRUCT(In_TextDocumentReferences, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentReferences);
struct Out_TextDocumentReferences
: public lsOutMessage<Out_TextDocumentReferences> {
@ -39,9 +40,11 @@ struct Out_TextDocumentReferences
};
MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result);
struct TextDocumentReferencesHandler
: BaseMessageHandler<Ipc_TextDocumentReferences> {
void Run(Ipc_TextDocumentReferences* request) override {
struct Handler_TextDocumentReferences
: BaseMessageHandler<In_TextDocumentReferences> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentReferences* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
request->params.textDocument.uri.GetPath(), &file)) {
@ -93,8 +96,8 @@ struct TextDocumentReferencesHandler
if ((int)out.result.size() >= 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

View File

@ -3,6 +3,7 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "textDocument/rename";
lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
WorkingFiles* working_files,
@ -47,8 +48,8 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
return edit;
}
struct Ipc_TextDocumentRename : public RequestMessage<Ipc_TextDocumentRename> {
const static IpcId kIpcId = IpcId::TextDocumentRename;
struct In_TextDocumentRename : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
// The document to format.
lsTextDocumentIdentifier textDocument;
@ -63,12 +64,12 @@ struct Ipc_TextDocumentRename : public RequestMessage<Ipc_TextDocumentRename> {
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename::Params,
MAKE_REFLECT_STRUCT(In_TextDocumentRename::Params,
textDocument,
position,
newName);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRename, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRename);
MAKE_REFLECT_STRUCT(In_TextDocumentRename, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentRename);
struct Out_TextDocumentRename : public lsOutMessage<Out_TextDocumentRename> {
lsRequestId id;
@ -76,8 +77,9 @@ struct Out_TextDocumentRename : public lsOutMessage<Out_TextDocumentRename> {
};
MAKE_REFLECT_STRUCT(Out_TextDocumentRename, jsonrpc, id, result);
struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
void Run(Ipc_TextDocumentRename* request) override {
struct Handler_TextDocumentRename : BaseMessageHandler<In_TextDocumentRename> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentRename* request) override {
QueryFileId file_id;
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
@ -100,8 +102,8 @@ struct TextDocumentRenameHandler : BaseMessageHandler<Ipc_TextDocumentRename> {
break;
}
QueueManager::WriteStdout(IpcId::TextDocumentRename, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentRenameHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentRename);
} // namespace

View File

@ -7,13 +7,14 @@
#include <stdint.h>
namespace {
struct Ipc_TextDocumentSignatureHelp
: public RequestMessage<Ipc_TextDocumentSignatureHelp> {
const static IpcId kIpcId = IpcId::TextDocumentSignatureHelp;
MethodType kMethodType = "textDocument/signatureHelp";
struct In_TextDocumentSignatureHelp : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentSignatureHelp, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentSignatureHelp);
MAKE_REFLECT_STRUCT(In_TextDocumentSignatureHelp, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentSignatureHelp);
// Represents a parameter of a callable-signature. A parameter can
// have a label and a doc-comment.
@ -82,11 +83,11 @@ struct Out_TextDocumentSignatureHelp
};
MAKE_REFLECT_STRUCT(Out_TextDocumentSignatureHelp, jsonrpc, id, result);
struct TextDocumentSignatureHelpHandler : MessageHandler {
IpcId GetId() const override { return IpcId::TextDocumentSignatureHelp; }
struct Handler_TextDocumentSignatureHelp : MessageHandler {
MethodType GetMethodType() const override { return kMethodType; }
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;
WorkingFile* file =
working_files->GetFileByFilename(params.textDocument.uri.GetPath());
@ -105,7 +106,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
[this](BaseIpcMessage* message, std::string search, int active_param,
const std::vector<lsCompletionItem>& results,
bool is_cached_result) {
auto msg = message->As<Ipc_TextDocumentSignatureHelp>();
auto msg = static_cast<In_TextDocumentSignatureHelp*>(message);
Out_TextDocumentSignatureHelp out;
out.id = msg->id;
@ -142,7 +143,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
out.result.activeParameter = active_param;
Timer timer;
QueueManager::WriteStdout(IpcId::TextDocumentSignatureHelp, out);
QueueManager::WriteStdout(kMethodType, out);
if (!is_cached_result) {
signature_cache->WithLock([&]() {
@ -168,5 +169,5 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
}
}
};
REGISTER_MESSAGE_HANDLER(TextDocumentSignatureHelpHandler);
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentSignatureHelp);
} // namespace

View File

@ -3,14 +3,14 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "textDocument/typeDefinition";
struct Ipc_TextDocumentTypeDefinition
: public RequestMessage<Ipc_TextDocumentTypeDefinition> {
const static IpcId kIpcId = IpcId::TextDocumentTypeDefinition;
struct In_TextDocumentTypeDefinition : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsTextDocumentPositionParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentTypeDefinition, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentTypeDefinition);
MAKE_REFLECT_STRUCT(In_TextDocumentTypeDefinition, id, params);
REGISTER_IN_MESSAGE(In_TextDocumentTypeDefinition);
struct Out_TextDocumentTypeDefinition
: public lsOutMessage<Out_TextDocumentTypeDefinition> {
@ -19,9 +19,10 @@ struct Out_TextDocumentTypeDefinition
};
MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result);
struct TextDocumentTypeDefinitionHandler
: BaseMessageHandler<Ipc_TextDocumentTypeDefinition> {
void Run(Ipc_TextDocumentTypeDefinition* request) override {
struct Handler_TextDocumentTypeDefinition
: BaseMessageHandler<In_TextDocumentTypeDefinition> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_TextDocumentTypeDefinition* request) override {
QueryFile* file;
if (!FindFileOrFail(db, project, request->id,
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

View File

@ -9,22 +9,24 @@
#include <loguru.hpp>
namespace {
MethodType kMethodType = "workspace/didChangeConfiguration";
struct lsDidChangeConfigurationParams {
bool placeholder;
};
MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder);
struct Ipc_WorkspaceDidChangeConfiguration
: public NotificationMessage<Ipc_WorkspaceDidChangeConfiguration> {
const static IpcId kIpcId = IpcId::WorkspaceDidChangeConfiguration;
struct In_WorkspaceDidChangeConfiguration : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsDidChangeConfigurationParams params;
};
MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeConfiguration, params);
REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeConfiguration);
MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeConfiguration, params);
REGISTER_IN_MESSAGE(In_WorkspaceDidChangeConfiguration);
struct WorkspaceDidChangeConfigurationHandler
: BaseMessageHandler<Ipc_WorkspaceDidChangeConfiguration> {
void Run(Ipc_WorkspaceDidChangeConfiguration* request) override {
struct Handler_WorkspaceDidChangeConfiguration
: BaseMessageHandler<In_WorkspaceDidChangeConfiguration> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_WorkspaceDidChangeConfiguration* request) override {
Timer time;
project->Load(config, config->projectRoot);
time.ResetAndPrint("[perf] Loaded compilation entries (" +
@ -40,5 +42,5 @@ struct WorkspaceDidChangeConfigurationHandler
LOG_S(INFO) << "Flushed all clang complete sessions";
}
};
REGISTER_MESSAGE_HANDLER(WorkspaceDidChangeConfigurationHandler);
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceDidChangeConfiguration);
} // namespace

View File

@ -8,6 +8,8 @@
#include <loguru/loguru.hpp>
namespace {
MethodType kMethodType = "workspace/didChangeWatchedFiles";
enum class lsFileChangeType {
Created = 1,
Changed = 2,
@ -26,17 +28,17 @@ struct lsDidChangeWatchedFilesParams {
};
MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes);
struct Ipc_WorkspaceDidChangeWatchedFiles
: public NotificationMessage<Ipc_WorkspaceDidChangeWatchedFiles> {
const static IpcId kIpcId = IpcId::WorkspaceDidChangeWatchedFiles;
struct In_WorkspaceDidChangeWatchedFiles : public NotificationMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsDidChangeWatchedFilesParams params;
};
MAKE_REFLECT_STRUCT(Ipc_WorkspaceDidChangeWatchedFiles, params);
REGISTER_IPC_MESSAGE(Ipc_WorkspaceDidChangeWatchedFiles);
MAKE_REFLECT_STRUCT(In_WorkspaceDidChangeWatchedFiles, params);
REGISTER_IN_MESSAGE(In_WorkspaceDidChangeWatchedFiles);
struct WorkspaceDidChangeWatchedFilesHandler
: BaseMessageHandler<Ipc_WorkspaceDidChangeWatchedFiles> {
void Run(Ipc_WorkspaceDidChangeWatchedFiles* request) override {
struct Handler_WorkspaceDidChangeWatchedFiles
: BaseMessageHandler<In_WorkspaceDidChangeWatchedFiles> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_WorkspaceDidChangeWatchedFiles* request) override {
for (lsFileEvent& event : request->params.changes) {
std::string path = event.uri.GetPath();
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

View File

@ -4,14 +4,14 @@
#include "queue_manager.h"
namespace {
MethodType kMethodType = "workspace/executeCommand";
struct Ipc_WorkspaceExecuteCommand
: public RequestMessage<Ipc_WorkspaceExecuteCommand> {
const static IpcId kIpcId = IpcId::WorkspaceExecuteCommand;
struct In_WorkspaceExecuteCommand : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
lsCommand<lsCodeLensCommandArguments> params;
};
MAKE_REFLECT_STRUCT(Ipc_WorkspaceExecuteCommand, id, params);
REGISTER_IPC_MESSAGE(Ipc_WorkspaceExecuteCommand);
MAKE_REFLECT_STRUCT(In_WorkspaceExecuteCommand, id, params);
REGISTER_IN_MESSAGE(In_WorkspaceExecuteCommand);
struct Out_WorkspaceExecuteCommand
: public lsOutMessage<Out_WorkspaceExecuteCommand> {
@ -28,9 +28,10 @@ void Reflect(Writer& visitor, Out_WorkspaceExecuteCommand& value) {
REFLECT_MEMBER_END();
}
struct WorkspaceExecuteCommandHandler
: BaseMessageHandler<Ipc_WorkspaceExecuteCommand> {
void Run(Ipc_WorkspaceExecuteCommand* request) override {
struct Handler_WorkspaceExecuteCommand
: BaseMessageHandler<In_WorkspaceExecuteCommand> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_WorkspaceExecuteCommand* request) override {
const auto& params = request->params;
Out_WorkspaceExecuteCommand out;
out.id = request->id;
@ -41,9 +42,9 @@ struct WorkspaceExecuteCommandHandler
out.result = params.arguments.locations;
}
QueueManager::WriteStdout(IpcId::WorkspaceExecuteCommand, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(WorkspaceExecuteCommandHandler);
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceExecuteCommand);
} // namespace

View File

@ -12,6 +12,7 @@
#include <functional>
namespace {
MethodType kMethodType = "workspace/symbol";
// Lookup |symbol| in |db| and insert the value into |result|.
bool InsertSymbolIntoResult(QueryDatabase* db,
@ -42,16 +43,16 @@ bool InsertSymbolIntoResult(QueryDatabase* db,
return true;
}
struct Ipc_WorkspaceSymbol : public RequestMessage<Ipc_WorkspaceSymbol> {
const static IpcId kIpcId = IpcId::WorkspaceSymbol;
struct In_WorkspaceSymbol : public RequestMessage {
MethodType GetMethodType() const override { return kMethodType; }
struct Params {
std::string query;
};
Params params;
};
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol::Params, query);
MAKE_REFLECT_STRUCT(Ipc_WorkspaceSymbol, id, params);
REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol);
MAKE_REFLECT_STRUCT(In_WorkspaceSymbol::Params, query);
MAKE_REFLECT_STRUCT(In_WorkspaceSymbol, id, params);
REGISTER_IN_MESSAGE(In_WorkspaceSymbol);
struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> {
lsRequestId id;
@ -61,8 +62,9 @@ MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result);
///// Fuzzy matching
struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
void Run(Ipc_WorkspaceSymbol* request) override {
struct Handler_WorkspaceSymbol : BaseMessageHandler<In_WorkspaceSymbol> {
MethodType GetMethodType() const override { return kMethodType; }
void Run(In_WorkspaceSymbol* request) override {
Out_WorkspaceSymbol out;
out.id = request->id;
@ -151,8 +153,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
LOG_S(INFO) << "[querydb] Found " << out.result.size()
<< " results for query " << query;
QueueManager::WriteStdout(IpcId::WorkspaceSymbol, out);
QueueManager::WriteStdout(kMethodType, out);
}
};
REGISTER_MESSAGE_HANDLER(WorkspaceSymbolHandler);
REGISTER_MESSAGE_HANDLER(Handler_WorkspaceSymbol);
} // namespace

View File

@ -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")

View File

@ -63,13 +63,13 @@ void QueueManager::Init(MultiQueueWaiter* querydb_waiter,
}
// static
void QueueManager::WriteStdout(IpcId id, lsBaseOutMessage& response) {
void QueueManager::WriteStdout(MethodType method, lsBaseOutMessage& response) {
std::ostringstream sstream;
response.Write(sstream);
Stdout_Request out;
out.content = sstream.str();
out.id = id;
out.method = method;
instance()->for_stdout.PushBack(std::move(out));
}

View File

@ -11,7 +11,7 @@ struct ICacheManager;
struct lsBaseOutMessage;
struct Stdout_Request {
IpcId id;
MethodType method;
std::string content;
};
@ -86,7 +86,7 @@ class QueueManager {
static void Init(MultiQueueWaiter* querydb_waiter,
MultiQueueWaiter* indexer_waiter,
MultiQueueWaiter* stdout_waiter);
static void WriteStdout(IpcId id, lsBaseOutMessage& response);
static void WriteStdout(MethodType method, lsBaseOutMessage& response);
bool HasWork();