containsStatusFunc returns true when any node in the tree is a status function. Used to gate complement / idempotent rules that must not fire on expressions containing status functions.
(node ConditionNode)
| 126 | // Used to gate complement / idempotent rules that must not fire on expressions |
| 127 | // containing status functions. |
| 128 | func containsStatusFunc(node ConditionNode) bool { |
| 129 | if isStatusFunc(node) { |
| 130 | return true |
| 131 | } |
| 132 | switch n := node.(type) { |
| 133 | case *AndNode: |
| 134 | return containsStatusFunc(n.Left) || containsStatusFunc(n.Right) |
| 135 | case *OrNode: |
| 136 | return containsStatusFunc(n.Left) || containsStatusFunc(n.Right) |
| 137 | case *NotNode: |
| 138 | return containsStatusFunc(n.Child) |
| 139 | case *DisjunctionNode: |
| 140 | return slices.ContainsFunc(n.Terms, containsStatusFunc) |
| 141 | case *FunctionCallNode: |
| 142 | return slices.ContainsFunc(n.Arguments, containsStatusFunc) |
| 143 | } |
| 144 | return false |
| 145 | } |
| 146 | |
| 147 | // collectOrTerms recursively flattens a chain of OrNode / DisjunctionNode into |
| 148 | // a flat slice of leaf terms. This allows the DisjunctionNode optimiser (which |