#include "message_handler.h" #include "query_utils.h" #include "queue_manager.h" namespace { struct lsDocumentSymbolParams { lsTextDocumentIdentifier textDocument; }; MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument); struct Ipc_TextDocumentDocumentSymbol : public RequestMessage { const static IpcId kIpcId = IpcId::TextDocumentDocumentSymbol; lsDocumentSymbolParams params; }; MAKE_REFLECT_STRUCT(Ipc_TextDocumentDocumentSymbol, id, params); REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol); struct Out_TextDocumentDocumentSymbol : public lsOutMessage { lsRequestId id; std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result); struct TextDocumentDocumentSymbolHandler : BaseMessageHandler { void Run(Ipc_TextDocumentDocumentSymbol* request) override { Out_TextDocumentDocumentSymbol out; out.id = request->id; QueryFile* file; if (!FindFileOrFail(db, project, request->id, request->params.textDocument.uri.GetPath(), &file)) { return; } for (SymbolRef sym : file->def->outline) { optional info = GetSymbolInfo(db, working_files, sym, true /*use_short_name*/); if (!info) continue; optional location = GetLsLocation(db, working_files, sym); if (!location) continue; info->location = *location; out.result.push_back(*info); } QueueManager::WriteStdout(IpcId::TextDocumentDocumentSymbol, out); } }; REGISTER_MESSAGE_HANDLER(TextDocumentDocumentSymbolHandler); } // namespace