mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 00:55:08 +00:00
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
|
#include "message_handler.h"
|
||
|
#include "query_utils.h"
|
||
|
|
||
|
struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
||
|
void Run(Ipc_CqueryDerived* request) override {
|
||
|
QueryFile* file;
|
||
|
if (!FindFileOrFail(db, request->id,
|
||
|
request->params.textDocument.uri.GetPath(), &file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
WorkingFile* working_file =
|
||
|
working_files->GetFileByFilename(file->def->path);
|
||
|
|
||
|
Out_LocationList out;
|
||
|
out.id = request->id;
|
||
|
for (const SymbolRef& ref :
|
||
|
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||
|
if (ref.idx.kind == SymbolKind::Type) {
|
||
|
QueryType& type = db->types[ref.idx.idx];
|
||
|
std::vector<QueryLocation> locations =
|
||
|
ToQueryLocation(db, type.derived);
|
||
|
out.result = GetLsLocations(db, working_files, locations);
|
||
|
} else if (ref.idx.kind == SymbolKind::Func) {
|
||
|
QueryFunc& func = db->funcs[ref.idx.idx];
|
||
|
std::vector<QueryLocation> locations =
|
||
|
ToQueryLocation(db, func.derived);
|
||
|
out.result = GetLsLocations(db, working_files, locations);
|
||
|
}
|
||
|
}
|
||
|
IpcManager::WriteStdout(IpcId::CqueryDerived, out);
|
||
|
}
|
||
|
};
|
||
|
REGISTER_MESSAGE_HANDLER(CqueryDerivedHandler);
|