mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
Add RemoveSymbol
This commit is contained in:
parent
28bdc0cf02
commit
2fb85732c0
29
src/query.cc
29
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;
|
||||
|
@ -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<QueryFileId> GetQueryFileIdFromPath(const std::string& path);
|
||||
|
Loading…
Reference in New Issue
Block a user