forked from jacobdufault/cquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_handler.h
122 lines (105 loc) · 3.52 KB
/
message_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#include "ipc.h"
#include "lsp.h"
#include "query.h"
#include <optional.h>
#include <memory>
#include <vector>
struct ClangCompleteManager;
struct CodeCompleteCache;
struct Config;
struct FileConsumerSharedState;
struct ImportManager;
struct ImportPipelineStatus;
struct IncludeComplete;
struct MultiQueueWaiter;
struct Project;
struct QueryDatabase;
struct SemanticHighlightSymbolCache;
struct TimestampManager;
struct WorkingFile;
struct WorkingFiles;
struct Out_CqueryPublishSemanticHighlighting
: public lsOutMessage<Out_CqueryPublishSemanticHighlighting> {
struct Symbol {
int stableId = 0;
SymbolKind parentKind;
lsSymbolKind kind;
StorageClass storage;
std::vector<lsRange> ranges;
};
struct Params {
lsDocumentUri uri;
std::vector<Symbol> symbols;
};
std::string method = "$cquery/publishSemanticHighlighting";
Params params;
};
MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting::Symbol,
stableId,
parentKind,
kind,
storage,
ranges);
MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting::Params,
uri,
symbols);
MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting,
jsonrpc,
method,
params);
// 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;
FileConsumerSharedState* file_consumer_shared = nullptr;
ImportManager* import_manager = nullptr;
ImportPipelineStatus* import_pipeline_status = nullptr;
TimestampManager* timestamp_manager = nullptr;
SemanticHighlightSymbolCache* semantic_cache = nullptr;
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>());
}
};
bool FindFileOrFail(QueryDatabase* db,
const Project* project,
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,
QueryFile* file);
bool ShouldIgnoreFileForIndexing(const std::string& path);