mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-23 16:15:07 +00:00
query: fix UpdateUses when a new entity is seen; simplify {DeclRef,Use,Usr}Update
Thanks to Leszek Swirski
This commit is contained in:
parent
cc11d30dad
commit
4416a258ae
@ -252,7 +252,7 @@ void DB::ApplyIndexUpdate(IndexUpdate *u) {
|
|||||||
auto &entities, auto &p, bool hint_implicit) {
|
auto &entities, auto &p, bool hint_implicit) {
|
||||||
auto R = entity_usr.try_emplace(usr, entity_usr.size());
|
auto R = entity_usr.try_emplace(usr, entity_usr.size());
|
||||||
if (R.second)
|
if (R.second)
|
||||||
vars.emplace_back().usr = usr;
|
entities.emplace_back().usr = usr;
|
||||||
auto &entity = entities[R.first->second];
|
auto &entity = entities[R.first->second];
|
||||||
for (Use &use : p.first) {
|
for (Use &use : p.first) {
|
||||||
if (hint_implicit && use.role & Role::Implicit) {
|
if (hint_implicit && use.role & Role::Implicit) {
|
||||||
|
28
src/query.hh
28
src/query.hh
@ -62,13 +62,9 @@ template <typename Q, typename QDef> struct QueryEntity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using DeclRefUpdate =
|
template <typename T>
|
||||||
std::unordered_map<Usr,
|
using Update =
|
||||||
std::pair<std::vector<DeclRef>, std::vector<DeclRef>>>;
|
std::unordered_map<Usr, std::pair<std::vector<T>, std::vector<T>>>;
|
||||||
using UseUpdate =
|
|
||||||
std::unordered_map<Usr, std::pair<std::vector<Use>, std::vector<Use>>>;
|
|
||||||
using UsrUpdate =
|
|
||||||
std::unordered_map<Usr, std::pair<std::vector<Usr>, std::vector<Usr>>>;
|
|
||||||
|
|
||||||
struct QueryFunc : QueryEntity<QueryFunc, FuncDef> {
|
struct QueryFunc : QueryEntity<QueryFunc, FuncDef> {
|
||||||
Usr usr;
|
Usr usr;
|
||||||
@ -115,25 +111,25 @@ struct IndexUpdate {
|
|||||||
int funcs_hint;
|
int funcs_hint;
|
||||||
std::vector<std::pair<Usr, QueryFunc::Def>> funcs_removed;
|
std::vector<std::pair<Usr, QueryFunc::Def>> funcs_removed;
|
||||||
std::vector<std::pair<Usr, QueryFunc::Def>> funcs_def_update;
|
std::vector<std::pair<Usr, QueryFunc::Def>> funcs_def_update;
|
||||||
DeclRefUpdate funcs_declarations;
|
Update<DeclRef> funcs_declarations;
|
||||||
UseUpdate funcs_uses;
|
Update<Use> funcs_uses;
|
||||||
UsrUpdate funcs_derived;
|
Update<Usr> funcs_derived;
|
||||||
|
|
||||||
// Type updates.
|
// Type updates.
|
||||||
int types_hint;
|
int types_hint;
|
||||||
std::vector<std::pair<Usr, QueryType::Def>> types_removed;
|
std::vector<std::pair<Usr, QueryType::Def>> types_removed;
|
||||||
std::vector<std::pair<Usr, QueryType::Def>> types_def_update;
|
std::vector<std::pair<Usr, QueryType::Def>> types_def_update;
|
||||||
DeclRefUpdate types_declarations;
|
Update<DeclRef> types_declarations;
|
||||||
UseUpdate types_uses;
|
Update<Use> types_uses;
|
||||||
UsrUpdate types_derived;
|
Update<Usr> types_derived;
|
||||||
UsrUpdate types_instances;
|
Update<Usr> types_instances;
|
||||||
|
|
||||||
// Variable updates.
|
// Variable updates.
|
||||||
int vars_hint;
|
int vars_hint;
|
||||||
std::vector<std::pair<Usr, QueryVar::Def>> vars_removed;
|
std::vector<std::pair<Usr, QueryVar::Def>> vars_removed;
|
||||||
std::vector<std::pair<Usr, QueryVar::Def>> vars_def_update;
|
std::vector<std::pair<Usr, QueryVar::Def>> vars_def_update;
|
||||||
DeclRefUpdate vars_declarations;
|
Update<DeclRef> vars_declarations;
|
||||||
UseUpdate vars_uses;
|
Update<Use> vars_uses;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DenseMapInfoForUsr {
|
struct DenseMapInfoForUsr {
|
||||||
|
Loading…
Reference in New Issue
Block a user