nitpackage: move package path services up to `model/mpackage.nit`
[nit.git] / src / model / model_collect.nit
index 00d52df..6edd044 100644 (file)
@@ -235,7 +235,7 @@ redef class MPackage
        # Collect all modules contained in `self`
        fun collect_all_mmodules(view: ModelView): HashSet[MModule] do
                var res = new HashSet[MModule]
-               for mgroup in collect_mgroups(view) do
+               for mgroup in collect_all_mgroups(view) do
                        res.add_all mgroup.collect_mmodules(view)
                end
                return res
@@ -394,17 +394,6 @@ redef class MModule
 
        redef fun collect_modifiers do return super + ["module"]
 
-       # Collect all module ancestors of `self` (direct and transitive imports)
-       redef fun collect_ancestors(view) do
-               var res = new HashSet[MENTITY]
-               for mentity in in_importation.greaters do
-                       if mentity == self then continue
-                       if not view.accept_mentity(mentity) then continue
-                       res.add mentity
-               end
-               return res
-       end
-
        # Collect all modules directly imported by `self`
        redef fun collect_parents(view) do
                var res = new HashSet[MENTITY]
@@ -579,6 +568,7 @@ redef class MClass
        # This method uses a flattened hierarchy containing all the mclassdefs.
        redef fun collect_parents(view) do
                var res = new HashSet[MENTITY]
+               if not view.mainmodule.flatten_mclass_hierarchy.has(self) then return res
                for mclass in in_hierarchy(view.mainmodule).direct_greaters do
                        if mclass == self or not view.accept_mentity(mclass) then continue
                        res.add mclass
@@ -591,6 +581,7 @@ redef class MClass
        # This method uses a flattened hierarchy containing all the mclassdefs.
        redef fun collect_children(view) do
                var res = new HashSet[MENTITY]
+               if not view.mainmodule.flatten_mclass_hierarchy.has(self) then return res
                for mclass in in_hierarchy(view.mainmodule).direct_smallers do
                        if mclass == self or not view.accept_mentity(mclass) then continue
                        res.add mclass
@@ -880,7 +871,9 @@ redef class MClassDef
                if not is_intro then
                        res.add "redef"
                else
-                       res.add mclass.visibility.to_s
+                       if mclass.visibility != public_visibility then
+                               res.add mclass.visibility.to_s
+                       end
                end
                res.add mclass.kind.to_s
                return res
@@ -895,17 +888,6 @@ redef class MClassDef
                return mclassdefs
        end
 
-       redef fun collect_ancestors(view) do
-               var res = new HashSet[MENTITY]
-               var hierarchy = self.in_hierarchy
-               if hierarchy == null then return res
-               for parent in hierarchy.greaters do
-                       if parent == self or not view.accept_mentity(parent) then continue
-                       res.add parent
-               end
-               return res
-       end
-
        redef fun collect_parents(view) do
                var res = new HashSet[MENTITY]
                var hierarchy = self.in_hierarchy
@@ -1042,7 +1024,9 @@ redef class MPropDef
                if not is_intro then
                        res.add "redef"
                else
-                       res.add mproperty.visibility.to_s
+                       if mproperty.visibility != public_visibility then
+                               res.add mproperty.visibility.to_s
+                       end
                end
                var mprop = self
                if mprop isa MVirtualTypeDef then