mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Add $cquery/fileInfo
This commit is contained in:
parent
afe86ef146
commit
5bbd3f4a29
@ -331,6 +331,7 @@ void LaunchStdinLoop(Config* config,
|
|||||||
case IpcId::TextDocumentCodeLens:
|
case IpcId::TextDocumentCodeLens:
|
||||||
case IpcId::WorkspaceDidChangeWatchedFiles:
|
case IpcId::WorkspaceDidChangeWatchedFiles:
|
||||||
case IpcId::WorkspaceSymbol:
|
case IpcId::WorkspaceSymbol:
|
||||||
|
case IpcId::CqueryFileInfo:
|
||||||
case IpcId::CqueryFreshenIndex:
|
case IpcId::CqueryFreshenIndex:
|
||||||
case IpcId::CqueryTypeHierarchyTree:
|
case IpcId::CqueryTypeHierarchyTree:
|
||||||
case IpcId::CqueryCallTreeInitial:
|
case IpcId::CqueryCallTreeInitial:
|
||||||
|
@ -66,6 +66,8 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
case IpcId::CqueryPublishSemanticHighlighting:
|
case IpcId::CqueryPublishSemanticHighlighting:
|
||||||
return "$cquery/publishSemanticHighlighting";
|
return "$cquery/publishSemanticHighlighting";
|
||||||
|
|
||||||
|
case IpcId::CqueryFileInfo:
|
||||||
|
return "$cquery/fileInfo";
|
||||||
case IpcId::CqueryFreshenIndex:
|
case IpcId::CqueryFreshenIndex:
|
||||||
return "$cquery/freshenIndex";
|
return "$cquery/freshenIndex";
|
||||||
case IpcId::CqueryTypeHierarchyTree:
|
case IpcId::CqueryTypeHierarchyTree:
|
||||||
|
@ -45,6 +45,7 @@ enum class IpcId : int {
|
|||||||
CqueryPublishSemanticHighlighting,
|
CqueryPublishSemanticHighlighting,
|
||||||
|
|
||||||
// Custom messages
|
// Custom messages
|
||||||
|
CqueryFileInfo,
|
||||||
CqueryFreshenIndex,
|
CqueryFreshenIndex,
|
||||||
// Messages used in tree views.
|
// Messages used in tree views.
|
||||||
CqueryTypeHierarchyTree,
|
CqueryTypeHierarchyTree,
|
||||||
|
44
src/messages/cquery_file_info.cc
Normal file
44
src/messages/cquery_file_info.cc
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include "message_handler.h"
|
||||||
|
#include "query_utils.h"
|
||||||
|
#include "queue_manager.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
struct lsDocumentSymbolParams {
|
||||||
|
lsTextDocumentIdentifier textDocument;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument);
|
||||||
|
|
||||||
|
struct Ipc_CqueryFileInfo : public RequestMessage<Ipc_CqueryFileInfo> {
|
||||||
|
const static IpcId kIpcId = IpcId::CqueryFileInfo;
|
||||||
|
lsDocumentSymbolParams params;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(Ipc_CqueryFileInfo, id, params);
|
||||||
|
REGISTER_IPC_MESSAGE(Ipc_CqueryFileInfo);
|
||||||
|
|
||||||
|
struct Out_CqueryFileInfo : public lsOutMessage<Out_CqueryFileInfo> {
|
||||||
|
lsRequestId id;
|
||||||
|
QueryFile::Def result;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(Out_CqueryFileInfo, jsonrpc, id, result);
|
||||||
|
|
||||||
|
struct CqueryFileInfoHandler : BaseMessageHandler<Ipc_CqueryFileInfo> {
|
||||||
|
void Run(Ipc_CqueryFileInfo* request) override {
|
||||||
|
QueryFile* file;
|
||||||
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Out_CqueryFileInfo out;
|
||||||
|
out.id = request->id;
|
||||||
|
// Expose some fields of |QueryFile::Def|.
|
||||||
|
out.result.path = file->def->path;
|
||||||
|
out.result.args = file->def->args;
|
||||||
|
out.result.language = file->def->language;
|
||||||
|
out.result.includes = file->def->includes;
|
||||||
|
out.result.inactive_regions = file->def->inactive_regions;
|
||||||
|
QueueManager::WriteStdout(IpcId::CqueryFileInfo, out);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
REGISTER_MESSAGE_HANDLER(CqueryFileInfoHandler);
|
||||||
|
} // namespace
|
@ -211,6 +211,7 @@ void CompareGroups(std::vector<T>& previous_data,
|
|||||||
QueryFile::DefUpdate BuildFileDefUpdate(const IdMap& id_map, const IndexFile& indexed) {
|
QueryFile::DefUpdate BuildFileDefUpdate(const IdMap& id_map, const IndexFile& indexed) {
|
||||||
QueryFile::Def def;
|
QueryFile::Def def;
|
||||||
def.path = indexed.path;
|
def.path = indexed.path;
|
||||||
|
def.args = indexed.args;
|
||||||
def.includes = indexed.includes;
|
def.includes = indexed.includes;
|
||||||
def.inactive_regions = indexed.skipped_by_preprocessor;
|
def.inactive_regions = indexed.skipped_by_preprocessor;
|
||||||
def.dependencies = indexed.dependencies;
|
def.dependencies = indexed.dependencies;
|
||||||
|
@ -96,6 +96,7 @@ struct QueryFamily {
|
|||||||
struct QueryFile {
|
struct QueryFile {
|
||||||
struct Def {
|
struct Def {
|
||||||
std::string path;
|
std::string path;
|
||||||
|
std::vector<std::string> args;
|
||||||
// Language identifier
|
// Language identifier
|
||||||
std::string language;
|
std::string language;
|
||||||
// Includes in the file.
|
// Includes in the file.
|
||||||
@ -122,6 +123,7 @@ struct QueryFile {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(QueryFile::Def,
|
MAKE_REFLECT_STRUCT(QueryFile::Def,
|
||||||
path,
|
path,
|
||||||
|
args,
|
||||||
language,
|
language,
|
||||||
outline,
|
outline,
|
||||||
all_symbols,
|
all_symbols,
|
||||||
|
Loading…
Reference in New Issue
Block a user