-# A Nit module is usually associated with a Nit source file.
-# Modules can be nested (see `direct_owner', `public_owner', and `in_nesting')
-class MModule
- # The model considered
- var model: Model
-
- # The direct nesting module, return null if self is not nested (ie. is a top-level module)
- var direct_owner: nullable MModule
-
- # The short name of the module
- var name: String
-
- # The origin of the definition
- var location: Location
-
- # Alias for `name'
- redef fun to_s do return self.name
-
- # The view of the module in the module_nesting_hierarchy
- var in_nesting: POSetElement[MModule]
-
- # The view of the module in the module_importation_hierarchy
- var in_importation: POSetElement[MModule]
-
- # The canonical name of the module
- # Example: "owner::name"
- fun full_name: String
- do
- var owner = self.public_owner
- if owner == null then
- return self.name
- else
- return "{owner.full_name}::{self.name}"
- end
- end
-
- # Create a new empty module and register it to a model
- # `direct_owner' is the direct owner (null if top-level module)
- init(model: Model, direct_owner: nullable MModule, name: String, location: Location)
- do
- self.model = model
- self.name = name
- self.location = location
- model.mmodules_by_name.add_one(name, self)
- model.mmodules.add(self)
- self.in_nesting = model.mmodule_nesting_hierarchy.add_node(self)
- self.direct_owner = direct_owner
- if direct_owner != null then
- model.mmodule_nesting_hierarchy.add_edge(direct_owner, self)
- end
- self.in_importation = model.mmodule_importation_hierarchy.add_node(self)
- 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-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