src: reduce warnings and spelling errors
[nit.git] / src / model / mproject.nit
index 9c1765f..49ce780 100644 (file)
@@ -19,16 +19,18 @@ import model_base
 private import more_collections
 import poset
 
-# A Nit project, thas encompass a product
+# A Nit project, that 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,15 +44,20 @@ 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
+       # The enclosing project
        var mproject: MProject
 
        # The parent group if any
@@ -66,12 +73,15 @@ class MGroup
        end
 
        # The group is the group tree on the project (`mproject.mgroups`)
-       # nested groups (children) are smallers
+       # nested groups (children) are smaller
        # nesting group (see `parent`) is bigger
        var in_nesting: POSetElement[MGroup]
 
-       # The filepath (usualy a directory) of the group, if any
-       var filepath: nullable String writable
+       # Is `self` the root of its project?
+       fun is_root: Bool do return mproject.root == self
+
+       # The filepath (usually a directory) of the group, if any
+       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
 
@@ -93,7 +110,7 @@ redef class Model
        var mprojects = new Array[MProject]
 
        # Collections of project grouped by their names
-       private var mproject_by_name: MultiHashMap[String, MProject] = new MultiHashMap[String, MProject]
+       private var mproject_by_name = new MultiHashMap[String, MProject]
 
        # Return all project named `name`
        # If such a project is not yet loaded, null is returned (instead of an empty array)