Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(885)

Delta Between Two Patch Sets: src/cmd/fix/netipv6zone.go

Issue 6849045: code review 6849045: net, cmd/fix: add IPv6 scoped addressing zone to INET, ... (Closed)
Left Patch Set: diff -r c4cc7dcc49cb https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r c200281fac50 https://code.google.com/p/go Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/cmd/fix/netipv6zone_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import "go/ast" 7 import "go/ast"
8 8
9 func init() { 9 func init() {
10 register(netipv6zoneFix) 10 register(netipv6zoneFix)
11 } 11 }
12 12
13 var netipv6zoneFix = fix{ 13 var netipv6zoneFix = fix{
14 "netipv6zone", 14 "netipv6zone",
15 » "2012-11-14", 15 » "2012-11-26",
16 netipv6zone, 16 netipv6zone,
17 `Adapt element key to IPNet, IPAddr, UDPAddr or TCPAddr composite litera ls. 17 `Adapt element key to IPNet, IPAddr, UDPAddr or TCPAddr composite litera ls.
18 18
19 https://codereview.appspot.com/6849045/ 19 https://codereview.appspot.com/6849045/
20 `, 20 `,
21 } 21 }
22 22
23 func netipv6zone(f *ast.File) bool { 23 func netipv6zone(f *ast.File) bool {
24 if !imports(f, "net") { 24 if !imports(f, "net") {
25 return false 25 return false
26 } 26 }
27 27
28 fixed := false 28 fixed := false
29 walk(f, func(n interface{}) { 29 walk(f, func(n interface{}) {
30 cl, ok := n.(*ast.CompositeLit) 30 cl, ok := n.(*ast.CompositeLit)
31 if !ok { 31 if !ok {
32 return 32 return
33 } 33 }
34 se, ok := cl.Type.(*ast.SelectorExpr) 34 se, ok := cl.Type.(*ast.SelectorExpr)
35 if !ok { 35 if !ok {
36 return 36 return
37 } 37 }
38 » » x, ok := se.X.(*ast.Ident) 38 » » if !isTopName(se.X, "net") || se.Sel == nil {
rsc 2012/11/26 15:23:15 Please use isTopName(se.X, "net"). That will avoid
mikio 2012/11/26 15:45:55 Done.
39 » » if !ok {
40 » » » return
41 » » }
42 » » if x.Name != "net" || se.Sel == nil {
43 return 39 return
44 } 40 }
45 switch ss := se.Sel.String(); ss { 41 switch ss := se.Sel.String(); ss {
46 case "IPNet", "IPAddr", "UDPAddr", "TCPAddr": 42 case "IPNet", "IPAddr", "UDPAddr", "TCPAddr":
47 for i, e := range cl.Elts { 43 for i, e := range cl.Elts {
48 if _, ok := e.(*ast.KeyValueExpr); ok { 44 if _, ok := e.(*ast.KeyValueExpr); ok {
49 break 45 break
50 } 46 }
51 switch i { 47 switch i {
52 case 0: 48 case 0:
(...skipping 13 matching lines...) Expand all
66 Value: e, 62 Value: e,
67 } 63 }
68 } 64 }
69 } 65 }
70 fixed = true 66 fixed = true
71 } 67 }
72 } 68 }
73 }) 69 })
74 return fixed 70 return fixed
75 } 71 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b