+ for mpackage in collect_mpackages(filter) do
+ res.add_all mpackage.collect_intro_mproperties(filter)
+ end
+ return res
+ end
+
+ # Collect all MProperties in `self`
+ fun collect_mproperties(filter: nullable ModelFilter): HashSet[MProperty] do
+ var res = new HashSet[MProperty]
+ for mproperty in mproperties do
+ if filter == null or filter.accept_mentity(mproperty) then res.add mproperty
+ end
+ return res
+ end
+
+ # Collect all MPropDefs in `self`
+ fun collect_mpropdefs(filter: nullable ModelFilter): HashSet[MPropDef] do
+ var res = new HashSet[MPropDef]
+ for mproperty in collect_mproperties(filter) do
+ for mpropdef in mproperty.mpropdefs do
+ if filter == null or filter.accept_mentity(mpropdef) then res.add mpropdef
+ end
+ end
+ return res
+ end
+
+ # Collect all MEntities in `self`
+ fun collect_mentities(filter: nullable ModelFilter): HashSet[MEntity] do
+ var res = new HashSet[MEntity]
+ res.add_all collect_mpackages(filter)
+ res.add_all collect_mgroups(filter)
+ res.add_all collect_mmodules(filter)
+ res.add_all collect_mclasses(filter)
+ res.add_all collect_mclassdefs(filter)
+ res.add_all collect_mproperties(filter)
+ res.add_all collect_mpropdefs(filter)
+ return res
+ end
+
+ # Searches the MEntity that matches `full_name`.
+ fun mentity_by_full_name(full_name: String, filter: nullable ModelFilter): nullable MEntity do
+ for mentity in collect_mentities(filter) do
+ if filter != null and not filter.accept_mentity(mentity) then continue
+ if mentity.full_name == full_name then return mentity
+ end
+ return null
+ end
+
+ # Searches the MEntities that matches `full_name`.
+ fun mentities_by_name(name: String, filter: nullable ModelFilter): Array[MEntity] do
+ var res = new Array[MEntity]
+ for mentity in collect_mentities(filter) do
+ if filter != null and not filter.accept_mentity(mentity) then continue
+ if mentity.name == name then res.add mentity