$ccls/fileInfo: optionally dump dependencies, includes and skipped_ranges

This commit is contained in:
Fangrui Song 2019-07-20 02:24:07 -07:00
parent 3dac492025
commit 86a93b2d71
2 changed files with 20 additions and 6 deletions

View File

@ -250,7 +250,7 @@ private:
void (MessageHandler::*handler)(Param &, ReplyOnce &));
void ccls_call(JsonReader &, ReplyOnce &);
void ccls_fileInfo(TextDocumentParam &, ReplyOnce &);
void ccls_fileInfo(JsonReader &, ReplyOnce &);
void ccls_info(EmptyParam &, ReplyOnce &);
void ccls_inheritance(JsonReader &, ReplyOnce &);
void ccls_member(JsonReader &, ReplyOnce &);

View File

@ -7,8 +7,9 @@
#include "query.hh"
namespace ccls {
REFLECT_STRUCT(QueryFile::Def, path, args, language, skipped_ranges,
dependencies);
REFLECT_STRUCT(IndexInclude, line, resolved_path);
REFLECT_STRUCT(QueryFile::Def, path, args, language, dependencies, includes,
skipped_ranges);
namespace {
struct Out_cclsInfo {
@ -41,7 +42,16 @@ void MessageHandler::ccls_info(EmptyParam &, ReplyOnce &reply) {
reply(result);
}
void MessageHandler::ccls_fileInfo(TextDocumentParam &param, ReplyOnce &reply) {
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;
@ -51,8 +61,12 @@ void MessageHandler::ccls_fileInfo(TextDocumentParam &param, ReplyOnce &reply) {
result.path = file->def->path;
result.args = file->def->args;
result.language = file->def->language;
result.includes = file->def->includes;
result.skipped_ranges = file->def->skipped_ranges;
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