summaryrefslogtreecommitdiff
path: root/src/cmd/fix/url2.go
blob: 5fd05ad2a7397f7708a3979a98d0a32ec80e9a9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2011 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "go/ast"

func init() {
	register(url2Fix)
}

var url2Fix = fix{
	"url2",
	"2012-02-16",
	url2,
	`Rename some functions in net/url.

http://codereview.appspot.com/5671061
`,
}

func url2(f *ast.File) bool {
	if !imports(f, "net/url") {
		return false
	}

	fixed := false

	walk(f, func(n interface{}) {
		// Rename functions and methods.
		sel, ok := n.(*ast.SelectorExpr)
		if !ok {
			return
		}
		if !isTopName(sel.X, "url") {
			return
		}
		if sel.Sel.Name == "ParseWithReference" {
			sel.Sel.Name = "ParseWithFragment"
			fixed = true
		}
	})

	return fixed
}