mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
size_t Query*::symbol_idx -> Maybe<Id<void>>
This commit is contained in:
parent
3c6f3f661f
commit
ae999f9c92
@ -42,6 +42,8 @@ struct Id {
|
||||
|
||||
Id() : id(-1) {} // Needed for containers and Maybe<Id>. Do not use directly.
|
||||
explicit Id(size_t id) : id(id) {}
|
||||
template <typename U>
|
||||
explicit Id(Id<U> o) : id(o.id) {}
|
||||
|
||||
// Needed for google::dense_hash_map.
|
||||
explicit operator size_t() const { return id; }
|
||||
|
18
src/query.cc
18
src/query.cc
@ -795,8 +795,8 @@ void QueryDatabase::RemoveUsrs(SymbolKind usr_kind,
|
||||
case SymbolKind::Type: {
|
||||
for (const Usr& usr : to_remove) {
|
||||
QueryType& type = types[usr_to_type[usr].id];
|
||||
if (type.symbol_idx != size_t(-1))
|
||||
symbols[type.symbol_idx].kind = SymbolKind::Invalid;
|
||||
if (type.symbol_idx)
|
||||
symbols[type.symbol_idx->id].kind = SymbolKind::Invalid;
|
||||
type.def = nullopt;
|
||||
}
|
||||
break;
|
||||
@ -804,8 +804,8 @@ void QueryDatabase::RemoveUsrs(SymbolKind usr_kind,
|
||||
case SymbolKind::Func: {
|
||||
for (const Usr& usr : to_remove) {
|
||||
QueryFunc& func = funcs[usr_to_func[usr].id];
|
||||
if (func.symbol_idx != size_t(-1))
|
||||
symbols[func.symbol_idx].kind = SymbolKind::Invalid;
|
||||
if (func.symbol_idx)
|
||||
symbols[func.symbol_idx->id].kind = SymbolKind::Invalid;
|
||||
func.def = nullopt;
|
||||
}
|
||||
break;
|
||||
@ -813,8 +813,8 @@ void QueryDatabase::RemoveUsrs(SymbolKind usr_kind,
|
||||
case SymbolKind::Var: {
|
||||
for (const Usr& usr : to_remove) {
|
||||
QueryVar& var = vars[usr_to_var[usr].id];
|
||||
if (var.symbol_idx != size_t(-1))
|
||||
symbols[var.symbol_idx].kind = SymbolKind::Invalid;
|
||||
if (var.symbol_idx)
|
||||
symbols[var.symbol_idx->id].kind = SymbolKind::Invalid;
|
||||
var.def = nullopt;
|
||||
}
|
||||
break;
|
||||
@ -954,11 +954,11 @@ void QueryDatabase::ImportOrUpdate(
|
||||
}
|
||||
}
|
||||
|
||||
void QueryDatabase::UpdateSymbols(size_t* symbol_idx,
|
||||
void QueryDatabase::UpdateSymbols(Maybe<Id<void>>* symbol_idx,
|
||||
SymbolKind kind,
|
||||
size_t idx) {
|
||||
if (*symbol_idx == -1) {
|
||||
*symbol_idx = symbols.size();
|
||||
if (!symbol_idx->has_value()) {
|
||||
*symbol_idx = Id<void>(symbols.size());
|
||||
symbols.push_back(SymbolIdx(kind, idx));
|
||||
}
|
||||
}
|
||||
|
10
src/query.h
10
src/query.h
@ -213,7 +213,7 @@ struct QueryFile {
|
||||
using DefUpdate = WithFileContent<Def>;
|
||||
|
||||
optional<Def> def;
|
||||
size_t symbol_idx = (size_t)-1;
|
||||
Maybe<Id<void>> symbol_idx;
|
||||
|
||||
explicit QueryFile(const std::string& path) {
|
||||
def = Def();
|
||||
@ -243,7 +243,7 @@ struct QueryType {
|
||||
std::vector<QueryTypeId> derived;
|
||||
std::vector<QueryVarId> instances;
|
||||
std::vector<QueryLocation> uses;
|
||||
size_t symbol_idx = (size_t)-1;
|
||||
Maybe<Id<void>> symbol_idx;
|
||||
|
||||
explicit QueryType(const Usr& usr) : usr(usr) {}
|
||||
};
|
||||
@ -264,7 +264,7 @@ struct QueryFunc {
|
||||
std::vector<QueryLocation> declarations;
|
||||
std::vector<QueryFuncId> derived;
|
||||
std::vector<QueryFuncRef> callers;
|
||||
size_t symbol_idx = (size_t)-1;
|
||||
Maybe<Id<void>> symbol_idx;
|
||||
|
||||
explicit QueryFunc(const Usr& usr) : usr(usr) {}
|
||||
};
|
||||
@ -280,7 +280,7 @@ struct QueryVar {
|
||||
optional<Def> def;
|
||||
std::vector<QueryLocation> declarations;
|
||||
std::vector<QueryLocation> uses;
|
||||
size_t symbol_idx = (size_t)-1;
|
||||
Maybe<Id<void>> symbol_idx;
|
||||
|
||||
explicit QueryVar(const Usr& usr) : usr(usr) {}
|
||||
};
|
||||
@ -386,7 +386,7 @@ struct QueryDatabase {
|
||||
void ImportOrUpdate(const std::vector<QueryType::DefUpdate>& updates);
|
||||
void ImportOrUpdate(const std::vector<QueryFunc::DefUpdate>& updates);
|
||||
void ImportOrUpdate(const std::vector<QueryVar::DefUpdate>& updates);
|
||||
void UpdateSymbols(size_t* symbol_idx, SymbolKind kind, size_t idx);
|
||||
void UpdateSymbols(Maybe<Id<void>>* symbol_idx, SymbolKind kind, size_t idx);
|
||||
std::string_view GetSymbolDetailedName(size_t symbol_idx) const;
|
||||
std::string_view GetSymbolShortName(size_t symbol_idx) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user