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

Side by Side Diff: src/cmd/gofix/math.go

Issue 5158043: code review 5158043: math: remove the leading F from Fabs etc. (Closed)
Patch Set: diff -r bc60e3827d04 https://go.googlecode.com/hg/ Created 13 years, 5 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:
View unified diff | Download patch
« no previous file with comments | « src/cmd/gofix/Makefile ('k') | src/cmd/gofix/math_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 import (
8 "fmt"
9 "os"
10 "go/ast"
11 )
12
13 var _ fmt.Stringer
14 var _ os.Error
15
16 var mathFix = fix{
17 "math",
18 math,
19 `Remove the leading F from math functions such as Fabs.
20
21 http://codereview.appspot.com/5158043
22 `,
23 }
24
25 func init() {
26 register(mathFix)
27 }
28
29 var mathRenames = []struct{ in, out string }{
30 {"Fabs", "Abs"},
31 {"Fdim", "Dim"},
32 {"Fmax", "Max"},
33 {"Fmin", "Min"},
34 {"Fmod", "Mod"},
35 }
36
37 func math(f *ast.File) bool {
38 if !imports(f, "math") {
39 return false
40 }
41
42 fixed := false
43
44 walk(f, func(n interface{}) {
45 // Rename functions.
46 if expr, ok := n.(ast.Expr); ok {
47 for _, s := range mathRenames {
48 if isPkgDot(expr, "math", s.in) {
49 expr.(*ast.SelectorExpr).Sel.Name = s.ou t
50 fixed = true
51 return
52 }
53 }
54 }
55 })
56 return fixed
57 }
OLDNEW
« no previous file with comments | « src/cmd/gofix/Makefile ('k') | src/cmd/gofix/math_test.go » ('j') | no next file with comments »

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