mirror of
https://github.com/golang/go
synced 2024-11-18 10:54:40 -07:00
cmd/vet: remove dependency on go/ast/astutil
This package was only imported for the trivial Unparen function. Change-Id: I0ead916a7fdb469a26b4fe99c6964a8ed1438c49 Reviewed-on: https://go-review.googlesource.com/8566 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
0770aced4f
commit
48e2a5be44
@ -9,8 +9,6 @@ package main
|
||||
import (
|
||||
"go/ast"
|
||||
"go/token"
|
||||
|
||||
"golang.org/x/tools/go/ast/astutil"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -164,7 +162,7 @@ func hasSideEffects(e ast.Expr) bool {
|
||||
// split returns []{d, c, b, a}.
|
||||
func (op boolOp) split(e ast.Expr) (exprs []ast.Expr) {
|
||||
for {
|
||||
e = astutil.Unparen(e)
|
||||
e = unparen(e)
|
||||
if b, ok := e.(*ast.BinaryExpr); ok && b.Op == op.tok {
|
||||
exprs = append(exprs, op.split(b.Y)...)
|
||||
e = b.X
|
||||
@ -175,3 +173,14 @@ func (op boolOp) split(e ast.Expr) (exprs []ast.Expr) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// unparen returns e with any enclosing parentheses stripped.
|
||||
func unparen(e ast.Expr) ast.Expr {
|
||||
for {
|
||||
p, ok := e.(*ast.ParenExpr)
|
||||
if !ok {
|
||||
return e
|
||||
}
|
||||
e = p.X
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user