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

Function pruneOptionalElements

cel/folding.go:325–337  ·  view source on GitHub ↗

pruneOptionalElements works from the bottom up to resolve optional elements within aggregate literals. Note, many aggregate literals will be resolved as arguments to functions or select statements, so this method exists to handle the case where the literal could not be fully resolved or exists outs

(ctx *OptimizerContext, root ast.NavigableExpr)

Source from the content-addressed store, hash-verified

323// statements, so this method exists to handle the case where the literal could not be
324// fully resolved or exists outside of a call, select, or comprehension context.
325func pruneOptionalElements(ctx *OptimizerContext, root ast.NavigableExpr) {
326 aggregateLiterals := ast.MatchDescendants(root, aggregateLiteralMatcher)
327 for _, lit := range aggregateLiterals {
328 switch lit.Kind() {
329 case ast.ListKind:
330 pruneOptionalListElements(ctx, lit)
331 case ast.MapKind:
332 pruneOptionalMapEntries(ctx, lit)
333 case ast.StructKind:
334 pruneOptionalStructFields(ctx, lit)
335 }
336 }
337}
338
339func pruneOptionalListElements(ctx *OptimizerContext, e ast.Expr) {
340 l := e.AsList()

Callers 1

OptimizeMethod · 0.85

Calls 5

MatchDescendantsFunction · 0.92
pruneOptionalMapEntriesFunction · 0.85
KindMethod · 0.65

Tested by

no test coverage detected