X-Git-Url: http://nitlanguage.org diff --git a/src/model/model_base.nit b/src/model/model_base.nit index 396d5e1..0a0d8b0 100644 --- a/src/model/model_base.nit +++ b/src/model/model_base.nit @@ -16,10 +16,19 @@ # The abstract concept of model and related common things module model_base +import location # The container class of a Nit object-oriented model. # A model knows modules, classes and properties and can retrieve them. class Model + super MEntity + + redef fun model do return self + + # Place-holder object that means no-location + # + # See `MEntity::location` + var no_location = new Location(null, 0, 0, 0, 0) end # A named and possibly documented entity in the model. @@ -62,8 +71,43 @@ abstract class MEntity # indirect use should be restricted (e.g. to name a web-page) fun c_name: String is abstract + # The origin of the definition. + # + # Most model entities are defined in a specific place in the source base. + # + # Because most model entities have one, + # it is simpler for the client to have a non-nullable return value. + # For entities that lack a location, mock-up special locations are used instead. + # By default it is `model.no_location`. + fun location: Location do return model.no_location + # A Model Entity has a direct link to its model fun model: Model is abstract + + # The indication that the entity did not pass some semantic verifications. + # + # This simple flag is set by a given analysis to say that the entity is broken and unusable in + # an execution. + # When an entity status is set to broken, it is usually associated with a error message. + # + # If it is safe to do so, clients of the model SHOULD just skip broken entities in their processing. + # Clients that do not care about the executability (e.g. metrics) MAY still process the entity or + # perform specific checks to determinate the validity of the entity. + # + # Note that the broken status is not propagated to enclosing and enclosed entities. + # e.g. a broken method does not make the whole module broken. + var is_broken = false is writable + + # Is `self` created for internal purpose? + # + # Fictive entities are used internally but they should not be + # exposed to the final user. + var is_fictive: Bool = false is writable + + # Is `self` created for unit testing purpose? + # + # See `nitunit`. + var is_test: Bool = false is writable end # Something that represents a concern