Debian Codegraph @

gopls/internal/test/marker/testdata/definition/misc.txt

raw
1 This test exercises miscellaneous definition and hover requests.
2
3 Its size expectations assume a 64-bit machine.
4
5 -- settings.json --
6 {"analyses": {"unusedfunc": false}}
7
8 -- go.mod --
9 module mod.com
10
11 go 1.16
12
13 -- flags --
14 -skip_goarch=386,arm
15
16 -- a.go --
17 package a //@loc(aPackage, re"package (a)"),hover(aPackage, aPackage, aPackage)
18
19 var (
20 // x is a variable.
21 x string //@loc(x, "x"),hover(x, x, hoverx)
22 )
23
24 // Constant block. When I hover on h, I should see this comment.
25 const (
26 // When I hover on g, I should see this comment.
27 g = 1 //@hover("g", "g", hoverg)
28
29 h = 2 //@hover("h", "h", hoverh)
30 )
31
32 // z is a variable too.
33 var z string //@loc(z, "z"),hover(z, z, hoverz)
34
35 func AStuff() { //@loc(AStuff, "AStuff")
36 x := 5
37 Random2(x) //@def("dom2", Random2)
38 Random() //@def("()", Random)
39 }
40
41 type H interface { //@loc(H, "H")
42 Goodbye()
43 }
44
45 type I interface { //@loc(I, "I")
46 B()
47 J
48 }
49
50 type J interface { //@loc(J, "J")
51 Hello()
52 }
53
54 func _() {
55 // 1st type declaration block
56 type (
57 a struct { //@hover("a", "a", hoverDeclBlocka)
58 x string
59 }
60 )
61
62 // 2nd type declaration block
63 type (
64 // b has a comment
65 b struct{} //@hover("b", "b", hoverDeclBlockb)
66 )
67
68 // 3rd type declaration block
69 type (
70 // c is a struct
71 c struct { //@hover("c", "c", hoverDeclBlockc)
72 f string
73 }
74
75 d string //@hover("d", "d", hoverDeclBlockd)
76 )
77
78 type (
79 e struct { //@hover("e", "e", hoverDeclBlocke)
80 f float64
81 } // e has a comment
82 )
83 }
84
85 var (
86 hh H //@hover("H", "H", hoverH)
87 ii I //@hover("I", "I", hoverI)
88 jj J //@hover("J", "J", hoverJ)
89 )
90 -- a_test.go --
91 package a
92
93 import (
94 "testing"
95 )
96
97 func TestA(t *testing.T) { //@hover("TestA", "TestA", hoverTestA)
98 }
99 -- random.go --
100 package a
101
102 func Random() int { //@loc(Random, "Random")
103 y := 6 + 7
104 return y
105 }
106
107 func Random2(y int) int { //@loc(Random2, "Random2"),loc(RandomParamY, "y")
108 return y //@def("y", RandomParamY),hover("y", "y", hovery)
109 }
110
111 type Pos struct {
112 x, y int //@loc(PosX, "x"),loc(PosY, "y")
113 }
114
115 // Typ has a comment. Its fields do not.
116 type Typ struct{ field string } //@loc(TypField, "field")
117
118 func _() {
119 x := &Typ{}
120 _ = x.field //@def("field", TypField),hover("field", "field", hoverfield)
121 }
122
123 func (p *Pos) Sum() int { //@loc(PosSum, "Sum")
124 return p.x + p.y //@hover("x", "x", hoverpx)
125 }
126
127 func _() {
128 var p Pos
129 _ = p.Sum() //@def("()", PosSum),hover(re"Sum()", `Sum`, hoverSum)
130 }
131 -- @aPackage --
132 ```go
133 package a
134 ```
135
136 ---
137
138 - Package path: mod.com
139 - Module: mod.com
140 - Language version: go1.16
141 -- @hoverDeclBlocka --
142 ```go
143 type a struct { // size=16 (0x10)
144 x string
145 }
146 ```
147
148 ---
149
150 1st type declaration block
151 -- @hoverDeclBlockb --
152 ```go
153 type b struct{} // size=0
154 ```
155
156 ---
157
158 b has a comment
159 -- @hoverDeclBlockc --
160 ```go
161 type c struct { // size=16 (0x10)
162 f string
163 }
164 ```
165
166 ---
167
168 c is a struct
169 -- @hoverDeclBlockd --
170 ```go
171 type d string // size=16 (0x10)
172 ```
173
174 ---
175
176 3rd type declaration block
177 -- @hoverDeclBlocke --
178 ```go
179 type e struct { // size=8
180 f float64
181 }
182 ```
183
184 ---
185
186 e has a comment
187 -- @hoverH --
188 ```go
189 type H interface {
190 Goodbye()
191 }
192 ```
193
194 ---
195
196 [`a.H` on pkg.go.dev](https://pkg.go.dev/mod.com#H)
197 -- @hoverI --
198 ```go
199 type I interface {
200 B()
201 J
202 }
203 ```
204
205 ---
206
207 ```go
208 func (J) Hello()
209 ```
210
211 ---
212
213 [`a.I` on pkg.go.dev](https://pkg.go.dev/mod.com#I)
214 -- @hoverJ --
215 ```go
216 type J interface {
217 Hello()
218 }
219 ```
220
221 ---
222
223 [`a.J` on pkg.go.dev](https://pkg.go.dev/mod.com#J)
224 -- @hoverSum --
225 ```go
226 func (p *Pos) Sum() int
227 ```
228
229 ---
230
231 [`(a.Pos).Sum` on pkg.go.dev](https://pkg.go.dev/mod.com#Pos.Sum)
232 -- @hoverTestA --
233 ```go
234 func TestA(t *testing.T)
235 ```
236 -- @hoverfield --
237 ```go
238 field field string
239 ```
240 -- @hoverg --
241 ```go
242 const g untyped int = 1
243 ```
244
245 ---
246
247 When I hover on g, I should see this comment.
248 -- @hoverh --
249 ```go
250 const h untyped int = 2
251 ```
252
253 ---
254
255 Constant block. When I hover on h, I should see this comment.
256 -- @hoverpx --
257 ```go
258 field x int
259 ```
260
261 ---
262
263 @loc(PosX, "x"),loc(PosY, "y")
264 -- @hoverx --
265 ```go
266 var x string
267 ```
268
269 ---
270
271 x is a variable.
272 -- @hovery --
273 ```go
274 var y int
275 ```
276 -- @hoverz --
277 ```go
278 var z string
279 ```
280
281 ---
282
283 z is a variable too.