From 0e8c9db44d456fd65920f4021f6cfcf61ef1399e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 20 Jul 2019 02:24:07 -0700 Subject: [PATCH] $ccls/fileInfo: optionally dump dependencies, includes and skipped_ranges --- src/message_handler.hh | 2 +- src/messages/ccls_info.cc | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/message_handler.hh b/src/message_handler.hh index 7043ac5b..e613df09 100644 --- a/src/message_handler.hh +++ b/src/message_handler.hh @@ -262,7 +262,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 &); diff --git a/src/messages/ccls_info.cc b/src/messages/ccls_info.cc index 9befa32f..e74866af 100644 --- a/src/messages/ccls_info.cc +++ b/src/messages/ccls_info.cc @@ -19,8 +19,9 @@ limitations under the License. #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 { @@ -53,7 +54,16 @@ void MessageHandler::ccls_info(EmptyParam &, ReplyOnce &reply) { reply(result); } -void MessageHandler::ccls_fileInfo(TextDocumentParam ¶m, 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; @@ -63,8 +73,12 @@ void MessageHandler::ccls_fileInfo(TextDocumentParam ¶m, 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