cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
internal/parser/utils/binary_expr.go
21lines · modecode
| 1 | package utils |
| 2 | |
| 3 | import ( |
| 4 | promParser "github.com/prometheus/prometheus/promql/parser" |
| 5 | |
| 6 | "github.com/cloudflare/pint/internal/parser" |
| 7 | ) |
| 8 | |
| 9 | func HasOuterBinaryExpr(node *parser.PromQLNode) *promParser.BinaryExpr { |
| 10 | if n, ok := node.Node.(*promParser.BinaryExpr); ok { |
| 11 | return n |
| 12 | } |
| 13 | |
| 14 | for _, child := range node.Children { |
| 15 | if be := HasOuterBinaryExpr(child); be != nil { |
| 16 | return be |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | return nil |
| 21 | } |