mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Move usr out of *Def and into Query*/Index* types.
I'd like to make the *Def structures optional in the future, and usr is always non-optional.
This commit is contained in:
parent
2751f51956
commit
9b909b3a13
@ -443,7 +443,7 @@ std::string IndexFile::ToString() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IndexType::IndexType(IndexTypeId id, const std::string& usr)
|
IndexType::IndexType(IndexTypeId id, const std::string& usr)
|
||||||
: def(usr), id(id) {
|
: usr(usr), id(id) {
|
||||||
assert(usr.size() > 0);
|
assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,6 @@ inline void Reflect(Writer& visitor, IndexFuncRef& value) {
|
|||||||
template <typename TypeId, typename FuncId, typename VarId, typename Range>
|
template <typename TypeId, typename FuncId, typename VarId, typename Range>
|
||||||
struct TypeDefDefinitionData {
|
struct TypeDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
|
||||||
std::string short_name;
|
std::string short_name;
|
||||||
std::string detailed_name;
|
std::string detailed_name;
|
||||||
|
|
||||||
@ -175,12 +174,9 @@ struct TypeDefDefinitionData {
|
|||||||
std::vector<FuncId> funcs;
|
std::vector<FuncId> funcs;
|
||||||
std::vector<VarId> vars;
|
std::vector<VarId> vars;
|
||||||
|
|
||||||
TypeDefDefinitionData() {} // For reflection.
|
|
||||||
TypeDefDefinitionData(const std::string& usr) : usr(usr) {}
|
|
||||||
|
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const TypeDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
const TypeDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
||||||
return usr == other.usr && short_name == other.short_name &&
|
return short_name == other.short_name &&
|
||||||
detailed_name == other.detailed_name &&
|
detailed_name == other.detailed_name &&
|
||||||
definition_spelling == other.definition_spelling &&
|
definition_spelling == other.definition_spelling &&
|
||||||
definition_extent == other.definition_extent &&
|
definition_extent == other.definition_extent &&
|
||||||
@ -201,7 +197,6 @@ template <typename TVisitor,
|
|||||||
void Reflect(TVisitor& visitor,
|
void Reflect(TVisitor& visitor,
|
||||||
TypeDefDefinitionData<TypeId, FuncId, VarId, Range>& value) {
|
TypeDefDefinitionData<TypeId, FuncId, VarId, Range>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
REFLECT_MEMBER(detailed_name);
|
REFLECT_MEMBER(detailed_name);
|
||||||
REFLECT_MEMBER(definition_spelling);
|
REFLECT_MEMBER(definition_spelling);
|
||||||
@ -217,10 +212,12 @@ void Reflect(TVisitor& visitor,
|
|||||||
struct IndexType {
|
struct IndexType {
|
||||||
using Def =
|
using Def =
|
||||||
TypeDefDefinitionData<IndexTypeId, IndexFuncId, IndexVarId, Range>;
|
TypeDefDefinitionData<IndexTypeId, IndexFuncId, IndexVarId, Range>;
|
||||||
Def def;
|
|
||||||
|
|
||||||
|
std::string usr;
|
||||||
IndexTypeId id;
|
IndexTypeId id;
|
||||||
|
|
||||||
|
Def def;
|
||||||
|
|
||||||
// Immediate derived types.
|
// Immediate derived types.
|
||||||
std::vector<IndexTypeId> derived;
|
std::vector<IndexTypeId> derived;
|
||||||
|
|
||||||
@ -231,16 +228,12 @@ struct IndexType {
|
|||||||
// NOTE: Do not insert directly! Use AddUsage instead.
|
// NOTE: Do not insert directly! Use AddUsage instead.
|
||||||
std::vector<Range> uses;
|
std::vector<Range> uses;
|
||||||
|
|
||||||
IndexType() : def("") {} // For serialization
|
IndexType() {} // For serialization.
|
||||||
|
|
||||||
IndexType(IndexTypeId id, const std::string& usr);
|
IndexType(IndexTypeId id, const std::string& usr);
|
||||||
|
|
||||||
bool operator<(const IndexType& other) const {
|
bool operator<(const IndexType& other) const { return id < other.id; }
|
||||||
return def.usr < other.def.usr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
MAKE_HASHABLE(IndexType, t.id);
|
||||||
MAKE_HASHABLE(IndexType, t.def.usr);
|
|
||||||
|
|
||||||
template <typename TypeId,
|
template <typename TypeId,
|
||||||
typename FuncId,
|
typename FuncId,
|
||||||
@ -249,7 +242,6 @@ template <typename TypeId,
|
|||||||
typename Range>
|
typename Range>
|
||||||
struct FuncDefDefinitionData {
|
struct FuncDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
|
||||||
std::string short_name;
|
std::string short_name;
|
||||||
std::string detailed_name;
|
std::string detailed_name;
|
||||||
optional<Range> definition_spelling;
|
optional<Range> definition_spelling;
|
||||||
@ -270,15 +262,10 @@ struct FuncDefDefinitionData {
|
|||||||
// Used for semantic highlighting
|
// Used for semantic highlighting
|
||||||
bool is_operator = false;
|
bool is_operator = false;
|
||||||
|
|
||||||
FuncDefDefinitionData() {} // For reflection.
|
|
||||||
FuncDefDefinitionData(const std::string& usr) : usr(usr) {
|
|
||||||
// assert(usr.size() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Range>& other)
|
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Range>& other)
|
||||||
const {
|
const {
|
||||||
return usr == other.usr && short_name == other.short_name &&
|
return short_name == other.short_name &&
|
||||||
detailed_name == other.detailed_name &&
|
detailed_name == other.detailed_name &&
|
||||||
definition_spelling == other.definition_spelling &&
|
definition_spelling == other.definition_spelling &&
|
||||||
definition_extent == other.definition_extent &&
|
definition_extent == other.definition_extent &&
|
||||||
@ -302,7 +289,6 @@ void Reflect(
|
|||||||
TVisitor& visitor,
|
TVisitor& visitor,
|
||||||
FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Range>& value) {
|
FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Range>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
REFLECT_MEMBER(detailed_name);
|
REFLECT_MEMBER(detailed_name);
|
||||||
REFLECT_MEMBER(definition_spelling);
|
REFLECT_MEMBER(definition_spelling);
|
||||||
@ -321,10 +307,12 @@ struct IndexFunc {
|
|||||||
IndexVarId,
|
IndexVarId,
|
||||||
IndexFuncRef,
|
IndexFuncRef,
|
||||||
Range>;
|
Range>;
|
||||||
Def def;
|
|
||||||
|
|
||||||
|
std::string usr;
|
||||||
IndexFuncId id;
|
IndexFuncId id;
|
||||||
|
|
||||||
|
Def def;
|
||||||
|
|
||||||
struct Declaration {
|
struct Declaration {
|
||||||
// Range of only the function name.
|
// Range of only the function name.
|
||||||
Range spelling;
|
Range spelling;
|
||||||
@ -349,16 +337,14 @@ struct IndexFunc {
|
|||||||
// def.definition_spelling.
|
// def.definition_spelling.
|
||||||
std::vector<IndexFuncRef> callers;
|
std::vector<IndexFuncRef> callers;
|
||||||
|
|
||||||
IndexFunc() {} // For reflection.
|
IndexFunc() {} // For serialization.
|
||||||
IndexFunc(IndexFuncId id, const std::string& usr) : def(usr), id(id) {
|
IndexFunc(IndexFuncId id, const std::string& usr) : usr(usr), id(id) {
|
||||||
// assert(usr.size() > 0);
|
// assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const IndexFunc& other) const {
|
bool operator<(const IndexFunc& other) const { return id < other.id; }
|
||||||
return def.usr < other.def.usr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
MAKE_HASHABLE(IndexFunc, t.def.usr);
|
MAKE_HASHABLE(IndexFunc, t.id);
|
||||||
MAKE_REFLECT_STRUCT(IndexFunc::Declaration,
|
MAKE_REFLECT_STRUCT(IndexFunc::Declaration,
|
||||||
spelling,
|
spelling,
|
||||||
extent,
|
extent,
|
||||||
@ -368,7 +354,6 @@ MAKE_REFLECT_STRUCT(IndexFunc::Declaration,
|
|||||||
template <typename TypeId, typename FuncId, typename VarId, typename Range>
|
template <typename TypeId, typename FuncId, typename VarId, typename Range>
|
||||||
struct VarDefDefinitionData {
|
struct VarDefDefinitionData {
|
||||||
// General metadata.
|
// General metadata.
|
||||||
std::string usr;
|
|
||||||
std::string short_name;
|
std::string short_name;
|
||||||
std::string detailed_name;
|
std::string detailed_name;
|
||||||
optional<Range> declaration;
|
optional<Range> declaration;
|
||||||
@ -388,12 +373,9 @@ struct VarDefDefinitionData {
|
|||||||
// Is this a macro, ie, #define FOO?
|
// Is this a macro, ie, #define FOO?
|
||||||
bool is_macro = false;
|
bool is_macro = false;
|
||||||
|
|
||||||
VarDefDefinitionData() {} // For reflection.
|
|
||||||
VarDefDefinitionData(const std::string& usr) : usr(usr) {}
|
|
||||||
|
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const VarDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
const VarDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
||||||
return usr == other.usr && short_name == other.short_name &&
|
return short_name == other.short_name &&
|
||||||
detailed_name == other.detailed_name &&
|
detailed_name == other.detailed_name &&
|
||||||
declaration == other.declaration &&
|
declaration == other.declaration &&
|
||||||
definition_spelling == other.definition_spelling &&
|
definition_spelling == other.definition_spelling &&
|
||||||
@ -415,7 +397,6 @@ template <typename TVisitor,
|
|||||||
void Reflect(TVisitor& visitor,
|
void Reflect(TVisitor& visitor,
|
||||||
VarDefDefinitionData<TypeId, FuncId, VarId, Range>& value) {
|
VarDefDefinitionData<TypeId, FuncId, VarId, Range>& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER(usr);
|
|
||||||
REFLECT_MEMBER(short_name);
|
REFLECT_MEMBER(short_name);
|
||||||
REFLECT_MEMBER(detailed_name);
|
REFLECT_MEMBER(detailed_name);
|
||||||
REFLECT_MEMBER(definition_spelling);
|
REFLECT_MEMBER(definition_spelling);
|
||||||
@ -429,24 +410,23 @@ void Reflect(TVisitor& visitor,
|
|||||||
|
|
||||||
struct IndexVar {
|
struct IndexVar {
|
||||||
using Def = VarDefDefinitionData<IndexTypeId, IndexFuncId, IndexVarId, Range>;
|
using Def = VarDefDefinitionData<IndexTypeId, IndexFuncId, IndexVarId, Range>;
|
||||||
Def def;
|
|
||||||
|
|
||||||
|
std::string usr;
|
||||||
IndexVarId id;
|
IndexVarId id;
|
||||||
|
|
||||||
|
Def def;
|
||||||
|
|
||||||
// Usages.
|
// Usages.
|
||||||
std::vector<Range> uses;
|
std::vector<Range> uses;
|
||||||
|
|
||||||
IndexVar() : def("") {} // For serialization
|
IndexVar() {} // For serialization.
|
||||||
|
IndexVar(IndexVarId id, const std::string& usr) : usr(usr), id(id) {
|
||||||
IndexVar(IndexVarId id, const std::string& usr) : def(usr), id(id) {
|
|
||||||
// assert(usr.size() > 0);
|
// assert(usr.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const IndexVar& other) const {
|
bool operator<(const IndexVar& other) const { return id < other.id; }
|
||||||
return def.usr < other.def.usr;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
MAKE_HASHABLE(IndexVar, t.def.usr);
|
MAKE_HASHABLE(IndexVar, t.id);
|
||||||
|
|
||||||
struct IdCache {
|
struct IdCache {
|
||||||
std::string primary_file;
|
std::string primary_file;
|
||||||
|
@ -59,7 +59,7 @@ std::vector<Out_CqueryCallTree::CallEntry> BuildInitialCallTree(
|
|||||||
|
|
||||||
Out_CqueryCallTree::CallEntry entry;
|
Out_CqueryCallTree::CallEntry entry;
|
||||||
entry.name = root_func.def->short_name;
|
entry.name = root_func.def->short_name;
|
||||||
entry.usr = root_func.def->usr;
|
entry.usr = root_func.usr;
|
||||||
entry.location = *def_loc;
|
entry.location = *def_loc;
|
||||||
entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, root_func);
|
entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, root_func);
|
||||||
std::vector<Out_CqueryCallTree::CallEntry> result;
|
std::vector<Out_CqueryCallTree::CallEntry> result;
|
||||||
@ -133,7 +133,7 @@ std::vector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
|
|||||||
call_entry.name =
|
call_entry.name =
|
||||||
call_func.def->short_name + " (" +
|
call_func.def->short_name + " (" +
|
||||||
format_location(*call_location, call_func.def->declaring_type) + ")";
|
format_location(*call_location, call_func.def->declaring_type) + ")";
|
||||||
call_entry.usr = call_func.def->usr;
|
call_entry.usr = call_func.usr;
|
||||||
call_entry.location = *call_location;
|
call_entry.location = *call_location;
|
||||||
call_entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, call_func);
|
call_entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, call_func);
|
||||||
call_entry.callType = call_type;
|
call_entry.callType = call_type;
|
||||||
|
128
src/query.cc
128
src/query.cc
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
optional<QueryType::DefUpdate> ToQuery(const IdMap& id_map,
|
optional<QueryType::Def> ToQuery(const IdMap& id_map,
|
||||||
const IndexType::Def& type) {
|
const IndexType::Def& type) {
|
||||||
if (type.detailed_name.empty())
|
if (type.detailed_name.empty())
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
QueryType::DefUpdate result(type.usr);
|
QueryType::Def result;
|
||||||
result.short_name = type.short_name;
|
result.short_name = type.short_name;
|
||||||
result.detailed_name = type.detailed_name;
|
result.detailed_name = type.detailed_name;
|
||||||
result.definition_spelling = id_map.ToQuery(type.definition_spelling);
|
result.definition_spelling = id_map.ToQuery(type.definition_spelling);
|
||||||
@ -36,12 +36,12 @@ optional<QueryType::DefUpdate> ToQuery(const IdMap& id_map,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<QueryFunc::DefUpdate> ToQuery(const IdMap& id_map,
|
optional<QueryFunc::Def> ToQuery(const IdMap& id_map,
|
||||||
const IndexFunc::Def& func) {
|
const IndexFunc::Def& func) {
|
||||||
if (func.detailed_name.empty())
|
if (func.detailed_name.empty())
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
QueryFunc::DefUpdate result(func.usr);
|
QueryFunc::Def result;
|
||||||
result.short_name = func.short_name;
|
result.short_name = func.short_name;
|
||||||
result.detailed_name = func.detailed_name;
|
result.detailed_name = func.detailed_name;
|
||||||
result.definition_spelling = id_map.ToQuery(func.definition_spelling);
|
result.definition_spelling = id_map.ToQuery(func.definition_spelling);
|
||||||
@ -54,12 +54,11 @@ optional<QueryFunc::DefUpdate> ToQuery(const IdMap& id_map,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<QueryVar::DefUpdate> ToQuery(const IdMap& id_map,
|
optional<QueryVar::Def> ToQuery(const IdMap& id_map, const IndexVar::Def& var) {
|
||||||
const IndexVar::Def& var) {
|
|
||||||
if (var.detailed_name.empty())
|
if (var.detailed_name.empty())
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
||||||
QueryVar::DefUpdate result(var.usr);
|
QueryVar::Def result;
|
||||||
result.short_name = var.short_name;
|
result.short_name = var.short_name;
|
||||||
result.detailed_name = var.detailed_name;
|
result.detailed_name = var.detailed_name;
|
||||||
result.declaration = id_map.ToQuery(var.declaration);
|
result.declaration = id_map.ToQuery(var.declaration);
|
||||||
@ -137,14 +136,14 @@ void CompareGroups(std::vector<T>& previous_data,
|
|||||||
auto curr_it = current_data.begin();
|
auto curr_it = current_data.begin();
|
||||||
while (prev_it != previous_data.end() && curr_it != current_data.end()) {
|
while (prev_it != previous_data.end() && curr_it != current_data.end()) {
|
||||||
// same id
|
// same id
|
||||||
if (prev_it->def.usr == curr_it->def.usr) {
|
if (prev_it->usr == curr_it->usr) {
|
||||||
on_found(&*prev_it, &*curr_it);
|
on_found(&*prev_it, &*curr_it);
|
||||||
++prev_it;
|
++prev_it;
|
||||||
++curr_it;
|
++curr_it;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prev_id is smaller - prev_it has data curr_it does not have.
|
// prev_id is smaller - prev_it has data curr_it does not have.
|
||||||
else if (prev_it->def.usr < curr_it->def.usr) {
|
else if (prev_it->usr < curr_it->usr) {
|
||||||
on_removed(&*prev_it);
|
on_removed(&*prev_it);
|
||||||
++prev_it;
|
++prev_it;
|
||||||
}
|
}
|
||||||
@ -439,13 +438,13 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
{ \
|
{ \
|
||||||
/* Check for changes. */ \
|
/* Check for changes. */ \
|
||||||
std::vector<type> removed, added; \
|
std::vector<type> removed, added; \
|
||||||
auto previous = previous_id_map.ToQuery(previous_def->index_name); \
|
auto query_previous = previous_id_map.ToQuery(previous->index_name); \
|
||||||
auto current = current_id_map.ToQuery(current_def->index_name); \
|
auto query_current = current_id_map.ToQuery(current->index_name); \
|
||||||
bool did_add = \
|
bool did_add = ComputeDifferenceForUpdate(query_previous, query_current, \
|
||||||
ComputeDifferenceForUpdate(previous, current, &removed, &added); \
|
&removed, &added); \
|
||||||
if (did_add) { \
|
if (did_add) { \
|
||||||
query_name.push_back(MergeableUpdate<type_id, type>( \
|
query_name.push_back(MergeableUpdate<type_id, type>( \
|
||||||
current_id_map.ToQuery(current_def->id), added, removed)); \
|
current_id_map.ToQuery(current->id), added, removed)); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
// File
|
// File
|
||||||
@ -462,7 +461,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
/*onRemoved:*/
|
/*onRemoved:*/
|
||||||
[this, &previous_id_map](IndexType* type) {
|
[this, &previous_id_map](IndexType* type) {
|
||||||
if (type->def.definition_spelling)
|
if (type->def.definition_spelling)
|
||||||
types_removed.push_back(type->def.usr);
|
types_removed.push_back(type->usr);
|
||||||
else {
|
else {
|
||||||
if (!type->derived.empty())
|
if (!type->derived.empty())
|
||||||
types_derived.push_back(QueryType::DerivedUpdate(
|
types_derived.push_back(QueryType::DerivedUpdate(
|
||||||
@ -480,10 +479,11 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
},
|
},
|
||||||
/*onAdded:*/
|
/*onAdded:*/
|
||||||
[this, ¤t_id_map](IndexType* type) {
|
[this, ¤t_id_map](IndexType* type) {
|
||||||
optional<QueryType::DefUpdate> def_update =
|
optional<QueryType::Def> def_update =
|
||||||
ToQuery(current_id_map, type->def);
|
ToQuery(current_id_map, type->def);
|
||||||
if (def_update)
|
if (def_update)
|
||||||
types_def_update.push_back(*def_update);
|
types_def_update.push_back(
|
||||||
|
QueryType::DefUpdate(type->usr, *def_update));
|
||||||
if (!type->derived.empty())
|
if (!type->derived.empty())
|
||||||
types_derived.push_back(
|
types_derived.push_back(
|
||||||
QueryType::DerivedUpdate(current_id_map.ToQuery(type->id),
|
QueryType::DerivedUpdate(current_id_map.ToQuery(type->id),
|
||||||
@ -498,16 +498,18 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
current_id_map.ToQuery(type->uses)));
|
current_id_map.ToQuery(type->uses)));
|
||||||
},
|
},
|
||||||
/*onFound:*/
|
/*onFound:*/
|
||||||
[this, &previous_id_map, ¤t_id_map](IndexType* previous_def,
|
[this, &previous_id_map, ¤t_id_map](IndexType* previous,
|
||||||
IndexType* current_def) {
|
IndexType* current) {
|
||||||
optional<QueryType::DefUpdate> previous_remapped_def =
|
optional<QueryType::Def> previous_remapped_def =
|
||||||
ToQuery(previous_id_map, previous_def->def);
|
ToQuery(previous_id_map, previous->def);
|
||||||
optional<QueryType::DefUpdate> current_remapped_def =
|
optional<QueryType::Def> current_remapped_def =
|
||||||
ToQuery(current_id_map, current_def->def);
|
ToQuery(current_id_map, current->def);
|
||||||
if (current_remapped_def &&
|
if (current_remapped_def &&
|
||||||
previous_remapped_def != current_remapped_def &&
|
previous_remapped_def != current_remapped_def &&
|
||||||
!current_remapped_def->detailed_name.empty())
|
!current_remapped_def->detailed_name.empty()) {
|
||||||
types_def_update.push_back(*current_remapped_def);
|
types_def_update.push_back(
|
||||||
|
QueryType::DefUpdate(current->usr, *current_remapped_def));
|
||||||
|
}
|
||||||
|
|
||||||
PROCESS_UPDATE_DIFF(QueryTypeId, types_derived, derived, QueryTypeId);
|
PROCESS_UPDATE_DIFF(QueryTypeId, types_derived, derived, QueryTypeId);
|
||||||
PROCESS_UPDATE_DIFF(QueryTypeId, types_instances, instances,
|
PROCESS_UPDATE_DIFF(QueryTypeId, types_instances, instances,
|
||||||
@ -521,7 +523,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
/*onRemoved:*/
|
/*onRemoved:*/
|
||||||
[this, &previous_id_map](IndexFunc* func) {
|
[this, &previous_id_map](IndexFunc* func) {
|
||||||
if (func->def.definition_spelling) {
|
if (func->def.definition_spelling) {
|
||||||
funcs_removed.push_back(func->def.usr);
|
funcs_removed.push_back(func->usr);
|
||||||
} else {
|
} else {
|
||||||
if (!func->declarations.empty())
|
if (!func->declarations.empty())
|
||||||
funcs_declarations.push_back(QueryFunc::DeclarationsUpdate(
|
funcs_declarations.push_back(QueryFunc::DeclarationsUpdate(
|
||||||
@ -539,10 +541,11 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
},
|
},
|
||||||
/*onAdded:*/
|
/*onAdded:*/
|
||||||
[this, ¤t_id_map](IndexFunc* func) {
|
[this, ¤t_id_map](IndexFunc* func) {
|
||||||
optional<QueryFunc::DefUpdate> def_update =
|
optional<QueryFunc::Def> def_update =
|
||||||
ToQuery(current_id_map, func->def);
|
ToQuery(current_id_map, func->def);
|
||||||
if (def_update)
|
if (def_update)
|
||||||
funcs_def_update.push_back(*def_update);
|
funcs_def_update.push_back(
|
||||||
|
QueryFunc::DefUpdate(func->usr, *def_update));
|
||||||
if (!func->declarations.empty())
|
if (!func->declarations.empty())
|
||||||
funcs_declarations.push_back(QueryFunc::DeclarationsUpdate(
|
funcs_declarations.push_back(QueryFunc::DeclarationsUpdate(
|
||||||
current_id_map.ToQuery(func->id),
|
current_id_map.ToQuery(func->id),
|
||||||
@ -557,16 +560,18 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
current_id_map.ToQuery(func->callers)));
|
current_id_map.ToQuery(func->callers)));
|
||||||
},
|
},
|
||||||
/*onFound:*/
|
/*onFound:*/
|
||||||
[this, &previous_id_map, ¤t_id_map](IndexFunc* previous_def,
|
[this, &previous_id_map, ¤t_id_map](IndexFunc* previous,
|
||||||
IndexFunc* current_def) {
|
IndexFunc* current) {
|
||||||
optional<QueryFunc::DefUpdate> previous_remapped_def =
|
optional<QueryFunc::Def> previous_remapped_def =
|
||||||
ToQuery(previous_id_map, previous_def->def);
|
ToQuery(previous_id_map, previous->def);
|
||||||
optional<QueryFunc::DefUpdate> current_remapped_def =
|
optional<QueryFunc::Def> current_remapped_def =
|
||||||
ToQuery(current_id_map, current_def->def);
|
ToQuery(current_id_map, current->def);
|
||||||
if (current_remapped_def &&
|
if (current_remapped_def &&
|
||||||
previous_remapped_def != current_remapped_def &&
|
previous_remapped_def != current_remapped_def &&
|
||||||
!current_remapped_def->detailed_name.empty())
|
!current_remapped_def->detailed_name.empty()) {
|
||||||
funcs_def_update.push_back(*current_remapped_def);
|
funcs_def_update.push_back(
|
||||||
|
QueryFunc::DefUpdate(current->usr, *current_remapped_def));
|
||||||
|
}
|
||||||
|
|
||||||
PROCESS_UPDATE_DIFF(QueryFuncId, funcs_declarations, declarations,
|
PROCESS_UPDATE_DIFF(QueryFuncId, funcs_declarations, declarations,
|
||||||
QueryLocation);
|
QueryLocation);
|
||||||
@ -580,7 +585,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
/*onRemoved:*/
|
/*onRemoved:*/
|
||||||
[this, &previous_id_map](IndexVar* var) {
|
[this, &previous_id_map](IndexVar* var) {
|
||||||
if (var->def.definition_spelling) {
|
if (var->def.definition_spelling) {
|
||||||
vars_removed.push_back(var->def.usr);
|
vars_removed.push_back(var->usr);
|
||||||
} else {
|
} else {
|
||||||
if (!var->uses.empty())
|
if (!var->uses.empty())
|
||||||
vars_uses.push_back(
|
vars_uses.push_back(
|
||||||
@ -590,26 +595,26 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
},
|
},
|
||||||
/*onAdded:*/
|
/*onAdded:*/
|
||||||
[this, ¤t_id_map](IndexVar* var) {
|
[this, ¤t_id_map](IndexVar* var) {
|
||||||
optional<QueryVar::DefUpdate> def_update =
|
optional<QueryVar::Def> def_update = ToQuery(current_id_map, var->def);
|
||||||
ToQuery(current_id_map, var->def);
|
|
||||||
if (def_update)
|
if (def_update)
|
||||||
vars_def_update.push_back(*def_update);
|
vars_def_update.push_back(QueryVar::DefUpdate(var->usr, *def_update));
|
||||||
if (!var->uses.empty())
|
if (!var->uses.empty())
|
||||||
vars_uses.push_back(
|
vars_uses.push_back(
|
||||||
QueryVar::UsesUpdate(current_id_map.ToQuery(var->id),
|
QueryVar::UsesUpdate(current_id_map.ToQuery(var->id),
|
||||||
current_id_map.ToQuery(var->uses)));
|
current_id_map.ToQuery(var->uses)));
|
||||||
},
|
},
|
||||||
/*onFound:*/
|
/*onFound:*/
|
||||||
[this, &previous_id_map, ¤t_id_map](IndexVar* previous_def,
|
[this, &previous_id_map, ¤t_id_map](IndexVar* previous,
|
||||||
IndexVar* current_def) {
|
IndexVar* current) {
|
||||||
optional<QueryVar::DefUpdate> previous_remapped_def =
|
optional<QueryVar::Def> previous_remapped_def =
|
||||||
ToQuery(previous_id_map, previous_def->def);
|
ToQuery(previous_id_map, previous->def);
|
||||||
optional<QueryVar::DefUpdate> current_remapped_def =
|
optional<QueryVar::Def> current_remapped_def =
|
||||||
ToQuery(current_id_map, current_def->def);
|
ToQuery(current_id_map, current->def);
|
||||||
if (current_remapped_def &&
|
if (current_remapped_def &&
|
||||||
previous_remapped_def != current_remapped_def &&
|
previous_remapped_def != current_remapped_def &&
|
||||||
!current_remapped_def->detailed_name.empty())
|
!current_remapped_def->detailed_name.empty())
|
||||||
vars_def_update.push_back(*current_remapped_def);
|
vars_def_update.push_back(
|
||||||
|
QueryVar::DefUpdate(current->usr, *current_remapped_def));
|
||||||
|
|
||||||
PROCESS_UPDATE_DIFF(QueryVarId, vars_uses, uses, QueryLocation);
|
PROCESS_UPDATE_DIFF(QueryVarId, vars_uses, uses, QueryLocation);
|
||||||
});
|
});
|
||||||
@ -619,7 +624,6 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map,
|
|||||||
|
|
||||||
// This function runs on an indexer thread.
|
// This function runs on an indexer thread.
|
||||||
void IndexUpdate::Merge(const IndexUpdate& update) {
|
void IndexUpdate::Merge(const IndexUpdate& update) {
|
||||||
|
|
||||||
#define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name);
|
#define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name);
|
||||||
#define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name);
|
#define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name);
|
||||||
|
|
||||||
@ -757,7 +761,7 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
// This function runs on the querydb thread.
|
// This function runs on the querydb thread.
|
||||||
|
|
||||||
for (auto& def : updates) {
|
for (auto& def : updates) {
|
||||||
assert(!def.detailed_name.empty());
|
assert(!def.value.detailed_name.empty());
|
||||||
|
|
||||||
auto it = usr_to_type.find(def.usr);
|
auto it = usr_to_type.find(def.usr);
|
||||||
assert(it != usr_to_type.end());
|
assert(it != usr_to_type.end());
|
||||||
@ -767,12 +771,12 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
|
|
||||||
// Keep the existing definition if it is higher quality.
|
// Keep the existing definition if it is higher quality.
|
||||||
if (existing.def && existing.def->definition_spelling &&
|
if (existing.def && existing.def->definition_spelling &&
|
||||||
!def.definition_spelling)
|
!def.value.definition_spelling)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
existing.def = def;
|
existing.def = def.value;
|
||||||
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Type,
|
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Type,
|
||||||
it->second.id, def.detailed_name);
|
it->second.id, def.value.detailed_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,7 +785,7 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
// This function runs on the querydb thread.
|
// This function runs on the querydb thread.
|
||||||
|
|
||||||
for (auto& def : updates) {
|
for (auto& def : updates) {
|
||||||
assert(!def.detailed_name.empty());
|
assert(!def.value.detailed_name.empty());
|
||||||
|
|
||||||
auto it = usr_to_func.find(def.usr);
|
auto it = usr_to_func.find(def.usr);
|
||||||
assert(it != usr_to_func.end());
|
assert(it != usr_to_func.end());
|
||||||
@ -791,12 +795,12 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
|
|
||||||
// Keep the existing definition if it is higher quality.
|
// Keep the existing definition if it is higher quality.
|
||||||
if (existing.def && existing.def->definition_spelling &&
|
if (existing.def && existing.def->definition_spelling &&
|
||||||
!def.definition_spelling)
|
!def.value.definition_spelling)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
existing.def = def;
|
existing.def = def.value;
|
||||||
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Func,
|
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Func,
|
||||||
it->second.id, def.detailed_name);
|
it->second.id, def.value.detailed_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,7 +809,7 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
// This function runs on the querydb thread.
|
// This function runs on the querydb thread.
|
||||||
|
|
||||||
for (auto& def : updates) {
|
for (auto& def : updates) {
|
||||||
assert(!def.detailed_name.empty());
|
assert(!def.value.detailed_name.empty());
|
||||||
|
|
||||||
auto it = usr_to_var.find(def.usr);
|
auto it = usr_to_var.find(def.usr);
|
||||||
assert(it != usr_to_var.end());
|
assert(it != usr_to_var.end());
|
||||||
@ -815,13 +819,13 @@ void QueryDatabase::ImportOrUpdate(
|
|||||||
|
|
||||||
// Keep the existing definition if it is higher quality.
|
// Keep the existing definition if it is higher quality.
|
||||||
if (existing.def && existing.def->definition_spelling &&
|
if (existing.def && existing.def->definition_spelling &&
|
||||||
!def.definition_spelling)
|
!def.value.definition_spelling)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
existing.def = def;
|
existing.def = def.value;
|
||||||
if (!def.is_local)
|
if (!def.value.is_local)
|
||||||
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Var,
|
UpdateDetailedNames(&existing.detailed_name_idx, SymbolKind::Var,
|
||||||
it->second.id, def.detailed_name);
|
it->second.id, def.value.detailed_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,7 +926,7 @@ TEST_SUITE("query") {
|
|||||||
IndexUpdate update = GetDelta(previous, current);
|
IndexUpdate update = GetDelta(previous, current);
|
||||||
|
|
||||||
REQUIRE(update.types_removed == std::vector<Usr>{});
|
REQUIRE(update.types_removed == std::vector<Usr>{});
|
||||||
REQUIRE(update.types_def_update == std::vector<QueryType::DefUpdate>{});
|
REQUIRE(update.types_def_update.empty());
|
||||||
REQUIRE(update.types_uses.size() == 1);
|
REQUIRE(update.types_uses.size() == 1);
|
||||||
REQUIRE(update.types_uses[0].to_remove.size() == 1);
|
REQUIRE(update.types_uses[0].to_remove.size() == 1);
|
||||||
REQUIRE(update.types_uses[0].to_remove[0].range == Range(Position(1, 0)));
|
REQUIRE(update.types_uses[0].to_remove[0].range == Range(Position(1, 0)));
|
||||||
|
41
src/query.h
41
src/query.h
@ -166,6 +166,21 @@ void Reflect(TVisitor& visitor, MergeableUpdate<TId, TValue>& value) {
|
|||||||
REFLECT_MEMBER_END();
|
REFLECT_MEMBER_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct WithUsr {
|
||||||
|
Usr usr;
|
||||||
|
T value;
|
||||||
|
|
||||||
|
WithUsr(const Usr& usr, const T& value) : usr(usr), value(value) {}
|
||||||
|
};
|
||||||
|
template <typename TVisitor, typename T>
|
||||||
|
void Reflect(TVisitor& visitor, WithUsr<T>& value) {
|
||||||
|
REFLECT_MEMBER_START();
|
||||||
|
REFLECT_MEMBER(usr);
|
||||||
|
REFLECT_MEMBER(value);
|
||||||
|
REFLECT_MEMBER_END();
|
||||||
|
}
|
||||||
|
|
||||||
struct QueryFile {
|
struct QueryFile {
|
||||||
struct Def {
|
struct Def {
|
||||||
std::string path;
|
std::string path;
|
||||||
@ -186,7 +201,7 @@ struct QueryFile {
|
|||||||
optional<DefUpdate> def;
|
optional<DefUpdate> def;
|
||||||
size_t detailed_name_idx = (size_t)-1;
|
size_t detailed_name_idx = (size_t)-1;
|
||||||
|
|
||||||
QueryFile(const std::string& path) {
|
explicit QueryFile(const std::string& path) {
|
||||||
def = DefUpdate();
|
def = DefUpdate();
|
||||||
def->path = path;
|
def->path = path;
|
||||||
}
|
}
|
||||||
@ -199,52 +214,58 @@ MAKE_REFLECT_STRUCT(QueryFile::Def,
|
|||||||
inactive_regions);
|
inactive_regions);
|
||||||
|
|
||||||
struct QueryType {
|
struct QueryType {
|
||||||
using DefUpdate = TypeDefDefinitionData<QueryTypeId,
|
using Def = TypeDefDefinitionData<QueryTypeId,
|
||||||
QueryFuncId,
|
QueryFuncId,
|
||||||
QueryVarId,
|
QueryVarId,
|
||||||
QueryLocation>;
|
QueryLocation>;
|
||||||
|
using DefUpdate = WithUsr<Def>;
|
||||||
using DerivedUpdate = MergeableUpdate<QueryTypeId, QueryTypeId>;
|
using DerivedUpdate = MergeableUpdate<QueryTypeId, QueryTypeId>;
|
||||||
using InstancesUpdate = MergeableUpdate<QueryTypeId, QueryVarId>;
|
using InstancesUpdate = MergeableUpdate<QueryTypeId, QueryVarId>;
|
||||||
using UsesUpdate = MergeableUpdate<QueryTypeId, QueryLocation>;
|
using UsesUpdate = MergeableUpdate<QueryTypeId, QueryLocation>;
|
||||||
|
|
||||||
optional<DefUpdate> def;
|
Usr usr;
|
||||||
|
optional<Def> def;
|
||||||
std::vector<QueryTypeId> derived;
|
std::vector<QueryTypeId> derived;
|
||||||
std::vector<QueryVarId> instances;
|
std::vector<QueryVarId> instances;
|
||||||
std::vector<QueryLocation> uses;
|
std::vector<QueryLocation> uses;
|
||||||
size_t detailed_name_idx = (size_t)-1;
|
size_t detailed_name_idx = (size_t)-1;
|
||||||
|
|
||||||
QueryType(const Usr& usr) : def(usr) {}
|
explicit QueryType(const Usr& usr) : usr(usr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueryFunc {
|
struct QueryFunc {
|
||||||
using DefUpdate = FuncDefDefinitionData<QueryTypeId,
|
using Def = FuncDefDefinitionData<QueryTypeId,
|
||||||
QueryFuncId,
|
QueryFuncId,
|
||||||
QueryVarId,
|
QueryVarId,
|
||||||
QueryFuncRef,
|
QueryFuncRef,
|
||||||
QueryLocation>;
|
QueryLocation>;
|
||||||
|
using DefUpdate = WithUsr<Def>;
|
||||||
using DeclarationsUpdate = MergeableUpdate<QueryFuncId, QueryLocation>;
|
using DeclarationsUpdate = MergeableUpdate<QueryFuncId, QueryLocation>;
|
||||||
using DerivedUpdate = MergeableUpdate<QueryFuncId, QueryFuncId>;
|
using DerivedUpdate = MergeableUpdate<QueryFuncId, QueryFuncId>;
|
||||||
using CallersUpdate = MergeableUpdate<QueryFuncId, QueryFuncRef>;
|
using CallersUpdate = MergeableUpdate<QueryFuncId, QueryFuncRef>;
|
||||||
|
|
||||||
optional<DefUpdate> def;
|
Usr usr;
|
||||||
|
optional<Def> def;
|
||||||
std::vector<QueryLocation> declarations;
|
std::vector<QueryLocation> declarations;
|
||||||
std::vector<QueryFuncId> derived;
|
std::vector<QueryFuncId> derived;
|
||||||
std::vector<QueryFuncRef> callers;
|
std::vector<QueryFuncRef> callers;
|
||||||
size_t detailed_name_idx = (size_t)-1;
|
size_t detailed_name_idx = (size_t)-1;
|
||||||
|
|
||||||
QueryFunc(const Usr& usr) : def(usr) {}
|
explicit QueryFunc(const Usr& usr) : usr(usr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueryVar {
|
struct QueryVar {
|
||||||
using DefUpdate =
|
using Def =
|
||||||
VarDefDefinitionData<QueryTypeId, QueryFuncId, QueryVarId, QueryLocation>;
|
VarDefDefinitionData<QueryTypeId, QueryFuncId, QueryVarId, QueryLocation>;
|
||||||
|
using DefUpdate = WithUsr<Def>;
|
||||||
using UsesUpdate = MergeableUpdate<QueryVarId, QueryLocation>;
|
using UsesUpdate = MergeableUpdate<QueryVarId, QueryLocation>;
|
||||||
|
|
||||||
optional<DefUpdate> def;
|
Usr usr;
|
||||||
|
optional<Def> def;
|
||||||
std::vector<QueryLocation> uses;
|
std::vector<QueryLocation> uses;
|
||||||
size_t detailed_name_idx = (size_t)-1;
|
size_t detailed_name_idx = (size_t)-1;
|
||||||
|
|
||||||
QueryVar(const Usr& usr) : def(usr) {}
|
explicit QueryVar(const Usr& usr) : usr(usr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IndexUpdate {
|
struct IndexUpdate {
|
||||||
|
@ -96,7 +96,7 @@ template <typename TVisitor>
|
|||||||
void Reflect(TVisitor& visitor, IndexType& value) {
|
void Reflect(TVisitor& visitor, IndexType& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER2("id", value.id);
|
REFLECT_MEMBER2("id", value.id);
|
||||||
REFLECT_MEMBER2("usr", value.def.usr);
|
REFLECT_MEMBER2("usr", value.usr);
|
||||||
REFLECT_MEMBER2("short_name", value.def.short_name);
|
REFLECT_MEMBER2("short_name", value.def.short_name);
|
||||||
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
||||||
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
||||||
@ -117,7 +117,7 @@ void Reflect(TVisitor& visitor, IndexFunc& value) {
|
|||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER2("id", value.id);
|
REFLECT_MEMBER2("id", value.id);
|
||||||
REFLECT_MEMBER2("is_operator", value.def.is_operator);
|
REFLECT_MEMBER2("is_operator", value.def.is_operator);
|
||||||
REFLECT_MEMBER2("usr", value.def.usr);
|
REFLECT_MEMBER2("usr", value.usr);
|
||||||
REFLECT_MEMBER2("short_name", value.def.short_name);
|
REFLECT_MEMBER2("short_name", value.def.short_name);
|
||||||
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
||||||
REFLECT_MEMBER2("declarations", value.declarations);
|
REFLECT_MEMBER2("declarations", value.declarations);
|
||||||
@ -136,7 +136,7 @@ template <typename TVisitor>
|
|||||||
void Reflect(TVisitor& visitor, IndexVar& value) {
|
void Reflect(TVisitor& visitor, IndexVar& value) {
|
||||||
REFLECT_MEMBER_START();
|
REFLECT_MEMBER_START();
|
||||||
REFLECT_MEMBER2("id", value.id);
|
REFLECT_MEMBER2("id", value.id);
|
||||||
REFLECT_MEMBER2("usr", value.def.usr);
|
REFLECT_MEMBER2("usr", value.usr);
|
||||||
REFLECT_MEMBER2("short_name", value.def.short_name);
|
REFLECT_MEMBER2("short_name", value.def.short_name);
|
||||||
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
||||||
REFLECT_MEMBER2("declaration", value.def.declaration);
|
REFLECT_MEMBER2("declaration", value.def.declaration);
|
||||||
@ -220,16 +220,16 @@ std::unique_ptr<IndexFile> Deserialize(std::string path,
|
|||||||
file->path = path;
|
file->path = path;
|
||||||
file->id_cache.primary_file = file->path;
|
file->id_cache.primary_file = file->path;
|
||||||
for (const auto& type : file->types) {
|
for (const auto& type : file->types) {
|
||||||
file->id_cache.type_id_to_usr[type.id] = type.def.usr;
|
file->id_cache.type_id_to_usr[type.id] = type.usr;
|
||||||
file->id_cache.usr_to_type_id[type.def.usr] = type.id;
|
file->id_cache.usr_to_type_id[type.usr] = type.id;
|
||||||
}
|
}
|
||||||
for (const auto& func : file->funcs) {
|
for (const auto& func : file->funcs) {
|
||||||
file->id_cache.func_id_to_usr[func.id] = func.def.usr;
|
file->id_cache.func_id_to_usr[func.id] = func.usr;
|
||||||
file->id_cache.usr_to_func_id[func.def.usr] = func.id;
|
file->id_cache.usr_to_func_id[func.usr] = func.id;
|
||||||
}
|
}
|
||||||
for (const auto& var : file->vars) {
|
for (const auto& var : file->vars) {
|
||||||
file->id_cache.var_id_to_usr[var.id] = var.def.usr;
|
file->id_cache.var_id_to_usr[var.id] = var.usr;
|
||||||
file->id_cache.usr_to_var_id[var.def.usr] = var.id;
|
file->id_cache.usr_to_var_id[var.usr] = var.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
Loading…
Reference in New Issue
Block a user