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

Function ParsedExprToAstWithSource

cel/io.go:80–87  ·  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

78//
79// Prefer ParsedExprToAst if loading expressions from storage.
80func 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.
90func AstToParsedExpr(a *Ast) (*exprpb.ParsedExpr, error) {

Callers 2

ParsedExprToAstFunction · 0.85
TestAstToProtoFunction · 0.85

Calls 4

ProtoToSourceInfoFunction · 0.92
NewInfoSourceFunction · 0.92
ProtoToExprFunction · 0.92
NewASTFunction · 0.92

Tested by 1

TestAstToProtoFunction · 0.68