modelize: `mpropdef2node` and `collect_attr_propdef` can process npropdef lazily
authorJean Privat <jean@pryen.org>
Fri, 19 Dec 2014 17:07:12 +0000 (12:07 -0500)
committerJean Privat <jean@pryen.org>
Sat, 27 Dec 2014 04:51:12 +0000 (23:51 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize/modelize_property.nit

index fef5ca9..f270c8d 100644 (file)
@@ -44,11 +44,16 @@ redef class ModelBuilder
        # Retrieve the associated AST node of a mpropertydef.
        # This method is used to associate model entity with syntactic entities.
        #
-       # If the property definition is not associated with a node, returns node.
+       # If the property definition is not associated with a node, returns `null`.
        fun mpropdef2node(mpropdef: MPropDef): nullable ANode
        do
-               var res: nullable ANode = mpropdef2npropdef.get_or_null(mpropdef)
-               if res != null then return res
+               var res
+               res = mpropdef2npropdef.get_or_null(mpropdef)
+               if res != null then
+                       # Run the phases on it
+                       toolcontext.run_phases_on_npropdef(res)
+                       return res
+               end
                if mpropdef isa MMethodDef and mpropdef.mproperty.is_root_init then
                        res = mclassdef2nclassdef.get_or_null(mpropdef.mclassdef)
                        if res != null then return res
@@ -65,6 +70,8 @@ redef class ModelBuilder
                if n == null then return res
                for npropdef in n.n_propdefs do
                        if npropdef isa AAttrPropdef then
+                               # Run the phases on it
+                               toolcontext.run_phases_on_npropdef(npropdef)
                                res.add(npropdef)
                        end
                end