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)
| 78 | // |
| 79 | // Prefer ParsedExprToAst if loading expressions from storage. |
| 80 | func ParsedExprToAstWithSource(parsedExpr *exprpb.ParsedExpr, src Source) *Ast { |
| 81 | info, _ := ast.ProtoToSourceInfo(parsedExpr.GetSourceInfo()) |
| 82 | if src == nil { |
| 83 | src = common.NewInfoSource(parsedExpr.GetSourceInfo()) |
| 84 | } |
| 85 | e, _ := ast.ProtoToExpr(parsedExpr.GetExpr()) |
| 86 | return &Ast{source: src, impl: ast.NewAST(e, info)} |
| 87 | } |
| 88 | |
| 89 | // AstToParsedExpr converts an Ast to an protobuf ParsedExpr value. |
| 90 | func AstToParsedExpr(a *Ast) (*exprpb.ParsedExpr, error) { |