nitc :: ModelFilter
By default ModelFilter accepts all mentity.
var filter = new ModelFilter
assert filter.accept_mentity(my_mentity) == true
To quickly configure the filters, options can be passed to the constructor:
var filter = new ModelFilter(
min_visibility = protected_visibility,
accept_fictive = false,
accept_test = false,
accept_redef = false,
accept_extern = false,
accept_attribute = false,
accept_empty_doc = false
)
nitc :: ModelFilter :: _accept_attribute
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: _accept_broken
Accept broken classes and properties?nitc :: ModelFilter :: _accept_empty_doc
Accept entities with empty documentation?nitc :: ModelFilter :: _accept_full_name
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: _accept_generated
Accept generated entities?nitc :: ModelFilter :: _accept_inherited
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: _accept_redef
Accept redef classdefs and propdefs?nitc :: ModelFilter :: _min_visibility
Minimum visibility an entity must have to be acceptednitc :: ModelFilter :: accept_attribute
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: accept_attribute=
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: accept_broken=
Accept broken classes and properties?nitc :: ModelFilter :: accept_empty_doc
Accept entities with empty documentation?nitc :: ModelFilter :: accept_empty_doc=
Accept entities with empty documentation?nitc :: ModelFilter :: accept_example=
Accept examples?nitc :: ModelFilter :: accept_extern=
Accept extern entities?nitc :: ModelFilter :: accept_fictive=
Accept fictive entities?nitc :: ModelFilter :: accept_full_name
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_full_name=
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_generated=
Accept generated entities?nitc :: ModelFilter :: accept_inherited
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_inherited=
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_mentity
Acceptmentity
based on all the options from self
?
nitc :: ModelFilter :: accept_mentity_attribute
Accept only entities that are not aMAttribute
or MAttributeDef
nitc :: ModelFilter :: accept_mentity_broken
Accept only non broken entitiesnitc :: ModelFilter :: accept_mentity_empty_doc
Accept only entities with documentationnitc :: ModelFilter :: accept_mentity_example
Accept only entities that are not example relatednitc :: ModelFilter :: accept_mentity_extern
Accept only non- extern entitiesnitc :: ModelFilter :: accept_mentity_fictive
Accept only non-fictive entitiesnitc :: ModelFilter :: accept_mentity_full_name
Accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_mentity_generated
Accept only non-generated entitiesnitc :: ModelFilter :: accept_mentity_inherited
Accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_mentity_redef
Accept a MClassDefs and MPropeDefs onyl if they are an introductionnitc :: ModelFilter :: accept_mentity_test
Accept only entities that are notnitunit
related
nitc :: ModelFilter :: accept_mentity_visibility
Acceptmentity
if its visibility is above min_visibility
nitc :: ModelFilter :: accept_redef=
Accept redef classdefs and propdefs?nitc :: ModelFilter :: accept_test=
Accept nitunit test suites?nitc :: ModelFilter :: defaultinit
nitc :: ModelFilter :: from
Initializeself
by copying the options from another filter
nitc :: ModelFilter :: min_visibility
Minimum visibility an entity must have to be acceptednitc :: ModelFilter :: min_visibility=
Minimum visibility an entity must have to be acceptednitc $ ModelFilter :: SELF
Type of this instance, automatically specialized in every classnitc :: ModelFilter :: _accept_attribute
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: _accept_broken
Accept broken classes and properties?nitc :: ModelFilter :: _accept_empty_doc
Accept entities with empty documentation?nitc :: ModelFilter :: _accept_full_name
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: _accept_generated
Accept generated entities?nitc :: ModelFilter :: _accept_inherited
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: _accept_redef
Accept redef classdefs and propdefs?nitc :: ModelFilter :: _min_visibility
Minimum visibility an entity must have to be acceptednitc :: ModelFilter :: accept_attribute
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: accept_attribute=
AcceptMAttribute
and MAttributeDef
instances?
nitc :: ModelFilter :: accept_broken=
Accept broken classes and properties?nitc :: ModelFilter :: accept_empty_doc
Accept entities with empty documentation?nitc :: ModelFilter :: accept_empty_doc=
Accept entities with empty documentation?nitc :: ModelFilter :: accept_example=
Accept examples?nitc :: ModelFilter :: accept_extern=
Accept extern entities?nitc :: ModelFilter :: accept_fictive=
Accept fictive entities?nitc :: ModelFilter :: accept_full_name
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_full_name=
If set, accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_generated=
Accept generated entities?nitc :: ModelFilter :: accept_inherited
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_inherited=
If set, accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_mentity
Acceptmentity
based on all the options from self
?
nitc :: ModelFilter :: accept_mentity_attribute
Accept only entities that are not aMAttribute
or MAttributeDef
nitc :: ModelFilter :: accept_mentity_broken
Accept only non broken entitiesnitc :: ModelFilter :: accept_mentity_empty_doc
Accept only entities with documentationnitc :: ModelFilter :: accept_mentity_example
Accept only entities that are not example relatednitc :: ModelFilter :: accept_mentity_extern
Accept only non- extern entitiesnitc :: ModelFilter :: accept_mentity_fictive
Accept only non-fictive entitiesnitc :: ModelFilter :: accept_mentity_full_name
Accept only entities whereMEntity::full_name
contains string
nitc :: ModelFilter :: accept_mentity_generated
Accept only non-generated entitiesnitc :: ModelFilter :: accept_mentity_inherited
Accept only entities local toaccept_inherited
nitc :: ModelFilter :: accept_mentity_redef
Accept a MClassDefs and MPropeDefs onyl if they are an introductionnitc :: ModelFilter :: accept_mentity_test
Accept only entities that are notnitunit
related
nitc :: ModelFilter :: accept_mentity_visibility
Acceptmentity
if its visibility is above min_visibility
nitc :: ModelFilter :: accept_redef=
Accept redef classdefs and propdefs?nitc :: ModelFilter :: accept_test=
Accept nitunit test suites?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
nitc :: ModelFilter :: defaultinit
nitc :: ModelFilter :: from
Initializeself
by copying the options from another filter
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.
nitc :: ModelFilter :: min_visibility
Minimum visibility an entity must have to be acceptednitc :: ModelFilter :: min_visibility=
Minimum visibility an entity must have to be acceptedcore :: 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).
# A list of filters that can be applied on a MEntity
#
#
# By default ModelFilter accepts all mentity.
#
# ~~~nitish
# var filter = new ModelFilter
# assert filter.accept_mentity(my_mentity) == true
# ~~~
#
# To quickly configure the filters, options can be passed to the constructor:
# ~~~
# var filter = new ModelFilter(
# min_visibility = protected_visibility,
# accept_fictive = false,
# accept_test = false,
# accept_redef = false,
# accept_extern = false,
# accept_attribute = false,
# accept_empty_doc = false
# )
# ~~~
class ModelFilter
# Initialize `self` by copying the options from another `filter`
init from(filter: ModelFilter) do
init(
min_visibility = filter.min_visibility,
accept_fictive = filter.accept_fictive,
accept_test = filter.accept_test,
accept_redef = filter.accept_redef,
accept_extern = filter.accept_extern,
accept_example = filter.accept_example,
accept_attribute = filter.accept_attribute,
accept_empty_doc = filter.accept_empty_doc,
accept_inherited = filter.accept_inherited,
accept_full_name = filter.accept_full_name
)
end
# Accept `mentity` based on all the options from `self`?
#
# If one of the filter returns `false` then the `mentity` is not accepted.
fun accept_mentity(mentity: MEntity): Bool do
if not accept_mentity_broken(mentity) then return false
if not accept_mentity_visibility(mentity) then return false
if not accept_mentity_fictive(mentity) then return false
if not accept_mentity_generated(mentity) then return false
if not accept_mentity_test(mentity) then return false
if not accept_mentity_redef(mentity) then return false
if not accept_mentity_extern(mentity) then return false
if not accept_mentity_example(mentity) then return false
if not accept_mentity_attribute(mentity) then return false
if not accept_mentity_empty_doc(mentity) then return false
if not accept_mentity_inherited(mentity) then return false
if not accept_mentity_full_name(mentity) then return false
return true
end
# Minimum visibility an entity must have to be accepted
#
# Default is `private_visibility`.
var min_visibility: MVisibility = private_visibility is optional, writable
# Accept `mentity` if its visibility is above `min_visibility`
fun accept_mentity_visibility(mentity: MEntity): Bool do
return mentity.visibility >= min_visibility
end
# Accept fictive entities?
#
# Default is `true`.
var accept_fictive = true is optional, writable
# Accept only non-fictive entities
#
# See `MEntity::is_fictive`.
fun accept_mentity_fictive(mentity: MEntity): Bool do
if accept_fictive then return true
return not mentity.is_fictive
end
# Accept generated entities?
#
# Default is `true`.
var accept_generated = true is optional, writable
# Accept only non-generated entities
#
# See `MEntity::is_generated`.
fun accept_mentity_generated(mentity: MEntity): Bool do
if accept_generated then return true
if mentity isa MClass then mentity = mentity.intro
if mentity isa MProperty then mentity = mentity.intro
if mentity isa MModule then
return not mentity.has_annotation("generated")
else if mentity isa MClassDef then
return not mentity.has_annotation("generated")
else if mentity isa MPropDef then
return not mentity.has_annotation("generated")
end
return true
end
# Accept nitunit test suites?
#
# Default is `true`.
var accept_test = true is optional, writable
# Accept only entities that are not `nitunit` related
fun accept_mentity_test(mentity: MEntity): Bool do
if accept_test then return true
if mentity isa MProperty then return accept_mentity(mentity.intro)
if mentity isa MMethodDef then
if mentity.is_before then return false
if mentity.is_before_all then return false
if mentity.is_after then return false
if mentity.is_after_all then return false
end
return not mentity.is_test
end
# Accept redef classdefs and propdefs?
#
# Default is `true`.
var accept_redef = true is optional, writable
# Accept a MClassDefs and MPropeDefs onyl if they are an introduction
#
# See `MClassDef::is_intro` and `MPropDef::is_intro`.
fun accept_mentity_redef(mentity: MEntity): Bool do
if accept_redef then return true
if mentity isa MClassDef then
return mentity.is_intro
else if mentity isa MPropDef then
return mentity.is_intro
end
return true
end
# Accept extern entities?
#
# Default is `true`.
var accept_extern = true is optional, writable
# Accept only non- extern entities
#
# See `MEntity::is_extern`.
fun accept_mentity_extern(mentity: MEntity): Bool do
if accept_extern then return true
if mentity isa MMethodDef then
return not mentity.is_extern
end
return true
end
# Accept `MAttribute` and `MAttributeDef` instances?
#
# Default is `true`.
var accept_attribute = true is optional, writable
# Accept only entities that are not a `MAttribute` or `MAttributeDef`
fun accept_mentity_attribute(mentity: MEntity): Bool do
if accept_attribute then return true
if mentity isa MAttribute then return false
if mentity isa MAttributeDef then return false
return true
end
# Accept entities with empty documentation?
#
# Default is `true`.
var accept_empty_doc = true is optional, writable
# Accept only entities with documentation
fun accept_mentity_empty_doc(mentity: MEntity): Bool do
if accept_empty_doc then return true
return mentity.mdoc_or_fallback != null
end
# Accept examples?
#
# Default is `true`.
var accept_example = true is optional, writable
# Accept only entities that are not example related
fun accept_mentity_example(mentity: MEntity): Bool do
if accept_example then return true
return not mentity.is_example
end
# If set, accept only entities local to `accept_inherited`
var accept_inherited: nullable MEntity = null is optional, writable
# Accept only entities local to `accept_inherited`
#
# This means no imported or inherited entities.
fun accept_mentity_inherited(mentity: MEntity): Bool do
var context = accept_inherited
if context == null then return true
if context isa MPackage then
if mentity isa MGroup then return mentity.mpackage == context
if mentity isa MModule then return mentity.mpackage == context
end
if context isa MGroup then
if mentity isa MModule then return mentity.mgroup == context
end
if context isa MModule then
if mentity isa MClass then return mentity.intro.mmodule == context
if mentity isa MClassDef then return mentity.mmodule == context
end
if context isa MClass then
if mentity isa MProperty then return mentity.intro_mclassdef.mclass == context
if mentity isa MPropDef then return mentity.mclassdef.mclass == context
end
if context isa MClassDef then
if mentity isa MProperty then return mentity.intro_mclassdef == context
if mentity isa MPropDef then return mentity.mclassdef == context
end
return true
end
# If set, accept only entities where `MEntity::full_name` contains `string`
var accept_full_name: nullable String = null is optional, writable
# Accept only entities where `MEntity::full_name` contains `string`
fun accept_mentity_full_name(mentity: MEntity): Bool do
var string = accept_full_name
if string == null then return true
return mentity.full_name.has(string)
end
# Accept broken classes and properties?
#
# Default is `false`.
var accept_broken = false is optional, writable
# Accept only non broken entities
fun accept_mentity_broken(mentity: MEntity): Bool do
if accept_broken then return true
return not mentity.is_broken
end
end
src/model/model_filters.nit:20,1--262,3