mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 09:50:26 +00:00
Simplify EachWithGen
This commit is contained in:
parent
2c787fe1fe
commit
1349cbfde3
@ -61,7 +61,7 @@ ExpandNode(QueryDatabase* db, WorkingFiles* working_files, QueryTypeId root) {
|
||||
return {};
|
||||
|
||||
std::vector<Out_CqueryMemberHierarchy::Entry> ret;
|
||||
EachWithGen<QueryVar>(db->vars, root_type.def->vars, [&](QueryVar& var) {
|
||||
EachWithGen(db->vars, root_type.def->vars, [&](QueryVar& var) {
|
||||
Out_CqueryMemberHierarchy::Entry entry;
|
||||
entry.name = var.def->ShortName();
|
||||
// FIXME WithGen
|
||||
|
@ -34,18 +34,17 @@ BuildParentInheritanceHierarchyForType(QueryDatabase* db,
|
||||
std::vector<Out_CqueryTypeHierarchyTree::TypeEntry> parent_entries;
|
||||
parent_entries.reserve(root_type.def->parents.size());
|
||||
|
||||
EachWithGen<QueryType>(
|
||||
db->types, root_type.def->parents, [&](QueryType& parent_type) {
|
||||
Out_CqueryTypeHierarchyTree::TypeEntry parent_entry;
|
||||
parent_entry.name = parent_type.def->detailed_name;
|
||||
if (parent_type.def->definition_spelling)
|
||||
parent_entry.location = GetLsLocation(
|
||||
db, working_files, *parent_type.def->definition_spelling);
|
||||
parent_entry.children = BuildParentInheritanceHierarchyForType(
|
||||
db, working_files, parent_type);
|
||||
EachWithGen(db->types, root_type.def->parents, [&](QueryType& parent_type) {
|
||||
Out_CqueryTypeHierarchyTree::TypeEntry parent_entry;
|
||||
parent_entry.name = parent_type.def->detailed_name;
|
||||
if (parent_type.def->definition_spelling)
|
||||
parent_entry.location = GetLsLocation(
|
||||
db, working_files, *parent_type.def->definition_spelling);
|
||||
parent_entry.children =
|
||||
BuildParentInheritanceHierarchyForType(db, working_files, parent_type);
|
||||
|
||||
parent_entries.push_back(parent_entry);
|
||||
});
|
||||
parent_entries.push_back(parent_entry);
|
||||
});
|
||||
|
||||
return parent_entries;
|
||||
}
|
||||
@ -74,7 +73,7 @@ BuildInheritanceHierarchyForType(QueryDatabase* db,
|
||||
entry.children.push_back(base);
|
||||
|
||||
// Add derived.
|
||||
EachWithGen<QueryType>(db->types, root_type.derived, [&](QueryType& type) {
|
||||
EachWithGen(db->types, root_type.derived, [&](QueryType& type) {
|
||||
auto derived_entry =
|
||||
BuildInheritanceHierarchyForType(db, working_files, type);
|
||||
if (derived_entry)
|
||||
|
@ -353,8 +353,7 @@ struct TextDocumentCodeActionHandler
|
||||
// Get implementation file.
|
||||
Out_TextDocumentCodeAction::Command command;
|
||||
|
||||
EachWithGen<QueryFunc>(db->funcs, type.def->funcs, [&](QueryFunc&
|
||||
func_def) {
|
||||
EachWithGen(db->funcs, type.def->funcs, [&](QueryFunc& func_def) {
|
||||
if (func_def.def->definition_extent)
|
||||
return;
|
||||
EnsureImplFile(db, file_id, impl_uri /*out*/, impl_file_id /*out*/);
|
||||
|
@ -73,8 +73,8 @@ void EmitDiagnostics(WorkingFiles* working_files,
|
||||
std::string path,
|
||||
std::vector<lsDiagnostic> diagnostics);
|
||||
|
||||
template <typename Q>
|
||||
void EachWithGen(std::vector<Q>& collection, WithGen<Id<Q>> x, std::function<void(Q&)> fn) {
|
||||
template <typename Q, typename Fn>
|
||||
void EachWithGen(std::vector<Q>& collection, WithGen<Id<Q>> x, Fn fn) {
|
||||
Q& obj = collection[x.value.id];
|
||||
// FIXME Deprecate optional<Def> def
|
||||
// if (obj.gen == x.gen && obj.def)
|
||||
@ -82,8 +82,8 @@ void EachWithGen(std::vector<Q>& collection, WithGen<Id<Q>> x, std::function<voi
|
||||
fn(obj);
|
||||
}
|
||||
|
||||
template <typename Q>
|
||||
void EachWithGen(std::vector<Q>& collection, std::vector<WithGen<Id<Q>>>& ids, std::function<void(Q&)> fn) {
|
||||
template <typename Q, typename Fn>
|
||||
void EachWithGen(std::vector<Q>& collection, std::vector<WithGen<Id<Q>>>& ids, Fn fn) {
|
||||
size_t j = 0;
|
||||
for (WithGen<Id<Q>> x : ids) {
|
||||
Q& obj = collection[x.value.id];
|
||||
|
Loading…
Reference in New Issue
Block a user