model: filter examples from views
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 27 Sep 2017 00:02:07 +0000 (20:02 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 28 Nov 2017 20:03:28 +0000 (15:03 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/model/model_filters.nit
src/model/model_visitor.nit

index 4cceddd..740a17a 100644 (file)
@@ -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
 
index e5a7409..d733912 100644 (file)
@@ -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,