Simplify GetDefinitionSpellingOfSymbol

This commit is contained in:
Fangrui Song 2018-02-13 12:15:31 -08:00
parent 273b670c0d
commit a1e1d115bf
3 changed files with 4 additions and 14 deletions

View File

@ -216,8 +216,8 @@ struct TextDocumentCodeLensHandler
// "Base"
if (func.def->base.size() == 1) {
Maybe<Use> base_loc =
GetDefinitionSpellingOfSymbol(db, func.def->base[0]);
Maybe<Use> base_loc = GetDefinitionSpellingOfSymbol(
db, SymbolIdx{func.def->base[0], SymbolKind::Func});
if (base_loc) {
optional<lsLocation> ls_base =
GetLsLocation(db, working_files, *base_loc);

View File

@ -18,14 +18,6 @@ int ComputeRangeSize(const Range& range) {
} // namespace
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
QueryFuncId id) {
QueryFunc& func = db->funcs[id.id];
if (func.def)
return func.def->spell;
return nullopt;
}
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
SymbolIdx sym) {
switch (sym.kind) {
@ -48,10 +40,10 @@ Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
break;
}
case SymbolKind::File:
case SymbolKind::Invalid: {
break;
case SymbolKind::Invalid:
assert(false && "unexpected");
break;
}
}
return nullopt;
}

View File

@ -7,8 +7,6 @@
#include <optional.h>
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
QueryFuncId id);
Maybe<Use> GetDefinitionSpellingOfSymbol(QueryDatabase* db,
SymbolIdx sym);
Maybe<Use> GetDefinitionExtentOfSymbol(QueryDatabase* db, SymbolIdx sym);