src/model: add `is_broken` filter
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 1 Jun 2018 15:05:20 +0000 (11:05 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Sat, 2 Jun 2018 15:59:30 +0000 (11:59 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/model/model_filters.nit

index 740a17a..572ccbd 100644 (file)
@@ -44,6 +44,7 @@ class ModelFilter
        #
        # 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_test(mentity) then return false
@@ -207,4 +208,15 @@ class ModelFilter
                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