diff --git a/src/query.cc b/src/query.cc index 27a41c4d..ad6a7637 100644 --- a/src/query.cc +++ b/src/query.cc @@ -788,18 +788,27 @@ void QueryDatabase::RemoveUsrs(SymbolKind usr_kind, switch (usr_kind) { case SymbolKind::Type: { - for (const Usr& usr : to_remove) - types[usr_to_type[usr].id].def = nullopt; + for (const Usr& usr : to_remove) { + QueryType& type = types[usr_to_type[usr].id]; + RemoveSymbol(type.detailed_name_idx); + type.def = nullopt; + } break; } case SymbolKind::Func: { - for (const Usr& usr : to_remove) - funcs[usr_to_func[usr].id].def = nullopt; + for (const Usr& usr : to_remove) { + QueryFunc& func = funcs[usr_to_func[usr].id]; + RemoveSymbol(func.detailed_name_idx); + func.def = nullopt; + } break; } case SymbolKind::Var: { - for (const Usr& usr : to_remove) - vars[usr_to_var[usr].id].def = nullopt; + for (const Usr& usr : to_remove) { + QueryVar& var = vars[usr_to_var[usr].id]; + RemoveSymbol(var.detailed_name_idx); + var.def = nullopt; + } break; } case SymbolKind::File: @@ -956,6 +965,14 @@ void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index, } } +void QueryDatabase::RemoveSymbol(size_t idx) { + if (idx != size_t(-1)) { + symbols[idx].kind = SymbolKind::Invalid; + short_names[idx].clear(); + detailed_names[idx].clear(); + } +} + TEST_SUITE("query") { IndexUpdate GetDelta(IndexFile previous, IndexFile current) { QueryDatabase db; diff --git a/src/query.h b/src/query.h index daee2aff..1b2c8d8b 100644 --- a/src/query.h +++ b/src/query.h @@ -392,6 +392,7 @@ struct QueryDatabase { size_t symbol_index, const std::string& short_name, const std::string& detailed_name); + void RemoveSymbol(size_t idx); // Query the indexing structure to look up symbol id for given Usr. optional GetQueryFileIdFromPath(const std::string& path);