From a9ad2b2d64ac9e8acb096e70ab6c034964a2b6f0 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 26 Sep 2017 20:02:07 -0400 Subject: [PATCH] model: filter examples from views Signed-off-by: Alexandre Terrasa --- src/model/model_filters.nit | 14 +++++++++++++- src/model/model_visitor.nit | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/model/model_filters.nit b/src/model/model_filters.nit index 4cceddd..740a17a 100644 --- a/src/model/model_filters.nit +++ b/src/model/model_filters.nit @@ -14,7 +14,7 @@ module model_filters -import model +import model_examples # A list of filters that can be applied on a MEntity # @@ -49,6 +49,7 @@ class ModelFilter 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 @@ -155,6 +156,17 @@ class ModelFilter return mentity.mdoc_or_fallback != null end + # Accept examples? + # + # Default is `true`. + var accept_example = true is optional + + # 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 diff --git a/src/model/model_visitor.nit b/src/model/model_visitor.nit index e5a7409..d733912 100644 --- a/src/model/model_visitor.nit +++ b/src/model/model_visitor.nit @@ -77,6 +77,7 @@ abstract class ModelVisitor min_visibility = protected_visibility, accept_fictive = false, accept_test = false, + accept_example = false, accept_redef = true, accept_extern = true, accept_attribute = true, -- 1.7.9.5