Compute call location on client-side.

This commit is contained in:
Jacob Dufault 2018-01-07 11:18:07 -08:00
parent ce6087978f
commit 7f6f63b702

View File

@ -76,27 +76,6 @@ std::vector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
if (!root_func.def) if (!root_func.def)
return {}; return {};
auto format_location = [&](
const lsLocation& location,
optional<QueryTypeId> declaring_type) -> std::string {
std::string base;
if (declaring_type) {
QueryType type = db->types[declaring_type->id];
if (type.def)
base = type.def->detailed_name;
}
if (base.empty()) {
base = location.uri.GetPath();
size_t last_index = base.find_last_of('/');
if (last_index != std::string::npos)
base = base.substr(last_index + 1);
}
return base + ":" + std::to_string(location.range.start.line + 1);
};
std::vector<Out_CqueryCallTree::CallEntry> result; std::vector<Out_CqueryCallTree::CallEntry> result;
std::unordered_set<QueryLocation> seen_locations; std::unordered_set<QueryLocation> seen_locations;
@ -131,9 +110,7 @@ std::vector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
return; return;
Out_CqueryCallTree::CallEntry call_entry; Out_CqueryCallTree::CallEntry call_entry;
call_entry.name = call_entry.name = call_func.def->short_name;
call_func.def->short_name + " (" +
format_location(*call_location, call_func.def->declaring_type) + ")";
call_entry.usr = call_func.usr; call_entry.usr = call_func.usr;
call_entry.location = *call_location; call_entry.location = *call_location;
call_entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, call_func); call_entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, call_func);