From e32adb178666bf0b8b938e3a7ebce027d1788f58 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Tue, 11 Apr 2017 23:30:31 -0700 Subject: [PATCH] Fix 'Base' code lens on interface parent types --- src/command_line.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index dacc2a05..49178d63 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -190,10 +190,14 @@ std::vector GetDeclarationsOfSymbolForGotoDefinition(Queryabl return {}; } -optional GetBaseDefinitionSpelling(QueryableDatabase* db, QueryableFuncDef& func) { +optional GetBaseDefinitionOrDeclarationSpelling(QueryableDatabase* db, QueryableFuncDef& func) { if (!func.def.base) 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 GetCallersForAllBaseFunctions(QueryableDatabase* db, QueryableFuncDef& root) { @@ -1006,9 +1010,9 @@ void QueryDbMainLoop( AddCodeLens(&common, ref.loc.OffsetStartColumn(offset++), ToQueryableLocation(db, func.derived), "derived", "derived"); // "Base" - optional base_definition = GetBaseDefinitionSpelling(db, func); - if (base_definition) { - optional ls_base = GetLsLocation(db, working_files, *base_definition); + optional base_loc = GetBaseDefinitionOrDeclarationSpelling(db, func); + if (base_loc) { + optional ls_base = GetLsLocation(db, working_files, *base_loc); if (ls_base) { optional range = GetLsRange(common.working_file, ref.loc.range); if (range) {