golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/rename/random.txt (about)

     1  This test ports some "random" rename tests from the old marker tests.
     2  
     3  -- flags --
     4  -ignore_extra_diags
     5  
     6  -- go.mod --
     7  module golang.org/lsptests/rename
     8  
     9  go 1.18
    10  -- a/a.go --
    11  package a
    12  
    13  import (
    14  	lg "log"
    15  	"fmt" //@rename("fmt", "fmty", fmtTofmty)
    16  	f2 "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    17  )
    18  
    19  func Random() int {
    20  	y := 6 + 7
    21  	return y
    22  }
    23  
    24  func Random2(y int) int { //@rename("y", "z", yToz)
    25  	return y
    26  }
    27  
    28  type Pos struct {
    29  	x, y int
    30  }
    31  
    32  func (p *Pos) Sum() int {
    33  	return p.x + p.y //@rename("x", "myX", xTomyX)
    34  }
    35  
    36  func _() {
    37  	var p Pos   //@rename("p", "pos", pTopos)
    38  	_ = p.Sum() //@rename("Sum", "GetSum", SumToGetSum)
    39  }
    40  
    41  func sw() {
    42  	var x interface{}
    43  
    44  	switch y := x.(type) { //@rename("y", "y0", yToy0)
    45  	case int:
    46  		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
    47  	case string:
    48  		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
    49  	default:
    50  		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    51  	}
    52  }
    53  -- @SumToGetSum/a/a.go --
    54  @@ -22 +22 @@
    55  -func (p *Pos) Sum() int {
    56  +func (p *Pos) GetSum() int {
    57  @@ -28 +28 @@
    58  -	_ = p.Sum() //@rename("Sum", "GetSum", SumToGetSum)
    59  +	_ = p.GetSum() //@rename("Sum", "GetSum", SumToGetSum)
    60  -- @f2Tof2name/a/a.go --
    61  @@ -6 +6 @@
    62  -	f2 "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    63  +	f2name "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    64  @@ -40 +40 @@
    65  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    66  +		f2name.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    67  -- @f2Tofmt2/a/a.go --
    68  @@ -6 +6 @@
    69  -	f2 "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    70  +	fmt2 "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    71  @@ -40 +40 @@
    72  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    73  +		fmt2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    74  -- @fmtTof2y/a/a.go --
    75  @@ -6 +6 @@
    76  -	f2 "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    77  +	f2y "fmt" //@rename("f2", "f2name", f2Tof2name),rename("fmt", "f2y", fmtTof2y)
    78  @@ -40 +40 @@
    79  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    80  +		f2y.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
    81  -- @fmtTofmty/a/a.go --
    82  @@ -5 +5 @@
    83  -	"fmt" //@rename("fmt", "fmty", fmtTofmty)
    84  +	fmty "fmt" //@rename("fmt", "fmty", fmtTofmty)
    85  @@ -36 +36 @@
    86  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
    87  +		fmty.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
    88  -- @fmtToformat/a/a.go --
    89  @@ -5 +5 @@
    90  -	"fmt" //@rename("fmt", "fmty", fmtTofmty)
    91  +	format "fmt" //@rename("fmt", "fmty", fmtTofmty)
    92  @@ -36 +36 @@
    93  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
    94  +		format.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
    95  -- @lgTolog/a/a.go --
    96  @@ -4 +4 @@
    97  -	lg "log"
    98  +	"log"
    99  @@ -38 +38 @@
   100  -		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   101  +		log.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   102  -- @pTopos/a/a.go --
   103  @@ -27,2 +27,2 @@
   104  -	var p Pos   //@rename("p", "pos", pTopos)
   105  -	_ = p.Sum() //@rename("Sum", "GetSum", SumToGetSum)
   106  +	var pos Pos   //@rename("p", "pos", pTopos)
   107  +	_ = pos.Sum() //@rename("Sum", "GetSum", SumToGetSum)
   108  -- @xTomyX/a/a.go --
   109  @@ -19 +19 @@
   110  -	x, y int
   111  +	myX, y int
   112  @@ -23 +23 @@
   113  -	return p.x + p.y //@rename("x", "myX", xTomyX)
   114  +	return p.myX + p.y //@rename("x", "myX", xTomyX)
   115  -- @yToy0/a/a.go --
   116  @@ -34 +34 @@
   117  -	switch y := x.(type) { //@rename("y", "y0", yToy0)
   118  +	switch y0 := x.(type) { //@rename("y", "y0", yToy0)
   119  @@ -36 +36 @@
   120  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   121  +		fmt.Printf("%d", y0) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   122  @@ -38 +38 @@
   123  -		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   124  +		lg.Printf("%s", y0) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   125  @@ -40 +40 @@
   126  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   127  +		f2.Printf("%v", y0) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   128  -- @yToy1/a/a.go --
   129  @@ -34 +34 @@
   130  -	switch y := x.(type) { //@rename("y", "y0", yToy0)
   131  +	switch y1 := x.(type) { //@rename("y", "y0", yToy0)
   132  @@ -36 +36 @@
   133  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   134  +		fmt.Printf("%d", y1) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   135  @@ -38 +38 @@
   136  -		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   137  +		lg.Printf("%s", y1) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   138  @@ -40 +40 @@
   139  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   140  +		f2.Printf("%v", y1) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   141  -- @yToy2/a/a.go --
   142  @@ -34 +34 @@
   143  -	switch y := x.(type) { //@rename("y", "y0", yToy0)
   144  +	switch y2 := x.(type) { //@rename("y", "y0", yToy0)
   145  @@ -36 +36 @@
   146  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   147  +		fmt.Printf("%d", y2) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   148  @@ -38 +38 @@
   149  -		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   150  +		lg.Printf("%s", y2) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   151  @@ -40 +40 @@
   152  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   153  +		f2.Printf("%v", y2) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   154  -- @yToy3/a/a.go --
   155  @@ -34 +34 @@
   156  -	switch y := x.(type) { //@rename("y", "y0", yToy0)
   157  +	switch y3 := x.(type) { //@rename("y", "y0", yToy0)
   158  @@ -36 +36 @@
   159  -		fmt.Printf("%d", y) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   160  +		fmt.Printf("%d", y3) //@rename("y", "y1", yToy1),rename("fmt", "format", fmtToformat)
   161  @@ -38 +38 @@
   162  -		lg.Printf("%s", y) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   163  +		lg.Printf("%s", y3) //@rename("y", "y2", yToy2),rename("lg", "log", lgTolog)
   164  @@ -40 +40 @@
   165  -		f2.Printf("%v", y) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   166  +		f2.Printf("%v", y3) //@rename("y", "y3", yToy3),rename("f2", "fmt2", f2Tofmt2)
   167  -- @yToz/a/a.go --
   168  @@ -14,2 +14,2 @@
   169  -func Random2(y int) int { //@rename("y", "z", yToz)
   170  -	return y
   171  +func Random2(z int) int { //@rename("y", "z", yToz)
   172  +	return z
   173  -- b/b.go --
   174  package b
   175  
   176  var c int //@renameerr("int", "uint", re"cannot be renamed")
   177  
   178  func _() {
   179  	a := 1 //@rename("a", "error", aToerror)
   180  	a = 2
   181  	_ = a
   182  }
   183  
   184  var (
   185  	// Hello there.
   186  	// Foo does the thing.
   187  	Foo int //@rename("Foo", "Bob", FooToBob)
   188  )
   189  
   190  /*
   191  Hello description
   192  */
   193  func Hello() {} //@rename("Hello", "Goodbye", HelloToGoodbye)
   194  
   195  -- c/c.go --
   196  package c
   197  
   198  import "golang.org/lsptests/rename/b"
   199  
   200  func _() {
   201  	b.Hello() //@rename("Hello", "Goodbye", HelloToGoodbye)
   202  }
   203  
   204  -- c/c2.go --
   205  package c
   206  
   207  //go:embed Static/*
   208  var Static embed.FS //@rename("Static", "static", StaticTostatic)
   209  
   210  -- @FooToBob/b/b.go --
   211  @@ -13,2 +13,2 @@
   212  -	// Foo does the thing.
   213  -	Foo int //@rename("Foo", "Bob", FooToBob)
   214  +	// Bob does the thing.
   215  +	Bob int //@rename("Foo", "Bob", FooToBob)
   216  -- @HelloToGoodbye/b/b.go --
   217  @@ -18 +18 @@
   218  -Hello description
   219  +Goodbye description
   220  @@ -20 +20 @@
   221  -func Hello() {} //@rename("Hello", "Goodbye", HelloToGoodbye)
   222  +func Goodbye() {} //@rename("Hello", "Goodbye", HelloToGoodbye)
   223  -- @aToerror/b/b.go --
   224  @@ -6,3 +6,3 @@
   225  -	a := 1 //@rename("a", "error", aToerror)
   226  -	a = 2
   227  -	_ = a
   228  +	error := 1 //@rename("a", "error", aToerror)
   229  +	error = 2
   230  +	_ = error
   231  -- @HelloToGoodbye/c/c.go --
   232  @@ -6 +6 @@
   233  -	b.Hello() //@rename("Hello", "Goodbye", HelloToGoodbye)
   234  +	b.Goodbye() //@rename("Hello", "Goodbye", HelloToGoodbye)
   235  -- @StaticTostatic/c/c2.go --
   236  @@ -4 +4 @@
   237  -var Static embed.FS //@rename("Static", "static", StaticTostatic)
   238  +var static embed.FS //@rename("Static", "static", StaticTostatic)