ApplyASTRewrites applies all registered transformations except those whose names appear in skip. Passing [TransformationAll] in skip disables every transformation.
(r *RootExpr, skip []string)
| 44 | // ApplyASTRewrites applies all registered transformations except those whose names appear in skip. |
| 45 | // Passing [TransformationAll] in skip disables every transformation. |
| 46 | func ApplyASTRewrites(r *RootExpr, skip []string) *RootExpr { |
| 47 | if slices.Contains(skip, TransformationAll) { |
| 48 | return r |
| 49 | } |
| 50 | |
| 51 | var chain rewriteChain |
| 52 | for _, nr := range defaultTransformations { |
| 53 | if !slices.Contains(skip, nr.name) { |
| 54 | chain = append(chain, nr.rewrite) |
| 55 | } |
| 56 | } |
| 57 | if len(chain) == 0 { |
| 58 | return r |
| 59 | } |
| 60 | |
| 61 | return chain.RewriteRoot(r) |
| 62 | } |
| 63 | |
| 64 | // ASTRewriter modifies a TraceQL AST without changing its meaning. |
| 65 | type ASTRewriter interface { |
no test coverage detected