2017-12-05 07:57:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-12-29 16:29:47 +00:00
|
|
|
#include "ipc.h"
|
|
|
|
#include "language_server_api.h"
|
2017-12-05 07:57:41 +00:00
|
|
|
#include "query.h"
|
2017-12-29 16:29:47 +00:00
|
|
|
|
|
|
|
#include <optional.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct ClangCompleteManager;
|
|
|
|
struct CodeCompleteCache;
|
|
|
|
struct Config;
|
|
|
|
struct FileConsumerSharedState;
|
|
|
|
struct ImportManager;
|
|
|
|
struct ImportPipelineStatus;
|
|
|
|
struct IncludeComplete;
|
|
|
|
struct MultiQueueWaiter;
|
2018-01-06 21:40:33 +00:00
|
|
|
struct Project;
|
2017-12-29 16:29:47 +00:00
|
|
|
struct QueryDatabase;
|
|
|
|
struct SemanticHighlightSymbolCache;
|
|
|
|
struct TimestampManager;
|
|
|
|
struct WorkingFile;
|
|
|
|
struct WorkingFiles;
|
2017-12-05 07:57:41 +00:00
|
|
|
|
|
|
|
// Usage:
|
|
|
|
//
|
|
|
|
// struct FooHandler : MessageHandler {
|
|
|
|
// // ...
|
|
|
|
// };
|
|
|
|
// REGISTER_MESSAGE_HANDLER(FooHandler);
|
|
|
|
//
|
|
|
|
// Then there will be a global FooHandler instance in
|
|
|
|
// |MessageHandler::message_handlers|.
|
|
|
|
|
|
|
|
#define REGISTER_MESSAGE_HANDLER(type) \
|
|
|
|
static type type##message_handler_instance_;
|
|
|
|
|
|
|
|
struct MessageHandler {
|
|
|
|
Config* config = nullptr;
|
|
|
|
QueryDatabase* db = nullptr;
|
|
|
|
MultiQueueWaiter* waiter = nullptr;
|
|
|
|
Project* project = nullptr;
|
2017-12-29 16:29:47 +00:00
|
|
|
FileConsumerSharedState* file_consumer_shared = nullptr;
|
2017-12-05 07:57:41 +00:00
|
|
|
ImportManager* import_manager = nullptr;
|
2017-12-28 16:55:46 +00:00
|
|
|
ImportPipelineStatus* import_pipeline_status = nullptr;
|
2017-12-05 07:57:41 +00:00
|
|
|
TimestampManager* timestamp_manager = nullptr;
|
2017-12-06 03:32:33 +00:00
|
|
|
SemanticHighlightSymbolCache* semantic_cache = nullptr;
|
2017-12-05 07:57:41 +00:00
|
|
|
WorkingFiles* working_files = nullptr;
|
|
|
|
ClangCompleteManager* clang_complete = nullptr;
|
|
|
|
IncludeComplete* include_complete = nullptr;
|
|
|
|
CodeCompleteCache* global_code_complete_cache = nullptr;
|
|
|
|
CodeCompleteCache* non_global_code_complete_cache = nullptr;
|
|
|
|
CodeCompleteCache* signature_cache = nullptr;
|
|
|
|
|
|
|
|
virtual IpcId GetId() const = 0;
|
|
|
|
virtual void Run(std::unique_ptr<BaseIpcMessage> message) = 0;
|
|
|
|
|
|
|
|
static std::vector<MessageHandler*>* message_handlers;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MessageHandler();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename TMessage>
|
|
|
|
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>());
|
|
|
|
}
|
|
|
|
};
|
2017-12-06 03:32:33 +00:00
|
|
|
|
|
|
|
bool FindFileOrFail(QueryDatabase* db,
|
2018-01-06 21:40:33 +00:00
|
|
|
const Project* project,
|
2017-12-06 03:32:33 +00:00
|
|
|
optional<lsRequestId> id,
|
|
|
|
const std::string& absolute_path,
|
|
|
|
QueryFile** out_query_file,
|
|
|
|
QueryFileId* out_file_id = nullptr);
|
|
|
|
|
|
|
|
void EmitInactiveLines(WorkingFile* working_file,
|
|
|
|
const std::vector<Range>& inactive_regions);
|
|
|
|
|
|
|
|
void EmitSemanticHighlighting(QueryDatabase* db,
|
|
|
|
SemanticHighlightSymbolCache* semantic_cache,
|
|
|
|
WorkingFile* working_file,
|
2017-12-07 01:00:19 +00:00
|
|
|
QueryFile* file);
|
|
|
|
|
|
|
|
bool ShouldIgnoreFileForIndexing(const std::string& path);
|