Debian Codegraph @

gopls/internal/test/marker/testdata/rename/prepare.txt

raw
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 var _ = stuff
37
38 func stuff() { //@item(good_stuff, "stuff", "func()", "func"),preparerename("stu", "stuff", span="stuff")
39 x := 5
40 random2(x) //@preparerename("dom", "random2", span="random2")
41 }
42
43 -- good/good1.go --
44 package good
45
46 import (
47 "golang.org/lsptests/types" //@item(types_import, "types", "\"golang.org/lsptests/types\"", "package")
48 )
49
50 var _ = random
51
52 func random() int { //@item(good_random, "random", "func() int", "func")
53 _ = "random() int" //@preparerename("random", "")
54 y := 6 + 7 //@preparerename("7", "")
55 return y //@preparerename("return", "", span="")
56 }
57
58 func random2(y int) int { //@item(good_random2, "random2", "func(y int) int", "func"),item(good_y_param, "y", "int", "var")
59 //@complete("", good_y_param, types_import, good_random, good_random2, good_stuff)
60 var b types.Bob = &types.X{} //@preparerename("ypes","types", span="types")
61 if _, ok := b.(*types.X); ok { //@complete(re"()X", X_struct, Y_struct, Bob_interface, CoolAlias)
62 _ = 0 // suppress "empty branch" diagnostic
63 }
64
65 return y
66 }