A list of filters that can be applied on a MEntity

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
)

Introduced properties

private var _accept_attribute: Bool

nitc :: ModelFilter :: _accept_attribute

Accept MAttribute and MAttributeDef instances?
private var _accept_broken: Bool

nitc :: ModelFilter :: _accept_broken

Accept broken classes and properties?
private var _accept_empty_doc: Bool

nitc :: ModelFilter :: _accept_empty_doc

Accept entities with empty documentation?
private var _accept_example: Bool

nitc :: ModelFilter :: _accept_example

Accept examples?
private var _accept_extern: Bool

nitc :: ModelFilter :: _accept_extern

Accept extern entities?
private var _accept_fictive: Bool

nitc :: ModelFilter :: _accept_fictive

Accept fictive entities?
private var _accept_full_name: nullable String

nitc :: ModelFilter :: _accept_full_name

If set, accept only entities where MEntity::full_name contains string
private var _accept_generated: Bool

nitc :: ModelFilter :: _accept_generated

Accept generated entities?
private var _accept_inherited: nullable MEntity

nitc :: ModelFilter :: _accept_inherited

If set, accept only entities local to accept_inherited
private var _accept_redef: Bool

nitc :: ModelFilter :: _accept_redef

Accept redef classdefs and propdefs?
private var _accept_test: Bool

nitc :: ModelFilter :: _accept_test

Accept nitunit test suites?
private var _min_visibility: MVisibility

nitc :: ModelFilter :: _min_visibility

Minimum visibility an entity must have to be accepted
fun accept_attribute: Bool

nitc :: ModelFilter :: accept_attribute

Accept MAttribute and MAttributeDef instances?
fun accept_attribute=(accept_attribute: nullable Bool)

nitc :: ModelFilter :: accept_attribute=

Accept MAttribute and MAttributeDef instances?
fun accept_broken: Bool

nitc :: ModelFilter :: accept_broken

Accept broken classes and properties?
fun accept_broken=(accept_broken: nullable Bool)

nitc :: ModelFilter :: accept_broken=

Accept broken classes and properties?
fun accept_empty_doc: Bool

nitc :: ModelFilter :: accept_empty_doc

Accept entities with empty documentation?
fun accept_empty_doc=(accept_empty_doc: nullable Bool)

nitc :: ModelFilter :: accept_empty_doc=

Accept entities with empty documentation?
fun accept_example: Bool

nitc :: ModelFilter :: accept_example

Accept examples?
fun accept_example=(accept_example: nullable Bool)

nitc :: ModelFilter :: accept_example=

Accept examples?
fun accept_extern: Bool

nitc :: ModelFilter :: accept_extern

Accept extern entities?
fun accept_extern=(accept_extern: nullable Bool)

nitc :: ModelFilter :: accept_extern=

Accept extern entities?
fun accept_fictive: Bool

nitc :: ModelFilter :: accept_fictive

Accept fictive entities?
fun accept_fictive=(accept_fictive: nullable Bool)

nitc :: ModelFilter :: accept_fictive=

Accept fictive entities?
fun accept_full_name: nullable String

nitc :: ModelFilter :: accept_full_name

If set, accept only entities where MEntity::full_name contains string
fun accept_full_name=(accept_full_name: nullable String)

nitc :: ModelFilter :: accept_full_name=

If set, accept only entities where MEntity::full_name contains string
fun accept_generated: Bool

nitc :: ModelFilter :: accept_generated

Accept generated entities?
fun accept_generated=(accept_generated: nullable Bool)

nitc :: ModelFilter :: accept_generated=

Accept generated entities?
fun accept_inherited: nullable MEntity

nitc :: ModelFilter :: accept_inherited

If set, accept only entities local to accept_inherited
fun accept_inherited=(accept_inherited: nullable MEntity)

nitc :: ModelFilter :: accept_inherited=

If set, accept only entities local to accept_inherited
fun accept_mentity(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity

Accept mentity based on all the options from self?
fun accept_mentity_attribute(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_attribute

Accept only entities that are not a MAttribute or MAttributeDef
fun accept_mentity_broken(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_broken

Accept only non broken entities
fun accept_mentity_empty_doc(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_empty_doc

Accept only entities with documentation
fun accept_mentity_example(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_example

Accept only entities that are not example related
fun accept_mentity_extern(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_extern

Accept only non- extern entities
fun accept_mentity_fictive(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_fictive

Accept only non-fictive entities
fun accept_mentity_full_name(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_full_name

Accept only entities where MEntity::full_name contains string
fun accept_mentity_generated(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_generated

Accept only non-generated entities
fun accept_mentity_inherited(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_inherited

Accept only entities local to accept_inherited
fun accept_mentity_redef(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_redef

Accept a MClassDefs and MPropeDefs onyl if they are an introduction
fun accept_mentity_test(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_test

Accept only entities that are not nitunit related
fun accept_mentity_visibility(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_visibility

Accept mentity if its visibility is above min_visibility
fun accept_redef: Bool

nitc :: ModelFilter :: accept_redef

Accept redef classdefs and propdefs?
fun accept_redef=(accept_redef: nullable Bool)

nitc :: ModelFilter :: accept_redef=

Accept redef classdefs and propdefs?
fun accept_test: Bool

nitc :: ModelFilter :: accept_test

Accept nitunit test suites?
fun accept_test=(accept_test: nullable Bool)

nitc :: ModelFilter :: accept_test=

Accept nitunit test suites?
init defaultinit(min_visibility: nullable MVisibility, accept_fictive: nullable Bool, accept_generated: nullable Bool, accept_test: nullable Bool, accept_redef: nullable Bool, accept_extern: nullable Bool, accept_attribute: nullable Bool, accept_empty_doc: nullable Bool, accept_example: nullable Bool, accept_inherited: nullable MEntity, accept_full_name: nullable String, accept_broken: nullable Bool)

nitc :: ModelFilter :: defaultinit

init from(filter: ModelFilter)

nitc :: ModelFilter :: from

Initialize self by copying the options from another filter
fun min_visibility: MVisibility

nitc :: ModelFilter :: min_visibility

Minimum visibility an entity must have to be accepted
fun min_visibility=(min_visibility: nullable MVisibility)

nitc :: ModelFilter :: min_visibility=

Minimum visibility an entity must have to be accepted

Redefined properties

redef type SELF: ModelFilter

nitc $ ModelFilter :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _accept_attribute: Bool

nitc :: ModelFilter :: _accept_attribute

Accept MAttribute and MAttributeDef instances?
private var _accept_broken: Bool

nitc :: ModelFilter :: _accept_broken

Accept broken classes and properties?
private var _accept_empty_doc: Bool

nitc :: ModelFilter :: _accept_empty_doc

Accept entities with empty documentation?
private var _accept_example: Bool

nitc :: ModelFilter :: _accept_example

Accept examples?
private var _accept_extern: Bool

nitc :: ModelFilter :: _accept_extern

Accept extern entities?
private var _accept_fictive: Bool

nitc :: ModelFilter :: _accept_fictive

Accept fictive entities?
private var _accept_full_name: nullable String

nitc :: ModelFilter :: _accept_full_name

If set, accept only entities where MEntity::full_name contains string
private var _accept_generated: Bool

nitc :: ModelFilter :: _accept_generated

Accept generated entities?
private var _accept_inherited: nullable MEntity

nitc :: ModelFilter :: _accept_inherited

If set, accept only entities local to accept_inherited
private var _accept_redef: Bool

nitc :: ModelFilter :: _accept_redef

Accept redef classdefs and propdefs?
private var _accept_test: Bool

nitc :: ModelFilter :: _accept_test

Accept nitunit test suites?
private var _min_visibility: MVisibility

nitc :: ModelFilter :: _min_visibility

Minimum visibility an entity must have to be accepted
fun accept_attribute: Bool

nitc :: ModelFilter :: accept_attribute

Accept MAttribute and MAttributeDef instances?
fun accept_attribute=(accept_attribute: nullable Bool)

nitc :: ModelFilter :: accept_attribute=

Accept MAttribute and MAttributeDef instances?
fun accept_broken: Bool

nitc :: ModelFilter :: accept_broken

Accept broken classes and properties?
fun accept_broken=(accept_broken: nullable Bool)

nitc :: ModelFilter :: accept_broken=

Accept broken classes and properties?
fun accept_empty_doc: Bool

nitc :: ModelFilter :: accept_empty_doc

Accept entities with empty documentation?
fun accept_empty_doc=(accept_empty_doc: nullable Bool)

nitc :: ModelFilter :: accept_empty_doc=

Accept entities with empty documentation?
fun accept_example: Bool

nitc :: ModelFilter :: accept_example

Accept examples?
fun accept_example=(accept_example: nullable Bool)

nitc :: ModelFilter :: accept_example=

Accept examples?
fun accept_extern: Bool

nitc :: ModelFilter :: accept_extern

Accept extern entities?
fun accept_extern=(accept_extern: nullable Bool)

nitc :: ModelFilter :: accept_extern=

Accept extern entities?
fun accept_fictive: Bool

nitc :: ModelFilter :: accept_fictive

Accept fictive entities?
fun accept_fictive=(accept_fictive: nullable Bool)

nitc :: ModelFilter :: accept_fictive=

Accept fictive entities?
fun accept_full_name: nullable String

nitc :: ModelFilter :: accept_full_name

If set, accept only entities where MEntity::full_name contains string
fun accept_full_name=(accept_full_name: nullable String)

nitc :: ModelFilter :: accept_full_name=

If set, accept only entities where MEntity::full_name contains string
fun accept_generated: Bool

nitc :: ModelFilter :: accept_generated

Accept generated entities?
fun accept_generated=(accept_generated: nullable Bool)

nitc :: ModelFilter :: accept_generated=

Accept generated entities?
fun accept_inherited: nullable MEntity

nitc :: ModelFilter :: accept_inherited

If set, accept only entities local to accept_inherited
fun accept_inherited=(accept_inherited: nullable MEntity)

nitc :: ModelFilter :: accept_inherited=

If set, accept only entities local to accept_inherited
fun accept_mentity(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity

Accept mentity based on all the options from self?
fun accept_mentity_attribute(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_attribute

Accept only entities that are not a MAttribute or MAttributeDef
fun accept_mentity_broken(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_broken

Accept only non broken entities
fun accept_mentity_empty_doc(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_empty_doc

Accept only entities with documentation
fun accept_mentity_example(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_example

Accept only entities that are not example related
fun accept_mentity_extern(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_extern

Accept only non- extern entities
fun accept_mentity_fictive(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_fictive

Accept only non-fictive entities
fun accept_mentity_full_name(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_full_name

Accept only entities where MEntity::full_name contains string
fun accept_mentity_generated(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_generated

Accept only non-generated entities
fun accept_mentity_inherited(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_inherited

Accept only entities local to accept_inherited
fun accept_mentity_redef(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_redef

Accept a MClassDefs and MPropeDefs onyl if they are an introduction
fun accept_mentity_test(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_test

Accept only entities that are not nitunit related
fun accept_mentity_visibility(mentity: MEntity): Bool

nitc :: ModelFilter :: accept_mentity_visibility

Accept mentity if its visibility is above min_visibility
fun accept_redef: Bool

nitc :: ModelFilter :: accept_redef

Accept redef classdefs and propdefs?
fun accept_redef=(accept_redef: nullable Bool)

nitc :: ModelFilter :: accept_redef=

Accept redef classdefs and propdefs?
fun accept_test: Bool

nitc :: ModelFilter :: accept_test

Accept nitunit test suites?
fun accept_test=(accept_test: nullable Bool)

nitc :: ModelFilter :: accept_test=

Accept nitunit test suites?
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(min_visibility: nullable MVisibility, accept_fictive: nullable Bool, accept_generated: nullable Bool, accept_test: nullable Bool, accept_redef: nullable Bool, accept_extern: nullable Bool, accept_attribute: nullable Bool, accept_empty_doc: nullable Bool, accept_example: nullable Bool, accept_inherited: nullable MEntity, accept_full_name: nullable String, accept_broken: nullable Bool)

nitc :: ModelFilter :: defaultinit

init from(filter: ModelFilter)

nitc :: ModelFilter :: from

Initialize self by copying the options from another filter
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun min_visibility: MVisibility

nitc :: ModelFilter :: min_visibility

Minimum visibility an entity must have to be accepted
fun min_visibility=(min_visibility: nullable MVisibility)

nitc :: ModelFilter :: min_visibility=

Minimum visibility an entity must have to be accepted
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::ModelFilter ModelFilter core::Object Object nitc::ModelFilter->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ ModelFilter
# 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