mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-21 23:25:07 +00:00
ipc.h -> method.h, rename some types
This commit is contained in:
parent
e37a6c814b
commit
2fc731c856
@ -17,7 +17,7 @@ add_executable(cquery "")
|
||||
### Compile options
|
||||
|
||||
# CMake default compile flags:
|
||||
# MSVC + Clang(Windows):
|
||||
# MSVC + Clang(Windows):
|
||||
# debug: /MDd /Zi /Ob0 /Od /RTC1
|
||||
# release: /MD /O2 /Ob2 /DNDEBUG
|
||||
# GCC + Clang(Linux):
|
||||
@ -32,15 +32,15 @@ set_property(TARGET cquery PROPERTY CXX_EXTENSIONS OFF)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
|
||||
# Common MSVC/Clang(Windows) options
|
||||
target_compile_options(cquery PRIVATE
|
||||
/nologo
|
||||
/EHsc
|
||||
target_compile_options(cquery PRIVATE
|
||||
/nologo
|
||||
/EHsc
|
||||
/W3 # roughly -Wall
|
||||
/wd4996 # disable loguru unsafe warnings
|
||||
/wd4722 # ignores warning C4722
|
||||
/wd4722 # ignores warning C4722
|
||||
# (destructor never returns) in loguru
|
||||
/wd4267 # ignores warning C4267
|
||||
# (conversion from 'size_t' to 'type'),
|
||||
/wd4267 # ignores warning C4267
|
||||
# (conversion from 'size_t' to 'type'),
|
||||
# roughly -Wno-sign-compare
|
||||
/wd4800
|
||||
$<$<CONFIG:Debug>:/FS>
|
||||
@ -48,8 +48,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
|
||||
else()
|
||||
# Common GCC/Clang(Linux) options
|
||||
target_compile_options(cquery PRIVATE
|
||||
-Wall
|
||||
-Wno-sign-compare
|
||||
-Wall
|
||||
-Wno-sign-compare
|
||||
)
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
||||
@ -57,14 +57,14 @@ else()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
||||
target_compile_options(cquery PRIVATE
|
||||
target_compile_options(cquery PRIVATE
|
||||
$<$<CONFIG:Debug>:-fno-limit-debug-info>)
|
||||
endif()
|
||||
|
||||
if(CLANG_CXX)
|
||||
# -Wno-comment: include/clang/Format/Format.h error: multi-line comment
|
||||
# -fno-rtti: # Without -fno-rtti, some Clang C++ functions may report
|
||||
# `undefined references to typeinfo`
|
||||
# `undefined references to typeinfo`
|
||||
target_compile_options(cquery PRIVATE -Wno-comment -fno-rtti)
|
||||
endif()
|
||||
|
||||
@ -148,21 +148,21 @@ install(TARGETS cquery RUNTIME DESTINATION bin)
|
||||
if(NOT SYSTEM_CLANG AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL Windows)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES Linux|FreeBSD)
|
||||
set_property(TARGET cquery APPEND PROPERTY
|
||||
set_property(TARGET cquery APPEND PROPERTY
|
||||
INSTALL_RPATH $ORIGIN/../lib)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
|
||||
set_property(TARGET cquery APPEND PROPERTY
|
||||
INSTALL_RPATH @loader_path/../lib)
|
||||
set_property(TARGET cquery APPEND PROPERTY
|
||||
INSTALL_RPATH @loader_path/../lib)
|
||||
endif()
|
||||
|
||||
file(GLOB LIBCLANG_PLUS_SYMLINKS
|
||||
file(GLOB LIBCLANG_PLUS_SYMLINKS
|
||||
${DOWNLOADED_CLANG_DIR}/lib/libclang.[so,dylib]*)
|
||||
install(FILES ${LIBCLANG_PLUS_SYMLINKS} DESTINATION lib)
|
||||
endif()
|
||||
|
||||
### Sources
|
||||
|
||||
target_sources(cquery PRIVATE third_party/siphash.cc)
|
||||
target_sources(cquery PRIVATE third_party/siphash.cc)
|
||||
|
||||
target_sources(cquery PRIVATE
|
||||
src/cache_manager.cc
|
||||
@ -183,7 +183,7 @@ target_sources(cquery PRIVATE
|
||||
src/import_manager.cc
|
||||
src/import_pipeline.cc
|
||||
src/include_complete.cc
|
||||
src/ipc.cc
|
||||
src/method.cc
|
||||
src/lex_utils.cc
|
||||
src/lsp_diagnostic.cc
|
||||
src/lsp.cc
|
||||
|
@ -137,7 +137,7 @@ bool QueryDbMainLoop(Config* config,
|
||||
CodeCompleteCache* non_global_code_complete_cache,
|
||||
CodeCompleteCache* signature_cache) {
|
||||
auto* queue = QueueManager::instance();
|
||||
std::vector<std::unique_ptr<BaseIpcMessage>> messages =
|
||||
std::vector<std::unique_ptr<InMessage>> messages =
|
||||
queue->for_querydb.DequeueAll();
|
||||
bool did_work = messages.size();
|
||||
for (auto& message : messages) {
|
||||
@ -281,7 +281,7 @@ void LaunchStdinLoop(Config* config,
|
||||
WorkThread::StartThread("stdin", [request_times]() {
|
||||
auto* queue = QueueManager::instance();
|
||||
while (true) {
|
||||
std::unique_ptr<BaseIpcMessage> message;
|
||||
std::unique_ptr<InMessage> message;
|
||||
optional<std::string> err =
|
||||
MessageRegistry::instance()->ReadMessageFromStdin(&message);
|
||||
|
||||
|
@ -123,7 +123,7 @@ optional<char> ReadCharFromStdinBlocking() {
|
||||
}
|
||||
|
||||
optional<std::string> MessageRegistry::ReadMessageFromStdin(
|
||||
std::unique_ptr<BaseIpcMessage>* message) {
|
||||
std::unique_ptr<InMessage>* message) {
|
||||
optional<std::string> content =
|
||||
ReadJsonRpcContentFrom(&ReadCharFromStdinBlocking);
|
||||
if (!content) {
|
||||
@ -141,7 +141,7 @@ optional<std::string> MessageRegistry::ReadMessageFromStdin(
|
||||
|
||||
optional<std::string> MessageRegistry::Parse(
|
||||
Reader& visitor,
|
||||
std::unique_ptr<BaseIpcMessage>* message) {
|
||||
std::unique_ptr<InMessage>* message) {
|
||||
if (!visitor.HasMember("jsonrpc") ||
|
||||
std::string(visitor["jsonrpc"]->GetString()) != "2.0") {
|
||||
LOG_S(FATAL) << "Bad or missing jsonrpc version";
|
||||
|
10
src/lsp.h
10
src/lsp.h
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "ipc.h"
|
||||
#include "method.h"
|
||||
#include "serializer.h"
|
||||
#include "utils.h"
|
||||
|
||||
@ -32,13 +32,13 @@ struct MessageRegistry {
|
||||
static MessageRegistry* instance();
|
||||
|
||||
using Allocator =
|
||||
std::function<void(Reader& visitor, std::unique_ptr<BaseIpcMessage>*)>;
|
||||
std::function<void(Reader& visitor, std::unique_ptr<InMessage>*)>;
|
||||
std::unordered_map<std::string, Allocator> allocators;
|
||||
|
||||
optional<std::string> ReadMessageFromStdin(
|
||||
std::unique_ptr<BaseIpcMessage>* message);
|
||||
std::unique_ptr<InMessage>* message);
|
||||
optional<std::string> Parse(Reader& visitor,
|
||||
std::unique_ptr<BaseIpcMessage>* message);
|
||||
std::unique_ptr<InMessage>* message);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -47,7 +47,7 @@ struct MessageRegistryRegister {
|
||||
T dummy;
|
||||
std::string method_name = dummy.GetMethodType();
|
||||
MessageRegistry::instance()->allocators[method_name] =
|
||||
[](Reader& visitor, std::unique_ptr<BaseIpcMessage>* message) {
|
||||
[](Reader& visitor, std::unique_ptr<InMessage>* message) {
|
||||
*message = std::make_unique<T>();
|
||||
// Reflect may throw and *message will be partially deserialized.
|
||||
Reflect(visitor, static_cast<T&>(**message));
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ipc.h"
|
||||
#include "lsp.h"
|
||||
#include "method.h"
|
||||
#include "query.h"
|
||||
|
||||
#include <optional.h>
|
||||
@ -87,7 +87,7 @@ struct MessageHandler {
|
||||
CodeCompleteCache* signature_cache = nullptr;
|
||||
|
||||
virtual MethodType GetMethodType() const = 0;
|
||||
virtual void Run(std::unique_ptr<BaseIpcMessage> message) = 0;
|
||||
virtual void Run(std::unique_ptr<InMessage> message) = 0;
|
||||
|
||||
static std::vector<MessageHandler*>* message_handlers;
|
||||
|
||||
@ -100,7 +100,7 @@ struct BaseMessageHandler : MessageHandler {
|
||||
virtual void Run(TMessage* message) = 0;
|
||||
|
||||
// MessageHandler:
|
||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||
void Run(std::unique_ptr<InMessage> message) override {
|
||||
Run(static_cast<TMessage*>(message.get()));
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ namespace {
|
||||
|
||||
MethodType kMethodType = "$cquery/base";
|
||||
|
||||
struct In_CqueryBase : public RequestMessage {
|
||||
struct In_CqueryBase : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
lsTextDocumentPositionParams params;
|
||||
|
@ -20,7 +20,7 @@ bool operator&(CallType lhs, CallType rhs) {
|
||||
return uint8_t(lhs) & uint8_t(rhs);
|
||||
}
|
||||
|
||||
struct In_CqueryCallHierarchy : public RequestMessage {
|
||||
struct In_CqueryCallHierarchy : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
struct Params {
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/callers";
|
||||
|
||||
struct In_CqueryCallers : public RequestMessage {
|
||||
struct In_CqueryCallers : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/derived";
|
||||
|
||||
struct In_CqueryDerived : public RequestMessage {
|
||||
struct In_CqueryDerived : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/textDocumentDidView";
|
||||
|
||||
struct In_CqueryTextDocumentDidView : public NotificationMessage {
|
||||
struct In_CqueryTextDocumentDidView : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
lsDocumentUri textDocumentUri;
|
||||
|
@ -10,7 +10,7 @@ struct lsDocumentSymbolParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
||||
|
||||
struct In_CqueryFileInfo : public RequestMessage {
|
||||
struct In_CqueryFileInfo : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDocumentSymbolParams params;
|
||||
};
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/freshenIndex";
|
||||
|
||||
struct In_CqueryFreshenIndex : public NotificationMessage {
|
||||
struct In_CqueryFreshenIndex : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
bool dependencies = true;
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/indexFile";
|
||||
|
||||
struct In_CqueryIndexFile : public NotificationMessage {
|
||||
struct In_CqueryIndexFile : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
std::string path;
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/inheritanceHierarchy";
|
||||
|
||||
struct In_CqueryInheritanceHierarchy : public RequestMessage {
|
||||
struct In_CqueryInheritanceHierarchy : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
// If id+kind are specified, expand a node; otherwise textDocument+position
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/memberHierarchy";
|
||||
|
||||
struct In_CqueryMemberHierarchy : public RequestMessage {
|
||||
struct In_CqueryMemberHierarchy : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
struct Params {
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/random";
|
||||
|
||||
struct In_CqueryRandom : public RequestMessage {
|
||||
struct In_CqueryRandom : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(In_CqueryRandom, id);
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/vars";
|
||||
|
||||
struct In_CqueryVars : public RequestMessage {
|
||||
struct In_CqueryVars : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
lsTextDocumentPositionParams params;
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "$cquery/wait";
|
||||
|
||||
struct In_CqueryWait : public NotificationMessage {
|
||||
struct In_CqueryWait : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
};
|
||||
MAKE_REFLECT_EMPTY_STRUCT(In_CqueryWait);
|
||||
@ -17,7 +17,7 @@ REGISTER_IN_MESSAGE(In_CqueryWait);
|
||||
struct Handler_CqueryWait : MessageHandler {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
||||
void Run(std::unique_ptr<InMessage> 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.
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <loguru.hpp>
|
||||
|
||||
namespace {
|
||||
struct In_Exit : public NotificationMessage {
|
||||
struct In_Exit : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType_Exit; }
|
||||
};
|
||||
MAKE_REFLECT_EMPTY_STRUCT(In_Exit);
|
||||
@ -12,7 +12,7 @@ REGISTER_IN_MESSAGE(In_Exit);
|
||||
struct Handler_Exit : MessageHandler {
|
||||
MethodType GetMethodType() const override { return kMethodType_Exit; }
|
||||
|
||||
void Run(std::unique_ptr<BaseIpcMessage> request) override {
|
||||
void Run(std::unique_ptr<InMessage> request) override {
|
||||
LOG_S(INFO) << "Exiting; got exit message";
|
||||
exit(0);
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ struct lsInitializeError {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsInitializeError, retry);
|
||||
|
||||
struct In_InitializeRequest : public RequestMessage {
|
||||
struct In_InitializeRequest : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
lsInitializeParams params;
|
||||
|
@ -4,7 +4,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "shutdown";
|
||||
|
||||
struct In_Shutdown : public RequestMessage {
|
||||
struct In_Shutdown : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(In_Shutdown, id);
|
||||
|
@ -257,7 +257,7 @@ optional<lsTextEdit> BuildAutoImplementForFunction(QueryDatabase* db,
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
struct In_TextDocumentCodeAction : public RequestMessage {
|
||||
struct In_TextDocumentCodeAction : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
// Contains additional diagnostic information about the context in which
|
||||
|
@ -13,7 +13,7 @@ struct lsDocumentCodeLensParams {
|
||||
MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument);
|
||||
|
||||
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
|
||||
struct In_TextDocumentCodeLens : public RequestMessage {
|
||||
struct In_TextDocumentCodeLens : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDocumentCodeLensParams params;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ struct lsCompletionParams : lsTextDocumentPositionParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsCompletionParams, textDocument, position, context);
|
||||
|
||||
struct In_TextDocumentComplete : public RequestMessage {
|
||||
struct In_TextDocumentComplete : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsCompletionParams params;
|
||||
};
|
||||
@ -219,7 +219,7 @@ void FilterAndSortCompletionResponse(
|
||||
struct Handler_TextDocumentCompletion : MessageHandler {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||
void Run(std::unique_ptr<InMessage> message) override {
|
||||
auto request = std::shared_ptr<In_TextDocumentComplete>(
|
||||
static_cast<In_TextDocumentComplete*>(message.release()));
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/definition";
|
||||
|
||||
struct In_TextDocumentDefinition : public RequestMessage {
|
||||
struct In_TextDocumentDefinition : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/didChange";
|
||||
|
||||
struct In_TextDocumentDidChange : public NotificationMessage {
|
||||
struct In_TextDocumentDidChange : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentDidChangeParams params;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/didClose";
|
||||
|
||||
struct In_TextDocumentDidClose : public NotificationMessage {
|
||||
struct In_TextDocumentDidClose : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
lsTextDocumentIdentifier textDocument;
|
||||
|
@ -13,7 +13,7 @@ namespace {
|
||||
MethodType kMethodType = "textDocument/didOpen";
|
||||
|
||||
// Open, view, change, close file
|
||||
struct In_TextDocumentDidOpen : public NotificationMessage {
|
||||
struct In_TextDocumentDidOpen : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
struct Params {
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/didSave";
|
||||
|
||||
struct In_TextDocumentDidSave : public NotificationMessage {
|
||||
struct In_TextDocumentDidSave : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
struct Params {
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/documentHighlight";
|
||||
|
||||
struct In_TextDocumentDocumentHighlight : public RequestMessage {
|
||||
struct In_TextDocumentDocumentHighlight : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/documentLink";
|
||||
|
||||
struct In_TextDocumentDocumentLink : public RequestMessage {
|
||||
struct In_TextDocumentDocumentLink : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
// The document to provide document links for.
|
||||
|
@ -10,7 +10,7 @@ struct lsDocumentSymbolParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
||||
|
||||
struct In_TextDocumentDocumentSymbol : public RequestMessage {
|
||||
struct In_TextDocumentDocumentSymbol : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDocumentSymbolParams params;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/formatting";
|
||||
|
||||
struct In_TextDocumentFormatting : public RequestMessage {
|
||||
struct In_TextDocumentFormatting : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
lsTextDocumentIdentifier textDocument;
|
||||
|
@ -42,7 +42,7 @@ std::pair<std::string_view, std::string_view> GetCommentsAndHover(
|
||||
return {"", ""};
|
||||
}
|
||||
|
||||
struct In_TextDocumentHover : public RequestMessage {
|
||||
struct In_TextDocumentHover : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
|
||||
range,
|
||||
options);
|
||||
|
||||
struct In_TextDocumentRangeFormatting : public RequestMessage {
|
||||
struct In_TextDocumentRangeFormatting : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentRangeFormattingParams params;
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/references";
|
||||
|
||||
struct In_TextDocumentReferences : public RequestMessage {
|
||||
struct In_TextDocumentReferences : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct lsReferenceContext {
|
||||
// Include the declaration of the current symbol.
|
||||
|
@ -48,7 +48,7 @@ lsWorkspaceEdit BuildWorkspaceEdit(QueryDatabase* db,
|
||||
return edit;
|
||||
}
|
||||
|
||||
struct In_TextDocumentRename : public RequestMessage {
|
||||
struct In_TextDocumentRename : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
// The document to format.
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/signatureHelp";
|
||||
|
||||
struct In_TextDocumentSignatureHelp : public RequestMessage {
|
||||
struct In_TextDocumentSignatureHelp : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
@ -86,7 +86,7 @@ MAKE_REFLECT_STRUCT(Out_TextDocumentSignatureHelp, jsonrpc, id, result);
|
||||
struct Handler_TextDocumentSignatureHelp : MessageHandler {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
void Run(std::unique_ptr<BaseIpcMessage> message) override {
|
||||
void Run(std::unique_ptr<InMessage> message) override {
|
||||
auto request = static_cast<In_TextDocumentSignatureHelp*>(message.get());
|
||||
lsTextDocumentPositionParams& params = request->params;
|
||||
WorkingFile* file =
|
||||
@ -103,7 +103,7 @@ struct Handler_TextDocumentSignatureHelp : MessageHandler {
|
||||
return;
|
||||
|
||||
ClangCompleteManager::OnComplete callback = std::bind(
|
||||
[this](BaseIpcMessage* message, std::string search, int active_param,
|
||||
[this](InMessage* message, std::string search, int active_param,
|
||||
const std::vector<lsCompletionItem>& results,
|
||||
bool is_cached_result) {
|
||||
auto msg = static_cast<In_TextDocumentSignatureHelp*>(message);
|
||||
|
@ -5,7 +5,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/typeDefinition";
|
||||
|
||||
struct In_TextDocumentTypeDefinition : public RequestMessage {
|
||||
struct In_TextDocumentTypeDefinition : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ struct lsDidChangeConfigurationParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDidChangeConfigurationParams, placeholder);
|
||||
|
||||
struct In_WorkspaceDidChangeConfiguration : public NotificationMessage {
|
||||
struct In_WorkspaceDidChangeConfiguration : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDidChangeConfigurationParams params;
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ struct lsDidChangeWatchedFilesParams {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDidChangeWatchedFilesParams, changes);
|
||||
|
||||
struct In_WorkspaceDidChangeWatchedFiles : public NotificationMessage {
|
||||
struct In_WorkspaceDidChangeWatchedFiles : public NotificationInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDidChangeWatchedFilesParams params;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace {
|
||||
MethodType kMethodType = "workspace/executeCommand";
|
||||
|
||||
struct In_WorkspaceExecuteCommand : public RequestMessage {
|
||||
struct In_WorkspaceExecuteCommand : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsCommand<lsCodeLensCommandArguments> params;
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ bool InsertSymbolIntoResult(QueryDatabase* db,
|
||||
return true;
|
||||
}
|
||||
|
||||
struct In_WorkspaceSymbol : public RequestMessage {
|
||||
struct In_WorkspaceSymbol : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
struct Params {
|
||||
std::string query;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "ipc.h"
|
||||
#include "method.h"
|
||||
|
||||
const char* kMethodType_Unknown = "$unknown";
|
||||
const char* kMethodType_Exit = "exit";
|
||||
@ -6,8 +6,12 @@ const char* kMethodType_TextDocumentPublishDiagnostics = "textDocument/publishDi
|
||||
const char* kMethodType_CqueryPublishInactiveRegions = "$cquery/publishInactiveRegions";
|
||||
const char* kMethodType_CqueryPublishSemanticHighlighting = "$cquery/publishSemanticHighlighting";
|
||||
|
||||
BaseIpcMessage::~BaseIpcMessage() = default;
|
||||
InMessage::~InMessage() = default;
|
||||
|
||||
lsRequestId BaseIpcMessage::GetRequestId() {
|
||||
return std::monostate();
|
||||
lsRequestId RequestInMessage::GetRequestId() const {
|
||||
return id;
|
||||
}
|
||||
|
||||
lsRequestId NotificationInMessage::GetRequestId() const {
|
||||
return std::monostate();
|
||||
}
|
@ -5,28 +5,29 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||
|
||||
using MethodType = std::string;
|
||||
|
||||
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 {
|
||||
virtual ~BaseIpcMessage();
|
||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||
|
||||
struct InMessage {
|
||||
virtual ~InMessage();
|
||||
|
||||
virtual MethodType GetMethodType() const = 0;
|
||||
virtual lsRequestId GetRequestId();
|
||||
virtual lsRequestId GetRequestId() const = 0;
|
||||
};
|
||||
|
||||
struct RequestMessage : public BaseIpcMessage {
|
||||
struct RequestInMessage : public InMessage {
|
||||
// number or string, actually no null
|
||||
lsRequestId id;
|
||||
lsRequestId GetRequestId() override { return id; }
|
||||
lsRequestId GetRequestId() const override;
|
||||
};
|
||||
|
||||
// NotificationMessage does not have |id|.
|
||||
struct NotificationMessage : public BaseIpcMessage {};
|
||||
// NotificationInMessage does not have |id|.
|
||||
struct NotificationInMessage : public InMessage {
|
||||
lsRequestId GetRequestId() const override;
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "method.h"
|
||||
|
||||
#include <optional.h>
|
||||
#include <sparsepp/spp.h>
|
||||
@ -11,8 +12,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// FIXME ipc.h
|
||||
using lsRequestId = std::variant<std::monostate, int64_t, std::string>;
|
||||
class QueueManager;
|
||||
struct WorkingFiles;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "ipc.h"
|
||||
#include "method.h"
|
||||
#include "performance.h"
|
||||
#include "query.h"
|
||||
#include "threaded_queue.h"
|
||||
@ -94,7 +94,7 @@ class QueueManager {
|
||||
ThreadedQueue<Stdout_Request> for_stdout;
|
||||
|
||||
// Runs on querydb thread.
|
||||
ThreadedQueue<std::unique_ptr<BaseIpcMessage>> for_querydb;
|
||||
ThreadedQueue<std::unique_ptr<InMessage>> for_querydb;
|
||||
ThreadedQueue<Index_DoIdMap> do_id_map;
|
||||
|
||||
// Runs on indexer threads.
|
||||
|
Loading…
Reference in New Issue
Block a user