From 9b909b3a13f58ca78d0cde474f3b2d6da973d9ed Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Mon, 11 Dec 2017 23:56:50 -0800 Subject: [PATCH] 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. --- src/indexer.cc | 2 +- src/indexer.h | 66 +++++--------- src/messages/cquery_call_tree.cc | 4 +- src/query.cc | 146 ++++++++++++++++--------------- src/query.h | 55 ++++++++---- src/serializer.cc | 18 ++-- 6 files changed, 148 insertions(+), 143 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 47a64c1f..059ab106 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -443,7 +443,7 @@ std::string IndexFile::ToString() { } IndexType::IndexType(IndexTypeId id, const std::string& usr) - : def(usr), id(id) { + : usr(usr), id(id) { assert(usr.size() > 0); } diff --git a/src/indexer.h b/src/indexer.h index 45a0e196..ed2431bd 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -147,7 +147,6 @@ inline void Reflect(Writer& visitor, IndexFuncRef& value) { template struct TypeDefDefinitionData { // General metadata. - std::string usr; std::string short_name; std::string detailed_name; @@ -175,12 +174,9 @@ struct TypeDefDefinitionData { std::vector funcs; std::vector vars; - TypeDefDefinitionData() {} // For reflection. - TypeDefDefinitionData(const std::string& usr) : usr(usr) {} - bool operator==( const TypeDefDefinitionData& other) const { - return usr == other.usr && short_name == other.short_name && + return short_name == other.short_name && detailed_name == other.detailed_name && definition_spelling == other.definition_spelling && definition_extent == other.definition_extent && @@ -201,7 +197,6 @@ template & value) { REFLECT_MEMBER_START(); - REFLECT_MEMBER(usr); REFLECT_MEMBER(short_name); REFLECT_MEMBER(detailed_name); REFLECT_MEMBER(definition_spelling); @@ -217,10 +212,12 @@ void Reflect(TVisitor& visitor, struct IndexType { using Def = TypeDefDefinitionData; - Def def; + std::string usr; IndexTypeId id; + Def def; + // Immediate derived types. std::vector derived; @@ -231,16 +228,12 @@ struct IndexType { // NOTE: Do not insert directly! Use AddUsage instead. std::vector uses; - IndexType() : def("") {} // For serialization - + IndexType() {} // For serialization. IndexType(IndexTypeId id, const std::string& usr); - bool operator<(const IndexType& other) const { - return def.usr < other.def.usr; - } + bool operator<(const IndexType& other) const { return id < other.id; } }; - -MAKE_HASHABLE(IndexType, t.def.usr); +MAKE_HASHABLE(IndexType, t.id); template struct FuncDefDefinitionData { // General metadata. - std::string usr; std::string short_name; std::string detailed_name; optional definition_spelling; @@ -270,15 +262,10 @@ struct FuncDefDefinitionData { // Used for semantic highlighting bool is_operator = false; - FuncDefDefinitionData() {} // For reflection. - FuncDefDefinitionData(const std::string& usr) : usr(usr) { - // assert(usr.size() > 0); - } - bool operator==( const FuncDefDefinitionData& other) const { - return usr == other.usr && short_name == other.short_name && + return short_name == other.short_name && detailed_name == other.detailed_name && definition_spelling == other.definition_spelling && definition_extent == other.definition_extent && @@ -302,7 +289,6 @@ void Reflect( TVisitor& visitor, FuncDefDefinitionData& value) { REFLECT_MEMBER_START(); - REFLECT_MEMBER(usr); REFLECT_MEMBER(short_name); REFLECT_MEMBER(detailed_name); REFLECT_MEMBER(definition_spelling); @@ -321,10 +307,12 @@ struct IndexFunc { IndexVarId, IndexFuncRef, Range>; - Def def; + std::string usr; IndexFuncId id; + Def def; + struct Declaration { // Range of only the function name. Range spelling; @@ -349,16 +337,14 @@ struct IndexFunc { // def.definition_spelling. std::vector callers; - IndexFunc() {} // For reflection. - IndexFunc(IndexFuncId id, const std::string& usr) : def(usr), id(id) { + IndexFunc() {} // For serialization. + IndexFunc(IndexFuncId id, const std::string& usr) : usr(usr), id(id) { // assert(usr.size() > 0); } - bool operator<(const IndexFunc& other) const { - return def.usr < other.def.usr; - } + bool operator<(const IndexFunc& other) const { return id < other.id; } }; -MAKE_HASHABLE(IndexFunc, t.def.usr); +MAKE_HASHABLE(IndexFunc, t.id); MAKE_REFLECT_STRUCT(IndexFunc::Declaration, spelling, extent, @@ -368,7 +354,6 @@ MAKE_REFLECT_STRUCT(IndexFunc::Declaration, template struct VarDefDefinitionData { // General metadata. - std::string usr; std::string short_name; std::string detailed_name; optional declaration; @@ -388,12 +373,9 @@ struct VarDefDefinitionData { // Is this a macro, ie, #define FOO? bool is_macro = false; - VarDefDefinitionData() {} // For reflection. - VarDefDefinitionData(const std::string& usr) : usr(usr) {} - bool operator==( const VarDefDefinitionData& other) const { - return usr == other.usr && short_name == other.short_name && + return short_name == other.short_name && detailed_name == other.detailed_name && declaration == other.declaration && definition_spelling == other.definition_spelling && @@ -415,7 +397,6 @@ template & value) { REFLECT_MEMBER_START(); - REFLECT_MEMBER(usr); REFLECT_MEMBER(short_name); REFLECT_MEMBER(detailed_name); REFLECT_MEMBER(definition_spelling); @@ -429,24 +410,23 @@ void Reflect(TVisitor& visitor, struct IndexVar { using Def = VarDefDefinitionData; - Def def; + std::string usr; IndexVarId id; + Def def; + // Usages. std::vector uses; - IndexVar() : def("") {} // For serialization - - IndexVar(IndexVarId id, const std::string& usr) : def(usr), id(id) { + IndexVar() {} // For serialization. + IndexVar(IndexVarId id, const std::string& usr) : usr(usr), id(id) { // assert(usr.size() > 0); } - bool operator<(const IndexVar& other) const { - return def.usr < other.def.usr; - } + bool operator<(const IndexVar& other) const { return id < other.id; } }; -MAKE_HASHABLE(IndexVar, t.def.usr); +MAKE_HASHABLE(IndexVar, t.id); struct IdCache { std::string primary_file; diff --git a/src/messages/cquery_call_tree.cc b/src/messages/cquery_call_tree.cc index d47effce..18239557 100644 --- a/src/messages/cquery_call_tree.cc +++ b/src/messages/cquery_call_tree.cc @@ -59,7 +59,7 @@ std::vector BuildInitialCallTree( Out_CqueryCallTree::CallEntry entry; entry.name = root_func.def->short_name; - entry.usr = root_func.def->usr; + entry.usr = root_func.usr; entry.location = *def_loc; entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, root_func); std::vector result; @@ -133,7 +133,7 @@ std::vector BuildExpandCallTree( call_entry.name = call_func.def->short_name + " (" + 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.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, call_func); call_entry.callType = call_type; diff --git a/src/query.cc b/src/query.cc index e55b84c2..925b5f40 100644 --- a/src/query.cc +++ b/src/query.cc @@ -18,12 +18,12 @@ namespace { -optional ToQuery(const IdMap& id_map, - const IndexType::Def& type) { +optional ToQuery(const IdMap& id_map, + const IndexType::Def& type) { if (type.detailed_name.empty()) return nullopt; - QueryType::DefUpdate result(type.usr); + QueryType::Def result; result.short_name = type.short_name; result.detailed_name = type.detailed_name; result.definition_spelling = id_map.ToQuery(type.definition_spelling); @@ -36,12 +36,12 @@ optional ToQuery(const IdMap& id_map, return result; } -optional ToQuery(const IdMap& id_map, - const IndexFunc::Def& func) { +optional ToQuery(const IdMap& id_map, + const IndexFunc::Def& func) { if (func.detailed_name.empty()) return nullopt; - QueryFunc::DefUpdate result(func.usr); + QueryFunc::Def result; result.short_name = func.short_name; result.detailed_name = func.detailed_name; result.definition_spelling = id_map.ToQuery(func.definition_spelling); @@ -54,12 +54,11 @@ optional ToQuery(const IdMap& id_map, return result; } -optional ToQuery(const IdMap& id_map, - const IndexVar::Def& var) { +optional ToQuery(const IdMap& id_map, const IndexVar::Def& var) { if (var.detailed_name.empty()) return nullopt; - QueryVar::DefUpdate result(var.usr); + QueryVar::Def result; result.short_name = var.short_name; result.detailed_name = var.detailed_name; result.declaration = id_map.ToQuery(var.declaration); @@ -137,14 +136,14 @@ void CompareGroups(std::vector& previous_data, auto curr_it = current_data.begin(); while (prev_it != previous_data.end() && curr_it != current_data.end()) { // same id - if (prev_it->def.usr == curr_it->def.usr) { + if (prev_it->usr == curr_it->usr) { on_found(&*prev_it, &*curr_it); ++prev_it; ++curr_it; } // 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); ++prev_it; } @@ -435,18 +434,18 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, // |query_name| is the name of the variable on the query type. // |index_name| is the name of the variable on the index type. // |type| is the type of the variable. -#define PROCESS_UPDATE_DIFF(type_id, query_name, index_name, type) \ - { \ - /* Check for changes. */ \ - std::vector removed, added; \ - auto previous = previous_id_map.ToQuery(previous_def->index_name); \ - auto current = current_id_map.ToQuery(current_def->index_name); \ - bool did_add = \ - ComputeDifferenceForUpdate(previous, current, &removed, &added); \ - if (did_add) { \ - query_name.push_back(MergeableUpdate( \ - current_id_map.ToQuery(current_def->id), added, removed)); \ - } \ +#define PROCESS_UPDATE_DIFF(type_id, query_name, index_name, type) \ + { \ + /* Check for changes. */ \ + std::vector removed, added; \ + auto query_previous = previous_id_map.ToQuery(previous->index_name); \ + auto query_current = current_id_map.ToQuery(current->index_name); \ + bool did_add = ComputeDifferenceForUpdate(query_previous, query_current, \ + &removed, &added); \ + if (did_add) { \ + query_name.push_back(MergeableUpdate( \ + current_id_map.ToQuery(current->id), added, removed)); \ + } \ } // File files_def_update.push_back(BuildFileDef(current_id_map, current_file)); @@ -462,7 +461,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, /*onRemoved:*/ [this, &previous_id_map](IndexType* type) { if (type->def.definition_spelling) - types_removed.push_back(type->def.usr); + types_removed.push_back(type->usr); else { if (!type->derived.empty()) types_derived.push_back(QueryType::DerivedUpdate( @@ -480,10 +479,11 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, }, /*onAdded:*/ [this, ¤t_id_map](IndexType* type) { - optional def_update = + optional def_update = ToQuery(current_id_map, type->def); 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()) types_derived.push_back( 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))); }, /*onFound:*/ - [this, &previous_id_map, ¤t_id_map](IndexType* previous_def, - IndexType* current_def) { - optional previous_remapped_def = - ToQuery(previous_id_map, previous_def->def); - optional current_remapped_def = - ToQuery(current_id_map, current_def->def); + [this, &previous_id_map, ¤t_id_map](IndexType* previous, + IndexType* current) { + optional previous_remapped_def = + ToQuery(previous_id_map, previous->def); + optional current_remapped_def = + ToQuery(current_id_map, current->def); if (current_remapped_def && previous_remapped_def != current_remapped_def && - !current_remapped_def->detailed_name.empty()) - types_def_update.push_back(*current_remapped_def); + !current_remapped_def->detailed_name.empty()) { + 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_instances, instances, @@ -521,7 +523,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, /*onRemoved:*/ [this, &previous_id_map](IndexFunc* func) { if (func->def.definition_spelling) { - funcs_removed.push_back(func->def.usr); + funcs_removed.push_back(func->usr); } else { if (!func->declarations.empty()) funcs_declarations.push_back(QueryFunc::DeclarationsUpdate( @@ -539,10 +541,11 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, }, /*onAdded:*/ [this, ¤t_id_map](IndexFunc* func) { - optional def_update = + optional def_update = ToQuery(current_id_map, func->def); 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()) funcs_declarations.push_back(QueryFunc::DeclarationsUpdate( current_id_map.ToQuery(func->id), @@ -557,16 +560,18 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, current_id_map.ToQuery(func->callers))); }, /*onFound:*/ - [this, &previous_id_map, ¤t_id_map](IndexFunc* previous_def, - IndexFunc* current_def) { - optional previous_remapped_def = - ToQuery(previous_id_map, previous_def->def); - optional current_remapped_def = - ToQuery(current_id_map, current_def->def); + [this, &previous_id_map, ¤t_id_map](IndexFunc* previous, + IndexFunc* current) { + optional previous_remapped_def = + ToQuery(previous_id_map, previous->def); + optional current_remapped_def = + ToQuery(current_id_map, current->def); if (current_remapped_def && previous_remapped_def != current_remapped_def && - !current_remapped_def->detailed_name.empty()) - funcs_def_update.push_back(*current_remapped_def); + !current_remapped_def->detailed_name.empty()) { + funcs_def_update.push_back( + QueryFunc::DefUpdate(current->usr, *current_remapped_def)); + } PROCESS_UPDATE_DIFF(QueryFuncId, funcs_declarations, declarations, QueryLocation); @@ -580,7 +585,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, /*onRemoved:*/ [this, &previous_id_map](IndexVar* var) { if (var->def.definition_spelling) { - vars_removed.push_back(var->def.usr); + vars_removed.push_back(var->usr); } else { if (!var->uses.empty()) vars_uses.push_back( @@ -590,26 +595,26 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, }, /*onAdded:*/ [this, ¤t_id_map](IndexVar* var) { - optional def_update = - ToQuery(current_id_map, var->def); + optional def_update = ToQuery(current_id_map, var->def); 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()) vars_uses.push_back( QueryVar::UsesUpdate(current_id_map.ToQuery(var->id), current_id_map.ToQuery(var->uses))); }, /*onFound:*/ - [this, &previous_id_map, ¤t_id_map](IndexVar* previous_def, - IndexVar* current_def) { - optional previous_remapped_def = - ToQuery(previous_id_map, previous_def->def); - optional current_remapped_def = - ToQuery(current_id_map, current_def->def); + [this, &previous_id_map, ¤t_id_map](IndexVar* previous, + IndexVar* current) { + optional previous_remapped_def = + ToQuery(previous_id_map, previous->def); + optional current_remapped_def = + ToQuery(current_id_map, current->def); if (current_remapped_def && previous_remapped_def != current_remapped_def && !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); }); @@ -619,7 +624,6 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, // This function runs on an indexer thread. void IndexUpdate::Merge(const IndexUpdate& update) { - #define INDEX_UPDATE_APPEND(name) AddRange(&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. for (auto& def : updates) { - assert(!def.detailed_name.empty()); + assert(!def.value.detailed_name.empty()); auto it = usr_to_type.find(def.usr); assert(it != usr_to_type.end()); @@ -767,12 +771,12 @@ void QueryDatabase::ImportOrUpdate( // Keep the existing definition if it is higher quality. if (existing.def && existing.def->definition_spelling && - !def.definition_spelling) + !def.value.definition_spelling) continue; - existing.def = def; + existing.def = def.value; 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. for (auto& def : updates) { - assert(!def.detailed_name.empty()); + assert(!def.value.detailed_name.empty()); auto it = usr_to_func.find(def.usr); assert(it != usr_to_func.end()); @@ -791,12 +795,12 @@ void QueryDatabase::ImportOrUpdate( // Keep the existing definition if it is higher quality. if (existing.def && existing.def->definition_spelling && - !def.definition_spelling) + !def.value.definition_spelling) continue; - existing.def = def; + existing.def = def.value; 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. for (auto& def : updates) { - assert(!def.detailed_name.empty()); + assert(!def.value.detailed_name.empty()); auto it = usr_to_var.find(def.usr); assert(it != usr_to_var.end()); @@ -815,13 +819,13 @@ void QueryDatabase::ImportOrUpdate( // Keep the existing definition if it is higher quality. if (existing.def && existing.def->definition_spelling && - !def.definition_spelling) + !def.value.definition_spelling) continue; - existing.def = def; - if (!def.is_local) + existing.def = def.value; + if (!def.value.is_local) 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); REQUIRE(update.types_removed == std::vector{}); - REQUIRE(update.types_def_update == std::vector{}); + REQUIRE(update.types_def_update.empty()); REQUIRE(update.types_uses.size() == 1); REQUIRE(update.types_uses[0].to_remove.size() == 1); REQUIRE(update.types_uses[0].to_remove[0].range == Range(Position(1, 0))); diff --git a/src/query.h b/src/query.h index f3ec38ce..5357a442 100644 --- a/src/query.h +++ b/src/query.h @@ -166,6 +166,21 @@ void Reflect(TVisitor& visitor, MergeableUpdate& value) { REFLECT_MEMBER_END(); } +template +struct WithUsr { + Usr usr; + T value; + + WithUsr(const Usr& usr, const T& value) : usr(usr), value(value) {} +}; +template +void Reflect(TVisitor& visitor, WithUsr& value) { + REFLECT_MEMBER_START(); + REFLECT_MEMBER(usr); + REFLECT_MEMBER(value); + REFLECT_MEMBER_END(); +} + struct QueryFile { struct Def { std::string path; @@ -186,7 +201,7 @@ struct QueryFile { optional def; size_t detailed_name_idx = (size_t)-1; - QueryFile(const std::string& path) { + explicit QueryFile(const std::string& path) { def = DefUpdate(); def->path = path; } @@ -199,52 +214,58 @@ MAKE_REFLECT_STRUCT(QueryFile::Def, inactive_regions); struct QueryType { - using DefUpdate = TypeDefDefinitionData; + using Def = TypeDefDefinitionData; + using DefUpdate = WithUsr; using DerivedUpdate = MergeableUpdate; using InstancesUpdate = MergeableUpdate; using UsesUpdate = MergeableUpdate; - optional def; + Usr usr; + optional def; std::vector derived; std::vector instances; std::vector uses; size_t detailed_name_idx = (size_t)-1; - QueryType(const Usr& usr) : def(usr) {} + explicit QueryType(const Usr& usr) : usr(usr) {} }; struct QueryFunc { - using DefUpdate = FuncDefDefinitionData; + using Def = FuncDefDefinitionData; + using DefUpdate = WithUsr; using DeclarationsUpdate = MergeableUpdate; using DerivedUpdate = MergeableUpdate; using CallersUpdate = MergeableUpdate; - optional def; + Usr usr; + optional def; std::vector declarations; std::vector derived; std::vector callers; size_t detailed_name_idx = (size_t)-1; - QueryFunc(const Usr& usr) : def(usr) {} + explicit QueryFunc(const Usr& usr) : usr(usr) {} }; struct QueryVar { - using DefUpdate = + using Def = VarDefDefinitionData; + using DefUpdate = WithUsr; using UsesUpdate = MergeableUpdate; - optional def; + Usr usr; + optional def; std::vector uses; size_t detailed_name_idx = (size_t)-1; - QueryVar(const Usr& usr) : def(usr) {} + explicit QueryVar(const Usr& usr) : usr(usr) {} }; struct IndexUpdate { diff --git a/src/serializer.cc b/src/serializer.cc index c6359574..a0b057bf 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -96,7 +96,7 @@ template void Reflect(TVisitor& visitor, IndexType& value) { REFLECT_MEMBER_START(); 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("detailed_name", value.def.detailed_name); REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling); @@ -117,7 +117,7 @@ void Reflect(TVisitor& visitor, IndexFunc& value) { REFLECT_MEMBER_START(); REFLECT_MEMBER2("id", value.id); 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("detailed_name", value.def.detailed_name); REFLECT_MEMBER2("declarations", value.declarations); @@ -136,7 +136,7 @@ template void Reflect(TVisitor& visitor, IndexVar& value) { REFLECT_MEMBER_START(); 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("detailed_name", value.def.detailed_name); REFLECT_MEMBER2("declaration", value.def.declaration); @@ -220,16 +220,16 @@ std::unique_ptr Deserialize(std::string path, file->path = path; file->id_cache.primary_file = file->path; for (const auto& type : file->types) { - file->id_cache.type_id_to_usr[type.id] = type.def.usr; - file->id_cache.usr_to_type_id[type.def.usr] = type.id; + file->id_cache.type_id_to_usr[type.id] = type.usr; + file->id_cache.usr_to_type_id[type.usr] = type.id; } for (const auto& func : file->funcs) { - file->id_cache.func_id_to_usr[func.id] = func.def.usr; - file->id_cache.usr_to_func_id[func.def.usr] = func.id; + file->id_cache.func_id_to_usr[func.id] = func.usr; + file->id_cache.usr_to_func_id[func.usr] = func.id; } for (const auto& var : file->vars) { - file->id_cache.var_id_to_usr[var.id] = var.def.usr; - file->id_cache.usr_to_var_id[var.def.usr] = var.id; + file->id_cache.var_id_to_usr[var.id] = var.usr; + file->id_cache.usr_to_var_id[var.usr] = var.id; } return file;