typing: allow `new` on interface and abstract classes that have a `new`-factory
[nit.git] / src / neo.nit
index b44d034..f9d3c9a 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Save and load `Model` from/to Neo4j base.
+# Save and load a `Model` to/from a Neo4j graph.
 #
 # Nit models are composed by MEntities.
 # This module creates NeoNode for each MEntity found in a `Model` and save them
 # into Neo4j database.
 #
-# see `Neo4jClient`.
+# SEE: `Neo4jClient`
 #
 # NeoNodes can also be translated back to MEntities to rebuild a Nit `Model`.
 #
-# Structure of the nit `Model` in base:
+# Structure of the nit `Model` in the graph:
 #
 # Note : Any null or empty attribute will not be saved in the database.
 #
 #
 # * labels: `MClass`, `model_name` and `MEntity`.
 # * `full_name`: fully qualified name.
-# * `arity`: number of generic formal parameters. 0 if the class is not generic.
 # * `kind`: kind of the class (`interface`, `abstract class`, etc.)
 # * `visibility`: visibility of the class.
+# * `parameter_names`: JSON array listing the name of each formal generic
+# parameter (in order of declaration).
 # * `(:MClass)-[:CLASSTYPE]->(:MClassType)`: SEE: `MClass.mclass_type`
 #
 # Arguments in the `CLASSTYPE` are named following the `parameter_names`
@@ -82,8 +83,6 @@
 # * labels: `MClassDef`, `model_name` and `MEntity`.
 # * `is_intro`: Does this definition introduce the class?
 # * `location`: origin of the definition. SEE: `Location.to_s`
-# * `parameter_names`: JSON array listing the name of each formal generic
-# parameter (in order of declaration).
 # * `(:MClassDef)-[:BOUNDTYPE]->(:MClassType)`: bounded type associated to the
 # classdef.
 # * `(:MClassDef)-[:MCLASS]->(:MClass)`: associated `MClass`.
 # * `(:MMethodDef)-[:SIGNATURE]->(:MSignature)`: signature attached to the
 # property definition.
 #
+# Additional relationship for `MAttributeDef`:
+#
+# * `(:MAttributeDef)-[:TYPE]->(:MType)`: static type of the attribute,
+# if specified.
+#
 # Additional relationship for `MVirtualTypeDef`:
 #
 # * `(:MVirtualTypeDef)-[:BOUND]->(:MType)`: type to which the virtual type
 # * `(:MClassType)-[:ARGUMENT]->(:MType)`: type arguments.
 #
 # Arguments are named following the `parameter_names` attribute of the
-# `MClassDef` that introduces the class referred by `CLASS`.
+# `MClass` referred by `CLASS`.
 #
 # Additional relationship for `MVirtualType`:
 #
@@ -446,7 +450,6 @@ class NeoModel
                node.labels.add "MModule"
                node["full_name"] = mmodule.full_name
                node["location"] = mmodule.location.to_s
-               var mgroup = mmodule.mgroup
                for parent in mmodule.in_importation.direct_greaters do
                        node.out_edges.add(new NeoEdge(node, "IMPORTS", to_node(parent)))
                end
@@ -633,6 +636,10 @@ class NeoModel
                        end
                else if mpropdef isa MAttributeDef then
                        node.labels.add "MAttributeDef"
+                       var static_mtype = mpropdef.static_mtype
+                       if static_mtype != null then
+                               node.out_edges.add(new NeoEdge(node, "TYPE", to_node(static_mtype)))
+                       end
                else if mpropdef isa MVirtualTypeDef then
                        node.labels.add "MVirtualTypeDef"
                        var bound = mpropdef.bound
@@ -663,6 +670,8 @@ class NeoModel
                else if node.labels.has("MAttributeDef") then
                        mpropdef = new MAttributeDef(mclassdef, mproperty.as(MAttribute), location)
                        mentities[node] = mpropdef
+                       var static_mtype = node.out_nodes("TYPE")
+                       if not static_mtype.is_empty then mpropdef.static_mtype = to_mtype(model, static_mtype.first)
                else if node.labels.has("MVirtualTypeDef") then
                        mpropdef = new MVirtualTypeDef(mclassdef, mproperty.as(MVirtualTypeProp), location)
                        mentities[node] = mpropdef