#
# This is usefull for tools that need a global view of a model like `nitdoc`,
# `nitx` or `nituml`.
-# It shoul not be used for compiling stuffs like computing VFT, where the listed
+# It should not be used for compiling stuffs like computing VFT, where the listed
# entities could not be reachable depending on the modules really imported.
module model_collect
end
return res
end
+
+ # `MModules` contained in `self`.
+ fun collect_mmodules(view: ModelView): HashSet[MModule] do
+ var res = new HashSet[MModule]
+ for mgroup in mgroups do
+ for mmodule in mgroup.mmodules do
+ if not view.accept_mentity(mmodule) then continue
+ res.add(mmodule)
+ end
+ end
+ return res
+ end
end
redef class MGroup
return res
end
+ # Collect all mmethods accessible by 'self' with `visibility >= min_visibility`.
+ #
+ # This include introduced, redefined, inherited mmethods.
+ fun collect_accessible_mmethods(view: ModelView): Set[MMethod] do
+ var set = new HashSet[MMethod]
+ set.add_all(collect_intro_mmethods(view))
+ set.add_all(collect_redef_mmethods(view))
+ set.add_all(collect_inherited_mmethods(view))
+ return set
+ end
+
# Collect mattributes introduced in 'self' with `visibility >= min_visibility`.
fun collect_intro_mattributes(view: ModelView): Set[MAttribute] do
var res = new HashSet[MAttribute]
set.add_all(collect_inherited_inits(view))
return set
end
+
+ # Collect all virtual types accessible by 'self' if accepted by `view`.
+ #
+ # This include introduced, redefined, inherited virtual types.
+ fun collect_accessible_vts(view: ModelView): Set[MVirtualTypeProp] do
+ var set = new HashSet[MVirtualTypeProp]
+ for mproperty in collect_accessible_mproperties(view) do
+ if mproperty isa MVirtualTypeProp then set.add mproperty
+ end
+ return set
+ end
end
redef class MClassDef