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

Function ParsedExprToAstWithSource

cel/io.go:85–96  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

83//
84// Prefer ParsedExprToAst if loading expressions from storage.
85func 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.

Callers 2

ParsedExprToAstFunction · 0.85
TestAstToProtoFunction · 0.85

Calls 5

ProtoToSourceInfoFunction · 0.92
NewInfoSourceFunction · 0.92
ProtoToExprFunction · 0.92
NewASTFunction · 0.92
checkLoadedASTDepthFunction · 0.85

Tested by 1

TestAstToProtoFunction · 0.68