From fdbb820d50c27897972512566ecd8f7090871a8e Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 12 Apr 2017 00:19:49 -0700 Subject: [PATCH] Fix outline and global search for pure virtual methods --- src/command_line.cc | 9 +++++++-- src/query.cc | 18 +++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 2c48b4b2..a3bf3239 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -1072,8 +1072,13 @@ void QueryDbMainLoop( if (db->qualified_names[i].find(query) != std::string::npos) { lsSymbolInformation info = GetSymbolInfo(db, working_files, db->symbols[i]); optional location = GetDefinitionExtentOfSymbol(db, db->symbols[i]); - if (!location) - continue; + if (!location) { + auto decls = GetDeclarationsOfSymbolForGotoDefinition(db, db->symbols[i]); + if (decls.empty()) + continue; + location = decls[0]; + } + optional ls_location = GetLsLocation(db, working_files, *location); if (!ls_location) continue; diff --git a/src/query.cc b/src/query.cc index 9de4e231..a1f8f792 100644 --- a/src/query.cc +++ b/src/query.cc @@ -93,8 +93,8 @@ QueryableFile::Def BuildFileDef(const IdMap& id_map, const IndexedFile& indexed) if (def.def.definition_extent.has_value()) add_outline(id_map.ToSymbol(def.id), def.def.definition_extent.value()); for (Range decl : def.declarations) { - add_outline(id_map.ToSymbol(def.id), decl); add_all_symbols(id_map.ToSymbol(def.id), decl); + add_outline(id_map.ToSymbol(def.id), decl); } for (const Range& use : def.uses) add_all_symbols(id_map.ToSymbol(def.id), use); @@ -599,7 +599,7 @@ void IndexUpdate::Merge(const IndexUpdate& update) { -void UpdateQualifiedName(QueryableDatabase* db, size_t* qualified_name_index, SymbolKind kind, size_t symbol_index, const std::string& name) { +void SetQualifiedNameForWorkspaceSearch(QueryableDatabase* db, size_t* qualified_name_index, SymbolKind kind, size_t symbol_index, const std::string& name) { if (*qualified_name_index == -1) { db->qualified_names.push_back(name); db->symbols.push_back(SymbolIdx(kind, symbol_index)); @@ -628,13 +628,13 @@ void QueryableDatabase::ImportOrUpdate(const std::vectorsecond.idx]; existing.def = def; - //UpdateQualifiedName(this, &existing.qualified_name_idx, SymbolKind::File, it->second.idx, def.usr); + //SetQualifiedNameForWorkspaceSearch(this, &existing.qualified_name_idx, SymbolKind::File, it->second.idx, def.usr); } } void QueryableDatabase::ImportOrUpdate(const std::vector& updates) { for (auto& def : updates) { - if (!def.definition_extent) + if (def.qualified_name.empty()) continue; auto it = usr_to_symbol.find(def.usr); @@ -642,13 +642,13 @@ void QueryableDatabase::ImportOrUpdate(const std::vectorsecond.idx]; existing.def = def; - UpdateQualifiedName(this, &existing.qualified_name_idx, SymbolKind::Type, it->second.idx, def.usr); + SetQualifiedNameForWorkspaceSearch(this, &existing.qualified_name_idx, SymbolKind::Type, it->second.idx, def.usr); } } void QueryableDatabase::ImportOrUpdate(const std::vector& updates) { for (auto& def : updates) { - if (!def.definition_extent) + if (def.qualified_name.empty()) continue; auto it = usr_to_symbol.find(def.usr); @@ -656,13 +656,13 @@ void QueryableDatabase::ImportOrUpdate(const std::vectorsecond.idx]; existing.def = def; - UpdateQualifiedName(this, &existing.qualified_name_idx, SymbolKind::Func, it->second.idx, def.usr); + SetQualifiedNameForWorkspaceSearch(this, &existing.qualified_name_idx, SymbolKind::Func, it->second.idx, def.usr); } } void QueryableDatabase::ImportOrUpdate(const std::vector& updates) { for (auto& def : updates) { - if (!def.definition_extent) + if (def.qualified_name.empty()) continue; auto it = usr_to_symbol.find(def.usr); @@ -671,7 +671,7 @@ void QueryableDatabase::ImportOrUpdate(const std::vectorsecond.idx]; existing.def = def; if (def.declaring_type) - UpdateQualifiedName(this, &existing.qualified_name_idx, SymbolKind::Var, it->second.idx, def.usr); + SetQualifiedNameForWorkspaceSearch(this, &existing.qualified_name_idx, SymbolKind::Var, it->second.idx, def.usr); } }