Browse Source

Fix 'Base' code lens on interface parent types

pull/2/head
Jacob Dufault 8 years ago
parent
commit
e32adb1786
  1. 14
      src/command_line.cc

14
src/command_line.cc

@ -190,10 +190,14 @@ std::vector<QueryableLocation> GetDeclarationsOfSymbolForGotoDefinition(Queryabl
return {}; return {};
} }
optional<QueryableLocation> GetBaseDefinitionSpelling(QueryableDatabase* db, QueryableFuncDef& func) { optional<QueryableLocation> GetBaseDefinitionOrDeclarationSpelling(QueryableDatabase* db, QueryableFuncDef& func) {
if (!func.def.base) if (!func.def.base)
return nullopt; return nullopt;
return db->funcs[func.def.base->id].def.definition_spelling; QueryableFuncDef& base = db->funcs[func.def.base->id];
auto def = base.def.definition_spelling;
if (!def && !base.declarations.empty())
def = base.declarations[0];
return def;
} }
std::vector<QueryFuncRef> GetCallersForAllBaseFunctions(QueryableDatabase* db, QueryableFuncDef& root) { std::vector<QueryFuncRef> GetCallersForAllBaseFunctions(QueryableDatabase* db, QueryableFuncDef& root) {
@ -1006,9 +1010,9 @@ void QueryDbMainLoop(
AddCodeLens(&common, ref.loc.OffsetStartColumn(offset++), ToQueryableLocation(db, func.derived), "derived", "derived"); AddCodeLens(&common, ref.loc.OffsetStartColumn(offset++), ToQueryableLocation(db, func.derived), "derived", "derived");
// "Base" // "Base"
optional<QueryableLocation> base_definition = GetBaseDefinitionSpelling(db, func); optional<QueryableLocation> base_loc = GetBaseDefinitionOrDeclarationSpelling(db, func);
if (base_definition) { if (base_loc) {
optional<lsLocation> ls_base = GetLsLocation(db, working_files, *base_definition); optional<lsLocation> ls_base = GetLsLocation(db, working_files, *base_loc);
if (ls_base) { if (ls_base) {
optional<lsRange> range = GetLsRange(common.working_file, ref.loc.range); optional<lsRange> range = GetLsRange(common.working_file, ref.loc.range);
if (range) { if (range) {

Loading…
Cancel
Save