memberHierarchy

This commit is contained in:
Fangrui Song 2018-02-25 22:55:17 -08:00
parent c166f3bca8
commit 42825d022b

View File

@ -107,6 +107,20 @@ bool Expand(MessageHandler* m,
else else
entry->name = def->ShortName(); entry->name = def->ShortName();
if (levels > 0) { if (levels > 0) {
std::unordered_set<Usr> seen;
std::vector<const QueryType*> stack;
seen.insert(type.usr);
stack.push_back(&type);
while (stack.size()) {
const QueryType& type = *stack.back();
stack.pop_back();
if (const auto* def = type.AnyDef()) {
EachDefinedEntity(m->db->types, def->bases, [&](QueryType& type1) {
if (!seen.count(type1.usr)) {
seen.insert(type1.usr);
stack.push_back(&type1);
}
});
EachDefinedEntity(m->db->vars, def->vars, [&](QueryVar& var) { EachDefinedEntity(m->db->vars, def->vars, [&](QueryVar& var) {
const QueryVar::Def* def1 = var.AnyDef(); const QueryVar::Def* def1 = var.AnyDef();
if (!def1) if (!def1)
@ -122,9 +136,11 @@ bool Expand(MessageHandler* m,
GetLsLocation(m->db, m->working_files, *def1->spell)) GetLsLocation(m->db, m->working_files, *def1->spell))
entry1.location = *loc; entry1.location = *loc;
} }
if (Expand(m, &entry1, detailed_name, levels - 1)) if (def1->type && Expand(m, &entry1, detailed_name, levels - 1))
entry->children.push_back(std::move(entry1)); entry->children.push_back(std::move(entry1));
}); });
}
}
entry->numChildren = int(entry->children.size()); entry->numChildren = int(entry->children.size());
} else } else
entry->numChildren = int(def->vars.size()); entry->numChildren = int(def->vars.size());