Rename REAMDE to README.md
[nit.git] / src / model / model_viz.nit
index 20be8c3..305cd23 100644 (file)
@@ -26,8 +26,6 @@ class MProjectTree
        # The model where to look for information
        var model: Model
 
-       init(model: Model) do self.model = model
-
        redef fun display(a) do
                if a isa MGroup then
                        if a.parent == null then return "{a.mproject.name} ({a.filepath.to_s})"
@@ -47,7 +45,7 @@ class MProjectTree
                sort_with(alpha_comparator)
        end
 
-       # Sort modules and groups with a loosly adaptation of the linerarisation of modules
+       # Sort modules and groups with a loosely adaptation of the linearization of modules
        fun sort_with_linex
        do
                var c = linex_comparator
@@ -62,16 +60,19 @@ end
 # Compare modules and groups using the
 # FIXME do not use Object, but a better common interface of MModule and MGroup
 private class LinexComparator
-       super Comparator[Object]
+       super Comparator
+
+       redef type COMPARED: Object
+
        var mins = new HashMap [MGroup, nullable MModule]
        var maxs = new HashMap [MGroup, nullable MModule]
-       fun min(o: Object): nullable MModule do
+       fun mini(o: Object): nullable MModule do
                if o isa MModule then return o
                assert o isa MGroup
                if not mins.has_key(o) then computeminmax(o)
                return mins[o]
        end
-       fun max(o: Object): nullable MModule do
+       fun maxi(o: Object): nullable MModule do
                if o isa MModule then return o
                assert o isa MGroup
                if not maxs.has_key(o) then computeminmax(o)
@@ -84,14 +85,14 @@ private class LinexComparator
                        return
                end
                var subs = tree.sub[o]
-               var minres = min(subs.first)
-               var maxres = max(subs.first)
+               var minres = mini(subs.first)
+               var maxres = maxi(subs.first)
                var order = minres.model.mmodule_importation_hierarchy
                for o2 in subs do
-                       var c = min(o2)
+                       var c = mini(o2)
                        if c == null then continue
                        if minres == null or order.compare(minres, c) > 0 then minres = c
-                       c = max(o2)
+                       c = maxi(o2)
                        if c == null then continue
                        if maxres == null or order.compare(maxres, c) < 0 then maxres = c
                end
@@ -100,8 +101,8 @@ private class LinexComparator
                #if minres != maxres then print "* {o} {minres}..{maxres}"
        end
        redef fun compare(a,b) do
-               var ma = min(a)
-               var mb = min(b)
+               var ma = mini(a)
+               var mb = mini(b)
                if ma == null then
                        if mb == null then return 0 else return -1
                else if mb == null then
@@ -132,10 +133,10 @@ end
 
 # Generate graphiz files based on projects, groups and modules
 #
-# Interessing elements must be selected. See `mmodules`, ``
+# Interesting elements must be selected. See `mmodules`, ``
 # Display configuration can be set. See `cluster_group`, `project_group`
 class MProjectDot
-       super Streamable
+       super Writable
 
        # The model where to look for information
        var model: Model
@@ -154,13 +155,13 @@ class MProjectDot
        end
 
        # Should groups be shown as clusters?
-       var cluster_group writable = true
+       var cluster_group = true is writable
 
        # Should projects be shown as clusters?
-       var project_group writable = true
+       var project_group = true is writable
 
-       # Recursively generate noed ans clusters for a mroup
-       private fun dot_cluster(o: OStream, mgroup: MGroup)
+       # Recursively generate node and clusters for a mgroup
+       private fun dot_cluster(o: Writer, mgroup: MGroup)
        do
                # Open the cluster, if required
                if mgroup.parent == null then
@@ -180,7 +181,7 @@ class MProjectDot
                        o.write("\t{node_for(mmodule)} [label=\"{mmodule.name}\",color=green]\n")
                end
 
-               # recusively progress on sub-clusters
+               # recursively progress on sub-clusters
                for d in mgroup.in_nesting.direct_smallers do
                        dot_cluster(o, d)
                end
@@ -193,7 +194,7 @@ class MProjectDot
                end
        end
 
-       # Extends the set of `mmodules` by recurdively adding the most specific imported modules of foreign projects
+       # Extends the set of `mmodules` by recursively adding the most specific imported modules of foreign projects
        fun collect_important_importation
        do
                var todo = new List[MModule]
@@ -215,7 +216,7 @@ class MProjectDot
        # Generate the dot content with the current configuration
        redef fun write_to(stream)
        do
-               # Collect interessing nodes
+               # Collect interesting nodes
                for m in model.mmodules do
                        # filter out modules outside wanted projects
                        if m.mgroup == null then continue
@@ -226,7 +227,7 @@ class MProjectDot
 
                collect_important_importation
 
-               # Collect interessing edges
+               # Collect interesting edges
                var sub_hierarchy = new POSet[MModule]
                for m in mmodules do
                        sub_hierarchy.add_node(m)