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

Function NavigateExpr

common/ast/navigable.go:55–63  ·  view source on GitHub ↗

NavigateExpr creates a NavigableExpr whose type information is backed by the input AST. If the expression is already a NavigableExpr, the parent and depth information will be propagated on the new NavigableExpr value; otherwise, the expr value will be treated as though it is the root of the express

(ast *AST, expr Expr)

Source from the content-addressed store, hash-verified

53// propagated on the new NavigableExpr value; otherwise, the expr value will be treated
54// as though it is the root of the expression graph with a depth of 0.
55func NavigateExpr(ast *AST, expr Expr) NavigableExpr {
56 depth := 0
57 var parent NavigableExpr = nil
58 if nav, ok := expr.(NavigableExpr); ok {
59 depth = nav.Depth()
60 parent, _ = nav.Parent()
61 }
62 return newNavigableExpr(ast, parent, expr, depth)
63}
64
65// ExprMatcher takes a NavigableExpr in and indicates whether the value is a match.
66//

Callers 2

TestNavigableExprFunction · 0.92
NavigateASTFunction · 0.85

Calls 3

newNavigableExprFunction · 0.85
DepthMethod · 0.65
ParentMethod · 0.65

Tested by 1

TestNavigableExprFunction · 0.74