modelize_class: adapt MClass and MClassDef creation to new mparameters
[nit.git] / src / model / mproject.nit
index 9c1765f..72f2114 100644 (file)
@@ -21,14 +21,16 @@ import poset
 
 # A Nit project, thas encompass a product
 class MProject
+       super MConcern
+
        # The name of the project
-       var name: String
+       redef var name: String
 
        # The model of the project
-       var model: Model
+       redef var model: Model
 
        # The root of the group tree
-       var root: nullable MGroup writable = null
+       var root: nullable MGroup = null is writable
 
        # The group tree, as a POSet
        var mgroups = new POSet[MGroup]
@@ -42,13 +44,18 @@ class MProject
                model.mprojects.add(self)
                model.mproject_by_name.add_one(name, self)
        end
+
+       # MProject are always roots of the concerns hierarchy
+       redef fun parent_concern do return null
 end
 
 # A group of modules in a project
 class MGroup
+       super MConcern
+
        # The name of the group
        # empty name for a default group in a single-module project
-       var name: String
+       redef var name: String
 
        # The englobing project
        var mproject: MProject
@@ -70,8 +77,11 @@ class MGroup
        # nesting group (see `parent`) is bigger
        var in_nesting: POSetElement[MGroup]
 
+       # Is `self` the root of its project?
+       fun is_root: Bool do return mproject.root == self
+
        # The filepath (usualy a directory) of the group, if any
-       var filepath: nullable String writable
+       var filepath: nullable String is writable
 
        init (name: String, mproject: MProject, parent: nullable MGroup)
        do
@@ -85,6 +95,13 @@ class MGroup
                end
        end
 
+       redef fun model do return mproject.model
+
+       redef fun parent_concern do
+               if not is_root then return parent
+               return mproject
+       end
+
        redef fun to_s do return name
 end