model: Promote definitions of `mdoc_or_fallback`
[nit.git] / src / model / model_views.nit
index 3a88f45..2f0eed5 100644 (file)
@@ -125,25 +125,12 @@ class ModelView
                v.include_test_suite = self.include_test_suite
        end
 
-       # Searches MEntities that match `name`.
-       fun mentities_by_name(name: String): Array[MEntity] do
-               var res = new Array[MEntity]
-               for mentity in mentities do if mentity.name == name then res.add mentity
-               return res
-       end
-
-       # Looks up a MEntity by its full `namespace`.
-       #
-       # Usefull when `mentities_by_name` returns conflicts.
-       #
-       # Namespaces must be of the form `package::core::module::Class::prop`.
-       fun mentities_by_namespace(namespace: String): Array[MEntity] do
-               var v = new LookupNamespaceVisitor(namespace)
-               init_visitor(v)
-               for mpackage in mpackages do
-                       v.enter_visit(mpackage)
+       # Searches the MEntity that matches `full_name`.
+       fun mentity_by_full_name(full_name: String): nullable MEntity do
+               for mentity in mentities do
+                       if mentity.full_name == full_name then return mentity
                end
-               return v.results
+               return null
        end
 
        # Build an concerns tree with from `self`
@@ -155,6 +142,16 @@ class ModelView
                end
                return v.tree
        end
+
+       # Build the POSet of `mmodules` importation.
+       fun mmodules_poset(mmodules: Set[MModule]): POSet[MModule] do
+               return model.mmodule_importation_hierarchy.sub(mmodules)
+       end
+
+       # Build the POSet of `mclasses` hierarchy.
+       fun mclasses_poset(mainmodule: MModule, mclasses: Set[MClass]): POSet[MClass] do
+               return mainmodule.flatten_mclass_hierarchy.sub(mclasses)
+       end
 end
 
 class LookupNamespaceVisitor