model/model_contract: Move contract model representation
[nit.git] / src / model / model_viz.nit
index 66ab460..06f2fb6 100644 (file)
@@ -19,16 +19,15 @@ import model
 import ordered_tree
 
 # A simple specialisation of OrderedTree to display packages, groups and modules
-# FIXME do not use Object, but a better common interface of MModule and MGroup
 class MPackageTree
-       super OrderedTree[Object]
+       super OrderedTree[MConcern]
 
        # The model where to look for information
        var model: Model
 
        redef fun display(a) do
                if a isa MGroup then
-                       if a.parent == null then return "{a.mpackage.name} ({a.filepath.to_s})"
+                       if a.parent == null then return "{a.mpackage.name} ({a.filepath or else "?"})"
                        return a.name + " (group)"
                else if a isa MModule then
                        return a.name
@@ -58,11 +57,10 @@ class MPackageTree
 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
 
-       redef type COMPARED: Object
+       redef type COMPARED: MConcern
 
        var mins = new HashMap [MGroup, nullable MModule]
        var maxs = new HashMap [MGroup, nullable MModule]
@@ -87,7 +85,7 @@ private class LinexComparator
                var subs = tree.sub[o]
                var minres = mini(subs.first)
                var maxres = maxi(subs.first)
-               var order = minres.model.mmodule_importation_hierarchy
+               var order = o.model.mmodule_importation_hierarchy
                for o2 in subs do
                        var c = mini(o2)
                        if c == null then continue
@@ -111,7 +109,7 @@ private class LinexComparator
                var order = ma.model.mmodule_importation_hierarchy
                return order.compare(ma, mb)
        end
-       var tree: OrderedTree[Object]
+       var tree: OrderedTree[MConcern]
 end
 
 redef class Model
@@ -167,7 +165,7 @@ class MPackageDot
                if mgroup.parent == null then
                        # is is a root group, so display the package
                        if package_group then
-                               o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mpackage.name}\\n({mgroup.filepath.to_s})\"\ncolor=black\nstyle=dotted\n")
+                               o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mpackage.name}\\n({mgroup.filepath or else "?"})\"\ncolor=black\nstyle=dotted\n")
                        end
                else
                        if cluster_group then