MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing a subset of NavigableExpr values which match.
(exprs []NavigableExpr, matcher ExprMatcher)
| 120 | // MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing a |
| 121 | // subset of NavigableExpr values which match. |
| 122 | func MatchSubset(exprs []NavigableExpr, matcher ExprMatcher) []NavigableExpr { |
| 123 | matches := []NavigableExpr{} |
| 124 | navVisitor := &baseVisitor{ |
| 125 | visitExpr: func(e Expr) { |
| 126 | nav := e.(NavigableExpr) |
| 127 | if matcher(nav) { |
| 128 | matches = append(matches, nav) |
| 129 | } |
| 130 | }, |
| 131 | } |
| 132 | for _, expr := range exprs { |
| 133 | visit(expr, navVisitor, postOrder, 0, 1) |
| 134 | } |
| 135 | return matches |
| 136 | } |
| 137 | |
| 138 | // Visitor defines an object for visiting Expr and EntryExpr nodes within an expression graph. |
| 139 | type Visitor interface { |