Caller Hiearchy shows lines of each reference in caller, not start line of caller

This commit is contained in:
Deok Koo Kim 2019-06-27 22:50:25 +09:00
parent cc7e0dde33
commit 787c06e26e

View File

@ -79,14 +79,14 @@ bool Expand(MessageHandler *m, Out_cclsCall *entry, bool callee,
entry->numChildren = 0; entry->numChildren = 0;
if (!def) if (!def)
return false; return false;
auto handle = [&](SymbolRef sym, int file_id, CallType call_type1) { auto handle = [&](SymbolRef sym, Use use, CallType call_type1) {
entry->numChildren++; entry->numChildren++;
if (levels > 0) { if (levels > 0) {
Out_cclsCall entry1; Out_cclsCall entry1;
entry1.id = std::to_string(sym.usr); entry1.id = std::to_string(sym.usr);
entry1.usr = sym.usr; entry1.usr = sym.usr;
if (auto loc = GetLsLocation(m->db, m->wfiles, if (auto loc = GetLsLocation(m->db, m->wfiles,
Use{{sym.range, sym.role}, file_id})) use))
entry1.location = *loc; entry1.location = *loc;
entry1.callType = call_type1; entry1.callType = call_type1;
if (Expand(m, &entry1, callee, call_type, qualified, levels - 1)) if (Expand(m, &entry1, callee, call_type, qualified, levels - 1))
@ -98,7 +98,7 @@ bool Expand(MessageHandler *m, Out_cclsCall *entry, bool callee,
if (const auto *def = func.AnyDef()) if (const auto *def = func.AnyDef())
for (SymbolRef sym : def->callees) for (SymbolRef sym : def->callees)
if (sym.kind == Kind::Func) if (sym.kind == Kind::Func)
handle(sym, def->file_id, call_type); handle(sym, Use{{sym.range, sym.role}, def->file_id}, call_type);
} else { } else {
for (Use use : func.uses) { for (Use use : func.uses) {
const QueryFile &file1 = m->db->files[use.file_id]; const QueryFile &file1 = m->db->files[use.file_id];
@ -110,7 +110,7 @@ bool Expand(MessageHandler *m, Out_cclsCall *entry, bool callee,
(!best || best->extent.start < sym.extent.start)) (!best || best->extent.start < sym.extent.start))
best = sym; best = sym;
if (best) if (best)
handle(*best, use.file_id, call_type); handle(*best, use, call_type);
} }
} }
}; };