Merge: modelbuilder_base: Define ANode as nullable
authorJean Privat <jean@pryen.org>
Mon, 20 Apr 2020 13:14:26 +0000 (09:14 -0400)
committerJean Privat <jean@pryen.org>
Mon, 20 Apr 2020 13:14:26 +0000 (09:14 -0400)
Definition of ANode as nullable. When you create entities manually there is not necessarily a current attachment point (in the ast). It is therefore more practical to provide a service with the ANode which can be null.

In addition, the `fun error (n: nullable ANode, text: String)` method that will be called already handles this case.

Pull-Request: #2816

src/modelize/modelize_property.nit

index 7aeffe8..a7acef6 100644 (file)
@@ -53,6 +53,17 @@ redef class ModelBuilder
                mpropdef2npropdef[mpropdef] = npropdef
        end
 
+       # Associate a `nclassdef` with its `mclassdef`
+       #
+       # Be careful, this method is unsafe, no checking is done when it's used.
+       # The safe way to add mclass it's to use the `build_property`
+       #
+       # See `mclassdef2nclassdef`
+       fun unsafe_add_mclassdef2nclassdef(mclassdef: MClassDef, nclassdef: AClassdef)
+       do
+               mclassdef2nclassdef[mclassdef] = nclassdef
+       end
+
        # Retrieve the associated AST node of a mpropertydef.
        # This method is used to associate model entity with syntactic entities.
        #