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

Delta Between Two Patch Sets: src/cmd/gofix/htmlerr.go

Issue 5448088: code review 5448088: cmd: shorten composite literal field values (Closed)
Left Patch Set: Created 12 years, 4 months ago
Right Patch Set: diff -r f91f50b96e10 https://go.googlecode.com/hg/ Created 12 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 ( 7 import (
8 "go/ast" 8 "go/ast"
9 ) 9 )
10 10
11 func init() { 11 func init() {
12 register(htmlerrFix) 12 register(htmlerrFix)
13 } 13 }
14 14
15 var htmlerrFix = fix{ 15 var htmlerrFix = fix{
16 "htmlerr", 16 "htmlerr",
17 "2011-11-04", 17 "2011-11-04",
18 htmlerr, 18 htmlerr,
19 `Rename html's Tokenizer.Error method to Err. 19 `Rename html's Tokenizer.Error method to Err.
20 20
21 http://codereview.appspot.com/5327064/ 21 http://codereview.appspot.com/5327064/
22 `, 22 `,
23 } 23 }
24 24
25 var htmlerrTypeConfig = &TypeConfig{ 25 var htmlerrTypeConfig = &TypeConfig{
26 » Func: map[string]string{ 26 » Func: {
gri 2011/12/02 23:11:05 I'd leave this file alone - no real win
27 "html.NewTokenizer": "html.Tokenizer", 27 "html.NewTokenizer": "html.Tokenizer",
28 }, 28 },
29 } 29 }
30 30
31 func htmlerr(f *ast.File) bool { 31 func htmlerr(f *ast.File) bool {
32 if !imports(f, "html") { 32 if !imports(f, "html") {
33 return false 33 return false
34 } 34 }
35 35
36 typeof, _ := typecheck(htmlerrTypeConfig, f) 36 typeof, _ := typecheck(htmlerrTypeConfig, f)
37 37
38 fixed := false 38 fixed := false
39 walk(f, func(n interface{}) { 39 walk(f, func(n interface{}) {
40 s, ok := n.(*ast.SelectorExpr) 40 s, ok := n.(*ast.SelectorExpr)
41 if ok && typeof[s.X] == "html.Tokenizer" && s.Sel.Name == "Error " { 41 if ok && typeof[s.X] == "html.Tokenizer" && s.Sel.Name == "Error " {
42 s.Sel.Name = "Err" 42 s.Sel.Name = "Err"
43 fixed = true 43 fixed = true
44 } 44 }
45 }) 45 })
46 return fixed 46 return fixed
47 } 47 }
LEFTRIGHT

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