Commit 10622421 authored by Rob Pike's avatar Rob Pike

gofix: walk names in ValueSpecs

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4887048
parent 3f5edd24
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment