MCPcopy Create free account
hub / github.com/cel-expr/cel-go / MatchSubset

Function MatchSubset

common/ast/navigable.go:122–136  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

120// MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing a
121// subset of NavigableExpr values which match.
122func 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.
139type Visitor interface {

Callers 5

TestNavigateASTFunction · 0.92
TestNavigableListExprFunction · 0.92
TestNavigableMapExprFunction · 0.92
TestNavigableStructExprFunction · 0.92

Calls 1

visitFunction · 0.70

Tested by 5

TestNavigateASTFunction · 0.74
TestNavigableListExprFunction · 0.74
TestNavigableMapExprFunction · 0.74
TestNavigableStructExprFunction · 0.74