mirror of
https://github.com/golang/go
synced 2024-11-24 22:57:57 -07:00
gofix: walk names in ValueSpecs
R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/4887048
This commit is contained in:
parent
3f5edd2461
commit
10622421b5
@ -71,17 +71,21 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) {
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case **ast.FuncType:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case **ast.Ident:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
|
||||
// pointers to slices
|
||||
case *[]ast.Stmt:
|
||||
case *[]ast.Decl:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case *[]ast.Expr:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case *[]ast.Decl:
|
||||
case *[]*ast.File:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case *[]*ast.Ident:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case *[]ast.Spec:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
case *[]*ast.File:
|
||||
case *[]ast.Stmt:
|
||||
walkBeforeAfter(*n, before, after)
|
||||
|
||||
// These are ordered and grouped to match ../../pkg/go/ast/ast.go
|
||||
@ -212,6 +216,7 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) {
|
||||
case *ast.ValueSpec:
|
||||
walkBeforeAfter(&n.Type, before, after)
|
||||
walkBeforeAfter(&n.Values, before, after)
|
||||
walkBeforeAfter(&n.Names, before, after)
|
||||
case *ast.TypeSpec:
|
||||
walkBeforeAfter(&n.Type, before, after)
|
||||
|
||||
@ -245,6 +250,10 @@ func walkBeforeAfter(x interface{}, before, after func(interface{})) {
|
||||
for i := range n {
|
||||
walkBeforeAfter(&n[i], before, after)
|
||||
}
|
||||
case []*ast.Ident:
|
||||
for i := range n {
|
||||
walkBeforeAfter(&n[i], before, after)
|
||||
}
|
||||
case []ast.Stmt:
|
||||
for i := range n {
|
||||
walkBeforeAfter(&n[i], before, after)
|
||||
|
@ -51,16 +51,6 @@ func url(f *ast.File) bool {
|
||||
ident.Name = "url_"
|
||||
return
|
||||
}
|
||||
// Find declared identifiers called url that might be confused.
|
||||
// TODO: Why does gofix not walk the Names in a ValueSpec?
|
||||
// TODO: Just a bug; fix later as it will have consequences.
|
||||
if valSpec, ok := n.(*ast.ValueSpec); ok {
|
||||
for _, ident := range valSpec.Names {
|
||||
if ident.Name == "url" {
|
||||
ident.Name = "url_"
|
||||
}
|
||||
}
|
||||
}
|
||||
// Parameter and result names.
|
||||
if fn, ok := n.(*ast.FuncType); ok {
|
||||
fixed = urlDoFields(fn.Params) || fixed
|
||||
|
Loading…
Reference in New Issue
Block a user