model: promote `full_name` to MEntity
authorJean Privat <jean@pryen.org>
Tue, 16 Dec 2014 04:05:32 +0000 (23:05 -0500)
committerJean Privat <jean@pryen.org>
Wed, 17 Dec 2014 04:52:46 +0000 (23:52 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/metrics/detect_variance_constraints.nit
src/model/mmodule.nit
src/model/model.nit
src/model/model_base.nit
src/model/mproject.nit

index 0319572..1f73fab 100644 (file)
@@ -76,11 +76,6 @@ private class DetectVarianceConstraintsPhase
        end
 end
 
-redef class MParameterType
-       # The fully-qualified name of the formal parameter.
-       fun full_name: String do return "{mclass.full_name}::{name}"
-end
-
 # A specific analysis that detects the variance constraints of formal parameters.
 #
 # The client has 3 steps to do:
index c634815..2fbb424 100644 (file)
@@ -88,10 +88,14 @@ class MModule
        # The view of the module in the `model.mmodule_importation_hierarchy`
        var in_importation: POSetElement[MModule] is noinit
 
-       # The canonical name of the module
+       # The canonical name of the module.
+       #
+       # It is usually the `name` prefixed by the project's name.
        # Example: `"project::name"`
-       fun full_name: String
-       do
+       #
+       # If both names are the same (of if the module is project-less), then
+       # the short-name is used alone.
+       redef var full_name is lazy do
                var mgroup = self.mgroup
                if mgroup == null or mgroup.mproject.name == self.name then
                        return self.name
index 9c7a877..f84b38f 100644 (file)
@@ -358,11 +358,10 @@ class MClass
        redef var name: String
 
        # The canonical name of the class
+       #
+       # It is the name of the class prefixed by the full_name of the `intro_mmodule`
        # Example: `"owner::module::MyClass"`
-       fun full_name: String
-       do
-               return "{self.intro_mmodule.full_name}::{name}"
-       end
+       redef var full_name is lazy do return "{self.intro_mmodule.full_name}::{name}"
 
        # The number of generic formal parameters
        # 0 if the class is not generic
@@ -1668,11 +1667,12 @@ abstract class MProperty
        # The (short) name of the property
        redef var name: String
 
-       # The canonical name of the property
-       # Example: "owner::my_module::MyClass::my_method"
-       fun full_name: String
-       do
-               return "{self.intro_mclassdef.mmodule.full_name}::{self.intro_mclassdef.mclass.name}::{name}"
+       # The canonical name of the property.
+       #
+       # It is the short-`name` prefixed by the short-name of the class and the full-name of the module.
+       # Example: "my_project::my_module::MyClass::my_method"
+       redef var full_name is lazy do
+               return "{intro_mclassdef.mmodule.full_name}::{intro_mclassdef.mclass.name}::{name}"
        end
 
        # The visibility of the property
index 4ee1eb6..ba2d5e3 100644 (file)
@@ -25,9 +25,28 @@ end
 # A named and possibly documented entity in the model.
 # This class is useful to generalize presentation of entities to the human.
 abstract class MEntity
-       # The short (unqualified) name of this model entity
+       # The short (unqualified) name of this model entity.
+       #
+       # The short-name is based from the identifiers used to declare or denote the entity.
+       # It is usually globally ambiguous but is often enough in a precise local context.
+       #
+       # It is suitable to use the short-name in message to the user.
+       # However, special care must be used in case of potential ambiguities or name conflict.
        fun name: String is abstract
 
+       # A fully-qualified name of this model entity.
+       #
+       # The full-name is based on the short name and is usually prefixed by the name of an outer entity.
+       # Usually the quad (`::`) is used to separate the different names.
+       #
+       # The full-name is expected to be unique and unambiguous in lawful Nit models for the same kind of entity.
+       #
+       # It is often suitable to use it in message to the user.
+       # However, some full-name could be long and verbose,
+       #
+       # See the specific implementation in subclasses for details.
+       fun full_name: String is abstract
+
        # A Model Entity has a direct link to its model
        fun model: Model is abstract
 end
index b89eced..9002009 100644 (file)
@@ -69,8 +69,9 @@ class MGroup
        # see `in_nesting` for more
        var parent: nullable MGroup
 
-       # fully qualified name
-       fun full_name: String
+       # Fully qualified name.
+       # It includes each parent group separated by `/`
+       redef fun full_name
        do
                var p = parent
                if p == null then return name