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

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

Issue 4631098: code review 4631098: sort: rename helpers: s/Sort// in sort.Sort[Float64s|In... (Closed)
Left Patch Set: diff -r 6998f26de587 https://go.googlecode.com/hg/ Created 12 years, 8 months ago
Right Patch Set: diff -r e276ba524959 https://go.googlecode.com/hg/ Created 12 years, 8 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
« no previous file with change/comment | « src/cmd/gofix/Makefile ('k') | src/cmd/gofix/sorthelpers_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
(no file at all)
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 "go/ast"
9 )
10
11 func init() {
12 register(fix{
13 "sorthelpers",
14 sorthelpers,
15 `Adapt code from sort.Sort[Ints|Float64s|Strings] to sort.[Ints| Float64s|Strings].
16 `,
17 })
18 }
19
20
21 func sorthelpers(f *ast.File) (fixed bool) {
22 if !imports(f, "sort") {
23 return
24 }
25
26 walk(f, func(n interface{}) {
27 s, ok := n.(*ast.SelectorExpr)
28 if !ok || !isTopName(s.X, "sort") {
29 return
30 }
31
32 switch s.Sel.String() {
33 case "SortFloat64s":
34 s.Sel.Name = "Float64s"
35 case "SortInts":
36 s.Sel.Name = "Ints"
37 case "SortStrings":
38 s.Sel.Name = "Strings"
39 default:
40 return
41 }
42
43 fixed = true
44 })
45
46 return
47 }
LEFTRIGHT

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