model: Specify `MClassDef`s’ order once
[nit.git] / src / modelbuilder_base.nit
index 85bb115..77ba0d8 100644 (file)
@@ -348,6 +348,12 @@ class ModelBuilder
                var name = qid.n_id.text
                var qname = qid.full_name
 
+               if bad_class_names[mmodule].has(qname) then
+                       error(qid, "Error: class `{qname}` not found in module `{mmodule}`.")
+                       return
+               end
+               bad_class_names[mmodule].add(qname)
+
                var all_classes = model.get_mclasses_by_name(name)
                var hints = new Array[String]
 
@@ -404,6 +410,10 @@ class ModelBuilder
                error(qid, "Error: class `{qname}` not found in module `{mmodule}`.")
        end
 
+       # List of already reported bad class names.
+       # Used to not perform and repeat hints again and again.
+       private var bad_class_names = new MultiHashMap[MModule, String]
+
        # Return the static type associated to the node `ntype`.
        # `mmodule` and `mclassdef` is the context where the call is made (used to understand formal types)
        # In case of problem, an error is displayed on `ntype` and null is returned.
@@ -471,6 +481,14 @@ redef class ANode
        # Note that the broken status is not propagated to parent or children nodes.
        # e.g. a broken expression used as argument does not make the whole call broken.
        var is_broken = false is writable
+
+       redef fun dump_info(v) do
+               var res = super
+               if is_broken then
+                       res += v.red("*broken*")
+               end
+               return res
+       end
 end
 
 redef class AType
@@ -479,6 +497,15 @@ redef class AType
 
        # Is the mtype a valid one?
        var checked_mtype: Bool = false
+
+       redef fun dump_info(v) do
+               var res = super
+               var mtype = self.mtype
+               if mtype != null then
+                       res += v.yellow(":{mtype}")
+               end
+               return res
+       end
 end
 
 redef class AVisibility