Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
10622421
Commit
10622421
authored
Aug 18, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofix: walk names in ValueSpecs
R=golang-dev, dsymonds CC=golang-dev
https://golang.org/cl/4887048
parent
3f5edd24
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
fix.go
src/cmd/gofix/fix.go
+12
-3
url.go
src/cmd/gofix/url.go
+0
-10
No files found.
src/cmd/gofix/fix.go
View file @
10622421
...
...
@@ -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
)
...
...
src/cmd/gofix/url.go
View file @
10622421
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment