Introduced classes

class ModelFilter

nitc :: ModelFilter

A list of filters that can be applied on a MEntity

All class definitions

class ModelFilter

nitc $ ModelFilter

A list of filters that can be applied on a MEntity
package_diagram nitc::model_filters model_filters nitc::model_examples model_examples nitc::model_filters->nitc::model_examples nitc::parse_annotations parse_annotations nitc::model_filters->nitc::parse_annotations nitc\>model\> model nitc::model_examples->nitc\>model\> nitc::modelize_property modelize_property nitc::parse_annotations->nitc::modelize_property ...nitc\>model\> ... ...nitc\>model\>->nitc\>model\> ...nitc::modelize_property ... ...nitc::modelize_property->nitc::modelize_property nitc::model_collect model_collect nitc::model_collect->nitc::model_filters nitc::model_visitor model_visitor nitc::model_visitor->nitc::model_filters nitc::html_model html_model nitc::html_model->nitc::model_collect nitc::model_index model_index nitc::model_index->nitc::model_collect nitc::uml_base uml_base nitc::uml_base->nitc::model_collect nitc::mmodules_metrics mmodules_metrics nitc::mmodules_metrics->nitc::model_collect nitc::mclasses_metrics mclasses_metrics nitc::mclasses_metrics->nitc::model_collect nitc::readme_metrics readme_metrics nitc::readme_metrics->nitc::model_collect nitc::vim_autocomplete vim_autocomplete nitc::vim_autocomplete->nitc::model_collect nitc::mclassdef_collect mclassdef_collect nitc::mclassdef_collect->nitc::model_collect nitc::term_model term_model nitc::term_model->nitc::model_collect nitc::html_model... ... nitc::html_model...->nitc::html_model nitc::model_index... ... nitc::model_index...->nitc::model_index nitc::uml_base... ... nitc::uml_base...->nitc::uml_base nitc::mmodules_metrics... ... nitc::mmodules_metrics...->nitc::mmodules_metrics nitc::mclasses_metrics... ... nitc::mclasses_metrics...->nitc::mclasses_metrics nitc::readme_metrics... ... nitc::readme_metrics...->nitc::readme_metrics nitc::vim_autocomplete... ... nitc::vim_autocomplete...->nitc::vim_autocomplete nitc::mclassdef_collect... ... nitc::mclassdef_collect...->nitc::mclassdef_collect nitc::term_model... ... nitc::term_model...->nitc::term_model nitc::test_model_visitor test_model_visitor nitc::test_model_visitor->nitc::model_visitor nitc::test_model_visitor... ... nitc::test_model_visitor...->nitc::test_model_visitor

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module location

nitc :: location

Nit source-file and locations in source-file
module math

core :: math

Mathematical operations
module mdoc

nitc :: mdoc

Documentation of model entities
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module model_examples

nitc :: model_examples

Examples for Model entities
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing

Children

module model_collect

nitc :: model_collect

Collect things from the model.
module model_visitor

nitc :: model_visitor

Simple visitor framework for Nit models.

Descendants

module a_star-m

a_star-m

module api

nitc :: api

Components required to build a web server about the nit model.
module api_auth

nitc :: api_auth

module api_base

nitc :: api_base

Base classes used by nitweb.
module api_docdown

nitc :: api_docdown

Nitdoc specific Markdown format handling for Nitweb
module api_feedback

nitc :: api_feedback

Feedback related features
module api_light

nitc :: api_light

Highlight and collect messages from a piece of code
module api_model

nitc :: api_model

module commands_base

nitc :: commands_base

Documentation commands
module commands_catalog

nitc :: commands_catalog

Commands to retrieve Catalog related data
module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_model

nitc :: commands_model

Doc commands about a Model or a MEntity
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module commands_usage

nitc :: commands_usage

Commands about how mentities are used
module html_commands

nitc :: html_commands

Render commands results as HTML
module html_model

nitc :: html_model

Translate mentities to html blocks.
module inheritance_metrics

nitc :: inheritance_metrics

Collect metrics about inheritance usage
module json_commands

nitc :: json_commands

Translate command results to json
module json_model

nitc :: json_model

Make model entities Serializable.
module mclasses_metrics

nitc :: mclasses_metrics

Collect common metrics about mclasses
module md_commands

nitc :: md_commands

Render commands results as Markdown
module mendel_metrics

nitc :: mendel_metrics

The Mendel model helps to understand class hierarchies.
module metrics

nitc :: metrics

Various statistics about Nit models and programs
module mmodules_metrics

nitc :: mmodules_metrics

Collect common metrics about modules
module model_index

nitc :: model_index

Search things from the Model
module nitcatalog

nitc :: nitcatalog

Basic catalog generator for Nit packages
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nitmetrics

nitc :: nitmetrics

A program that collects various metrics on nit programs and libraries
module nitpackage

nitc :: nitpackage

Helpful features about packages
module nitpick

nitc :: nitpick

A program that collect potential style and code issues
module nitsmells

nitc :: nitsmells

module nituml

nitc :: nituml

UML generator in dot format.
module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module nitx

nitc :: nitx

nitx, a command tool that displays useful data about Nit code
module nullables_metrics

nitc :: nullables_metrics

Statistics about the usage of nullables
module readme_metrics

nitc :: readme_metrics

Collect common metrics about README files
module rta_metrics

nitc :: rta_metrics

Metrics from RTA
module static

nitc :: static

Nitdoc generation framework
module static_base

nitc :: static_base

Base entities shared by all the nitdoc code
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module static_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
module term

nitc :: term

module term_model

nitc :: term_model

Markdown templates for Nit model MEntities.
module test_model_visitor

nitc :: test_model_visitor

Example of model_visitor
module uml

nitc :: uml

Group head module for UML generation services
module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model
module uml_class

nitc :: uml_class

Provides facilities of exporting a Model to a UML class diagram
module uml_module

nitc :: uml_module

Services for generation of a UML package diagram based on a Model
module vim_autocomplete

nitc :: vim_autocomplete

Generate files used by the Vim plugin to autocomplete with doc
module model_filters

import model_examples
import parse_annotations

# 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:15,1--262,3