| 1 | // Copyright 2015 The Go Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package astutil |
| 6 | |
| 7 | import "go/ast" |
| 8 | |
| 9 | // Unparen returns e with any enclosing parentheses stripped. |
| 10 | func Unparen(e ast.Expr) ast.Expr { |
| 11 | for { |
| 12 | p, ok := e.(*ast.ParenExpr) |
| 13 | if !ok { |
| 14 | return e |
| 15 | } |
| 16 | e = p.X |
| 17 | } |
| 18 | } |
| 19 |