ParsedExprToAstWithSource converts a parsed expression proto message to an Ast, using the provided Source as the textual contents. In general you only need this if you need to recheck a previously checked expression, or if you need to separately check a subset of an expression. Prefer ParsedExprTo
(parsedExpr *exprpb.ParsedExpr, src Source)
| 83 | // |
| 84 | // Prefer ParsedExprToAst if loading expressions from storage. |
| 85 | func ParsedExprToAstWithSource(parsedExpr *exprpb.ParsedExpr, src Source) *Ast { |
| 86 | info, _ := ast.ProtoToSourceInfo(parsedExpr.GetSourceInfo()) |
| 87 | if src == nil { |
| 88 | src = common.NewInfoSource(parsedExpr.GetSourceInfo()) |
| 89 | } |
| 90 | e, _ := ast.ProtoToExpr(parsedExpr.GetExpr()) |
| 91 | out := &Ast{source: src, impl: ast.NewAST(e, info)} |
| 92 | // ParsedExprToAstWithSource has no error return, so record an over-depth violation on the Ast |
| 93 | // to be surfaced when it is later checked or planned. |
| 94 | out.loadErr = checkLoadedASTDepth(out.impl) |
| 95 | return out |
| 96 | } |
| 97 | |
| 98 | // checkLoadedASTDepth guards ASTs that enter through the proto conversion helpers |
| 99 | // (ParsedExprToAst / CheckedExprToAst) against nesting deeper than the parser's recursion limit. |