mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21: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) {
|
switch (usr_kind) {
|
||||||
case SymbolKind::Type: {
|
case SymbolKind::Type: {
|
||||||
for (const Usr& usr : to_remove)
|
for (const Usr& usr : to_remove) {
|
||||||
types[usr_to_type[usr].id].def = nullopt;
|
QueryType& type = types[usr_to_type[usr].id];
|
||||||
|
RemoveSymbol(type.detailed_name_idx);
|
||||||
|
type.def = nullopt;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SymbolKind::Func: {
|
case SymbolKind::Func: {
|
||||||
for (const Usr& usr : to_remove)
|
for (const Usr& usr : to_remove) {
|
||||||
funcs[usr_to_func[usr].id].def = nullopt;
|
QueryFunc& func = funcs[usr_to_func[usr].id];
|
||||||
|
RemoveSymbol(func.detailed_name_idx);
|
||||||
|
func.def = nullopt;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SymbolKind::Var: {
|
case SymbolKind::Var: {
|
||||||
for (const Usr& usr : to_remove)
|
for (const Usr& usr : to_remove) {
|
||||||
vars[usr_to_var[usr].id].def = nullopt;
|
QueryVar& var = vars[usr_to_var[usr].id];
|
||||||
|
RemoveSymbol(var.detailed_name_idx);
|
||||||
|
var.def = nullopt;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SymbolKind::File:
|
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") {
|
TEST_SUITE("query") {
|
||||||
IndexUpdate GetDelta(IndexFile previous, IndexFile current) {
|
IndexUpdate GetDelta(IndexFile previous, IndexFile current) {
|
||||||
QueryDatabase db;
|
QueryDatabase db;
|
||||||
|
@ -392,6 +392,7 @@ struct QueryDatabase {
|
|||||||
size_t symbol_index,
|
size_t symbol_index,
|
||||||
const std::string& short_name,
|
const std::string& short_name,
|
||||||
const std::string& detailed_name);
|
const std::string& detailed_name);
|
||||||
|
void RemoveSymbol(size_t idx);
|
||||||
|
|
||||||
// Query the indexing structure to look up symbol id for given Usr.
|
// Query the indexing structure to look up symbol id for given Usr.
|
||||||
optional<QueryFileId> GetQueryFileIdFromPath(const std::string& path);
|
optional<QueryFileId> GetQueryFileIdFromPath(const std::string& path);
|
||||||
|
Loading…
Reference in New Issue
Block a user