1
0
mirror of https://github.com/golang/go synced 2024-11-19 05:44:40 -07:00
go/internal/lsp/testdata/rename/a/random.go.golden
Suzy Mueller 6cfa55603c internal/lsp: check ident exists for comment rename
The identifier in a reference is used to check for a doc comment.
Implicits do not have an ident, so do not use that to look for a doc
comment.

Also set the context.Context for the renamer.

Change-Id: I085d9e6c11d919222592dcb6fb30982eeb0fc7cd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184042
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-28 17:52:03 +00:00

361 lines
5.2 KiB
Plaintext

-- GetSum-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) GetSum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.GetSum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y) //@rename("y", "y1")
case string:
fmt.Printf("%s", y) //@rename("y", "y2")
default:
fmt.Printf("%v", y) //@rename("y", "y3")
}
}
-- myX-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
myX, y int
}
func (p *Pos) Sum() int {
return p.myX + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y) //@rename("y", "y1")
case string:
fmt.Printf("%s", y) //@rename("y", "y2")
default:
fmt.Printf("%v", y) //@rename("y", "y3")
}
}
-- pos-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var pos Pos //@rename("p", "pos")
_ = pos.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y) //@rename("y", "y1")
case string:
fmt.Printf("%s", y) //@rename("y", "y2")
default:
fmt.Printf("%v", y) //@rename("y", "y3")
}
}
-- z-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(z int) int { //@rename("y", "z")
return z
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y) //@rename("y", "y1")
case string:
fmt.Printf("%s", y) //@rename("y", "y2")
default:
fmt.Printf("%v", y) //@rename("y", "y3")
}
}
-- y0-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y0 := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y0) //@rename("y", "y1")
case string:
fmt.Printf("%s", y0) //@rename("y", "y2")
default:
fmt.Printf("%v", y0) //@rename("y", "y3")
}
}
-- y1-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y1 := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y1) //@rename("y", "y1")
case string:
fmt.Printf("%s", y1) //@rename("y", "y2")
default:
fmt.Printf("%v", y1) //@rename("y", "y3")
}
}
-- y2-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y2 := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y2) //@rename("y", "y1")
case string:
fmt.Printf("%s", y2) //@rename("y", "y2")
default:
fmt.Printf("%v", y2) //@rename("y", "y3")
}
}
-- y3-rename --
package a
import "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y3 := x.(type) { //@rename("y", "y0")
case int:
fmt.Printf("%d", y3) //@rename("y", "y1")
case string:
fmt.Printf("%s", y3) //@rename("y", "y2")
default:
fmt.Printf("%v", y3) //@rename("y", "y3")
}
}
-- format-rename --
package a
import format "fmt"
func Random() int {
y := 6 + 7
return y
}
func Random2(y int) int { //@rename("y", "z")
return y
}
type Pos struct {
x, y int
}
func (p *Pos) Sum() int {
return p.x + p.y //@rename("x", "myX")
}
func _() {
var p Pos //@rename("p", "pos")
_ = p.Sum() //@rename("Sum", "GetSum")
}
func sw() {
var x interface{}
switch y := x.(type) { //@rename("y", "y0")
case int:
format.Printf("%d", y) //@rename("y", "y1")
case string:
format.Printf("%s", y) //@rename("y", "y2")
default:
format.Printf("%v", y) //@rename("y", "y3")
}
}