forked from MaskRay/ccls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccls_info.cc
75 lines (68 loc) · 2.21 KB
/
ccls_info.cc
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
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#include "message_handler.hh"
#include "pipeline.hh"
#include "project.hh"
#include "query.hh"
namespace ccls {
REFLECT_STRUCT(IndexInclude, line, resolved_path);
REFLECT_STRUCT(QueryFile::Def, path, args, language, dependencies, includes,
skipped_ranges);
namespace {
struct Out_cclsInfo {
struct DB {
int files, funcs, types, vars;
} db;
struct Pipeline {
int64_t lastIdle, completed, enqueued;
} pipeline;
struct Project {
int entries;
} project;
};
REFLECT_STRUCT(Out_cclsInfo::DB, files, funcs, types, vars);
REFLECT_STRUCT(Out_cclsInfo::Pipeline, lastIdle, completed, enqueued);
REFLECT_STRUCT(Out_cclsInfo::Project, entries);
REFLECT_STRUCT(Out_cclsInfo, db, pipeline, project);
} // namespace
void MessageHandler::ccls_info(EmptyParam &, ReplyOnce &reply) {
Out_cclsInfo result;
result.db.files = db->files.size();
result.db.funcs = db->funcs.size();
result.db.types = db->types.size();
result.db.vars = db->vars.size();
result.pipeline.lastIdle = pipeline::stats.last_idle;
result.pipeline.completed = pipeline::stats.completed;
result.pipeline.enqueued = pipeline::stats.enqueued;
result.project.entries = 0;
for (auto &[_, folder] : project->root2folder)
result.project.entries += folder.entries.size();
reply(result);
}
struct FileInfoParam : TextDocumentParam {
bool dependencies = false;
bool includes = false;
bool skipped_ranges = false;
};
REFLECT_STRUCT(FileInfoParam, textDocument, dependencies, includes,
skipped_ranges);
void MessageHandler::ccls_fileInfo(JsonReader &reader, ReplyOnce &reply) {
FileInfoParam param;
reflect(reader, param);
QueryFile *file = findFile(param.textDocument.uri.getPath());
if (!file)
return;
QueryFile::Def result;
// Expose some fields of |QueryFile::Def|.
result.path = file->def->path;
result.args = file->def->args;
result.language = file->def->language;
if (param.dependencies)
result.dependencies = file->def->dependencies;
if (param.includes)
result.includes = file->def->includes;
if (param.skipped_ranges)
result.skipped_ranges = file->def->skipped_ranges;
reply(result);
}
} // namespace ccls