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

     1  This test verifies the behavior of textDocument/prepareRename.
     2  
     3  -- settings.json --
     4  {
     5  	"deepCompletion": false
     6  }
     7  
     8  -- go.mod --
     9  module golang.org/lsptests
    10  
    11  go 1.18
    12  -- types/types.go --
    13  package types
    14  
    15  type CoolAlias = int //@item(CoolAlias, "CoolAlias", "int", "type")
    16  
    17  type X struct { //@item(X_struct, "X", "struct{...}", "struct")
    18  	x int
    19  }
    20  
    21  type Y struct { //@item(Y_struct, "Y", "struct{...}", "struct")
    22  	y int
    23  }
    24  
    25  
    26  type Bob interface { //@item(Bob_interface, "Bob", "interface{...}", "interface")
    27  	Bobby()
    28  }
    29  
    30  func (*X) Bobby() {}
    31  func (*Y) Bobby() {}
    32  
    33  -- good/good0.go --
    34  package good
    35  
    36  func stuff() { //@item(good_stuff, "stuff", "func()", "func"),preparerename("stu", "stuff", "stuff")
    37  	x := 5
    38  	random2(x) //@preparerename("dom", "random2", "random2")
    39  }
    40  
    41  -- good/good1.go --
    42  package good
    43  
    44  import (
    45  	"golang.org/lsptests/types" //@item(types_import, "types", "\"golang.org/lsptests/types\"", "package")
    46  )
    47  
    48  func random() int { //@item(good_random, "random", "func() int", "func")
    49  	_ = "random() int" //@preparerename("random", "", "")
    50  	y := 6 + 7         //@preparerename("7", "", "")
    51  	return y           //@preparerename("return", "","")
    52  }
    53  
    54  func random2(y int) int { //@item(good_random2, "random2", "func(y int) int", "func"),item(good_y_param, "y", "int", "var")
    55  	//@complete("", good_y_param, types_import, good_random, good_random2, good_stuff)
    56  	var b types.Bob = &types.X{}   //@preparerename("ypes","types", "types")
    57  	if _, ok := b.(*types.X); ok { //@complete("X", X_struct, Y_struct, Bob_interface, CoolAlias)
    58  		_ = 0 // suppress "empty branch" diagnostic
    59  	}
    60  
    61  	return y
    62  }