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

Function MatchDescendants

common/ast/navigable.go:106–118  ·  view source on GitHub ↗

MatchDescendants takes a NavigableExpr and ExprMatcher and produces a list of NavigableExpr values matching the input criteria in post-order (bottom up).

(expr NavigableExpr, matcher ExprMatcher)

Source from the content-addressed store, hash-verified

104// MatchDescendants takes a NavigableExpr and ExprMatcher and produces a list of NavigableExpr values
105// matching the input criteria in post-order (bottom up).
106func MatchDescendants(expr NavigableExpr, matcher ExprMatcher) []NavigableExpr {
107 matches := []NavigableExpr{}
108 navVisitor := &baseVisitor{
109 visitExpr: func(e Expr) {
110 nav := e.(NavigableExpr)
111 if matcher(nav) {
112 matches = append(matches, nav)
113 }
114 },
115 }
116 visit(expr, navVisitor, postOrder, 0, 0)
117 return matches
118}
119
120// MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing a
121// subset of NavigableExpr values which match.

Callers 15

maybeUnnestRuleMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
OptimizeMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
ValidateMethod · 0.92
OptimizeMethod · 0.92
pruneOptionalElementsFunction · 0.92
OptimizeMethod · 0.92
TestNavigateASTFunction · 0.92

Calls 1

visitFunction · 0.70

Tested by 7

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