modelize_property: add annotation `lazy`
authorJean Privat <jean@pryen.org>
Mon, 21 Jul 2014 19:58:45 +0000 (15:58 -0400)
committerJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 11:58:08 +0000 (07:58 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/modelize_property.nit

index 96ec598..9c269d5 100644 (file)
@@ -645,10 +645,14 @@ redef class AAttrPropdef
        # Is the node tagged `noinit`?
        var noinit = false
 
+       # Is the node taggeg lazy?
+       var is_lazy = false
+
        # The associated getter (read accessor) if any
        var mreadpropdef: nullable MMethodDef writable
        # The associated setter (write accessor) if any
        var mwritepropdef: nullable MMethodDef writable
+
        redef fun build_property(modelbuilder, mclassdef)
        do
                var mclass = mclassdef.mclass
@@ -718,6 +722,14 @@ redef class AAttrPropdef
                        modelbuilder.mpropdef2npropdef[mreadpropdef] = self
                        mreadpropdef.mdoc = mpropdef.mdoc
 
+                       var atlazy = self.get_single_annotation("lazy", modelbuilder)
+                       if atlazy != null then
+                               if n_expr == null then
+                                       modelbuilder.error(atlazy, "Error: a lazy attribute needs a value")
+                               end
+                               is_lazy = true
+                       end
+
                        var atreadonly = self.get_single_annotation("readonly", modelbuilder)
                        if atreadonly != null then
                                if n_expr == null then