nitc :: ModelVisitor
Specific visitor must implement the visit
method to perform the work.
nitc :: ModelVisitor :: _current_entity
The current visited entitynitc :: ModelVisitor :: _filter
Filters to apply when visiting the model.nitc :: ModelVisitor :: accept_mentity
Should we accept thismentity
from the view?
nitc :: ModelVisitor :: current_entity
The current visited entitynitc :: ModelVisitor :: current_entity=
The current visited entitynitc :: ModelVisitor :: defaultinit
nitc :: ModelVisitor :: filter=
Filters to apply when visiting the model.nitc :: ModelVisitor :: visit
Method to define in specific visitor.nitc $ ModelVisitor :: SELF
Type of this instance, automatically specialized in every classnitc :: ModelVisitor :: _current_entity
The current visited entitynitc :: ModelVisitor :: _filter
Filters to apply when visiting the model.nitc :: ModelVisitor :: accept_mentity
Should we accept thismentity
from the view?
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: ModelVisitor :: current_entity
The current visited entitynitc :: ModelVisitor :: current_entity=
The current visited entitycore :: Object :: defaultinit
nitc :: ModelVisitor :: defaultinit
nitc :: ModelVisitor :: filter=
Filters to apply when visiting the model.core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: ModelVisitor :: visit
Method to define in specific visitor.
# The abstract model visitor template.
#
# Specific visitor must implement the `visit` method to perform the work.
abstract class ModelVisitor
# Visit the entity `e`.
#
# This method setups `current_entity` and call `visit`.
# If `e` is null, nothing is done.
fun enter_visit(e: nullable MEntity) do
if e == null then return
if not accept_mentity(e) then return
var old_entity = current_entity
current_entity = e
visit(e)
current_entity = old_entity
end
# The current visited entity
var current_entity: nullable MEntity = null
# Method to define in specific visitor.
#
# It should not be called directly but used by `enter_visit`
protected fun visit(e: MEntity) is abstract
# Filters to apply when visiting the model.
#
# See ModelFilters for configuration.
var filter: ModelFilter is lazy, writable, optional do
return new ModelFilter(
min_visibility = protected_visibility,
accept_fictive = false,
accept_test = false,
accept_example = false,
accept_redef = true,
accept_extern = true,
accept_attribute = true,
accept_empty_doc = true
)
end
# Should we accept this `mentity` from the view?
#
# If no `override_filter` is passed then use `self.filter`.
fun accept_mentity(mentity: MEntity, override_filter: nullable ModelFilter): Bool do
if override_filter != null then
return override_filter.accept_mentity(mentity)
end
return filter.accept_mentity(mentity)
end
end
src/model/model_visitor.nit:46,1--97,3