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)
| 262 | // statements, so this method exists to handle the case where the literal could not be |
| 263 | // fully resolved or exists outside of a call, select, or comprehension context. |
| 264 | func pruneOptionalElements(ctx *OptimizerContext, root ast.NavigableExpr) { |
| 265 | aggregateLiterals := ast.MatchDescendants(root, aggregateLiteralMatcher) |
| 266 | for _, lit := range aggregateLiterals { |
| 267 | switch lit.Kind() { |
| 268 | case ast.ListKind: |
| 269 | pruneOptionalListElements(ctx, lit) |
| 270 | case ast.MapKind: |
| 271 | pruneOptionalMapEntries(ctx, lit) |
| 272 | case ast.StructKind: |
| 273 | pruneOptionalStructFields(ctx, lit) |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | func pruneOptionalListElements(ctx *OptimizerContext, e ast.Expr) { |
| 279 | l := e.AsList() |
no test coverage detected