cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
internal/parser/utils/binary_expr.go
21lines · modeblame
d292a71cLukasz Mierzwa4 years ago | 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 | } |