forked from MaskRay/ccls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.hh
84 lines (70 loc) · 2.13 KB
/
pipeline.hh
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
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "lsp.hh"
#include "query.hh"
#include <atomic>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
namespace ccls {
struct SemaManager;
struct GroupMatch;
struct Project;
struct WorkingFiles;
struct VFS {
struct State {
int64_t timestamp;
int step;
int loaded;
};
std::unordered_map<std::string, State> state;
std::mutex mutex;
void clear();
int loaded(const std::string &path);
bool stamp(const std::string &path, int64_t ts, int step);
};
enum class IndexMode {
Delete,
Background,
OnChange,
Normal,
};
struct IndexStats {
std::atomic<int64_t> last_idle, completed, enqueued;
};
namespace pipeline {
extern std::atomic<bool> g_quit;
extern std::atomic<int64_t> loaded_ts;
extern IndexStats stats;
extern int64_t tick;
void threadEnter();
void threadLeave();
void init();
void launchStdin();
void launchStdout();
void indexer_Main(SemaManager *manager, VFS *vfs, Project *project,
WorkingFiles *wfiles);
void mainLoop();
void standalone(const std::string &root);
void index(const std::string &path, const std::vector<const char *> &args,
IndexMode mode, bool must_exist, RequestId id = {});
void removeCache(const std::string &path);
std::optional<std::string> loadIndexedContent(const std::string &path);
void notifyOrRequest(const char *method, bool request,
const std::function<void(JsonWriter &)> &fn);
template <typename T> void notify(const char *method, T &result) {
notifyOrRequest(method, false, [&](JsonWriter &w) { reflect(w, result); });
}
template <typename T> void request(const char *method, T &result) {
notifyOrRequest(method, true, [&](JsonWriter &w) { reflect(w, result); });
}
void reply(const RequestId &id, const std::function<void(JsonWriter &)> &fn);
void replyError(const RequestId &id,
const std::function<void(JsonWriter &)> &fn);
template <typename T> void replyError(const RequestId &id, T &result) {
replyError(id, [&](JsonWriter &w) { reflect(w, result); });
}
} // namespace pipeline
} // namespace ccls