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)
| 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. |
| 55 | func 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 | // |