Debian Codegraph @

gopls/internal/test/marker/testdata/mcptools/context.txt

raw
1 This test exercises the "go_context" MCP tool.
2
3 -- flags --
4 -mcp
5 -ignore_extra_diags
6
7 -- settings.json --
8 {
9 "mcpTools": {
10 "go_context": true
11 }
12 }
13
14 -- go.mod --
15 module example.com
16
17 -- a/main.go --
18 // File doc for main.go part 1.
19 package main
20
21 // File doc for main.go part 2.
22 import(
23 "example.com/a/comment"
24 )
25
26 // File doc for main.go part 3.
27
28 // doc comment for func foo.
29 func foo() {//@mcptool("go_context", `{"file": "$WORKDIR/a/main.go"}`, output=withComment)
30 comment.Foo("", 0)
31 }
32
33 -- a/a.go --
34 // File doc for a.go.
35 package main
36
37 // doc comment for func a.
38 func a () {}
39
40 // doc comment for type b.
41 type b struct {}
42
43 // doc comment for const c.
44 const c = ""
45
46 // doc comment for var d.
47 var d int
48
49 -- a/comment/doc.go --
50 // Copyright 2025 The Go Authors. All rights reserved.
51 // Use of this source code is governed by a BSD-style
52 // license that can be found in the LICENSE file.
53
54 /*
55 Package doc for package comment.
56 */
57 package comment
58
59 -- a/comment/comment.go --
60 // File doc for comment.go part 1.
61 package comment
62
63 // File doc for comment.go part 2.
64 import (
65 // comment for package renaming.
66 myfmt "fmt"
67 )
68
69 // File doc for comment.go part 3.
70
71 // doc comment for comment.Foo
72 func Foo(foo string, _ int) {
73 myfmt.Printf("%s", foo)
74 }
75
76 // Random comment floating around.
77
78 -- @withComment --
79 Current package "example.com/a" (package main):
80
81 main.go (current file):
82 ```go
83 // File doc for main.go part 1.
84 package main
85
86 // File doc for main.go part 2.
87 import(
88 "example.com/a/comment"
89 )
90
91 // File doc for main.go part 3.
92
93 // doc comment for func foo.
94 func foo()
95
96 ```
97
98 a.go:
99 ```go
100 // File doc for a.go.
101 package main
102
103 // doc comment for func a.
104 func a ()
105
106 // doc comment for type b.
107 type b struct {}
108 // doc comment for const c.
109 const c = ""
110 // doc comment for var d.
111 var d int
112 ```
113
114 Current file "main.go" contains this import declaration:
115 ```go
116 import(
117 "example.com/a/comment"
118 )
119 ```
120
121 The imported packages declare the following symbols:
122
123 "example.com/a/comment" (package comment)
124 comment.go:
125 ```go
126 // File doc for comment.go part 1.
127 package comment
128
129 // File doc for comment.go part 2.
130 import (
131 // comment for package renaming.
132 myfmt "fmt"
133 )
134
135 // File doc for comment.go part 3.
136
137 // doc comment for comment.Foo
138 func Foo(foo string, _ int)
139
140 ```
141
142 doc.go:
143 ```go
144 /*
145 Package doc for package comment.
146 */
147 package comment
148
149 ```
150
151 -- b/main.go --
152 package main
153
154 import(
155 "example.com/b/function"
156 )
157
158 func testFunction() {//@mcptool("go_context", `{"file":"$WORKDIR/b/main.go"}`, output=withFunction)
159 function.Foo(0, "")
160 }
161
162 -- b/function/function.go --
163 package function
164
165 func Foo(int, string) {}
166
167 func foo(string, int) {}
168
169 type unexported struct {}
170
171 func (*unexported) unexported(int) {}
172
173 func (*unexported) Exported(int) {}
174
175 type Exported struct{}
176
177 func (*Exported) unexported(int) {}
178
179 func (*Exported) Exported(int) {}
180
181 -- @withFunction --
182 Current package "example.com/b" (package main):
183
184 main.go (current file):
185 ```go
186 package main
187
188 import(
189 "example.com/b/function"
190 )
191
192 func testFunction()
193
194 ```
195
196 Current file "main.go" contains this import declaration:
197 ```go
198 import(
199 "example.com/b/function"
200 )
201 ```
202
203 The imported packages declare the following symbols:
204
205 "example.com/b/function" (package function)
206 function.go:
207 ```go
208 package function
209
210 func Foo(int, string)
211
212 type Exported struct{}
213
214 func (*Exported) Exported(int)
215
216 ```
217
218 -- c/main.go --
219 package main
220
221 import(
222 "example.com/c/types"
223 )
224
225 var x types.Exported //@mcptool("go_context", `{"file":"$WORKDIR/c/main.go"}`, output=withType)
226
227 -- c/types/types.go --
228 package types
229
230 // Doc for exported.
231 type Exported struct {
232 // Doc for exported.
233 Exported string
234 // Doc for unexported.
235 unexported string
236 }
237
238 // Doc for types.
239 type (
240 // Doc for Foo first line.
241 // Doc for Foo second line.
242 Foo struct {
243 foo string
244 }
245
246 // Doc for foo.
247 foo struct {}
248
249 // Doc for Bar.
250 Bar struct {
251 bar string
252 }
253
254 // Doc for bar.
255 bar struct {}
256 )
257
258 -- @withType --
259 Current package "example.com/c" (package main):
260
261 main.go (current file):
262 ```go
263 package main
264
265 import(
266 "example.com/c/types"
267 )
268
269 var x types.Exported
270 ```
271
272 Current file "main.go" contains this import declaration:
273 ```go
274 import(
275 "example.com/c/types"
276 )
277 ```
278
279 The imported packages declare the following symbols:
280
281 "example.com/c/types" (package types)
282 types.go:
283 ```go
284 package types
285
286 // Doc for exported.
287 type Exported struct {
288 // Doc for exported.
289 Exported string
290 // Doc for unexported.
291 unexported string
292 }
293
294 // Doc for types.
295 type (
296 // Doc for Foo first line.
297 // Doc for Foo second line.
298 Foo struct {
299 foo string
300 }
301 // Doc for Bar.
302 Bar struct {
303 bar string
304 }
305 )
306
307 ```
308
309 -- d/main.go --
310 package main
311
312 import(
313 "example.com/d/values"
314 )
315
316 var y values.ConstFoo //@mcptool("go_context", `{"file":"$WORKDIR/d/main.go"}`, output=withValue)
317
318 -- d/values/consts.go --
319 package values
320
321 const (
322 // doc for ConstFoo
323 ConstFoo = "Foo" // comment for ConstFoo
324 // doc for constFoo
325 constFoo = "foo" // comment for constFoo
326 // doc for ConstBar
327 ConstBar = "Bar" // comment for ConstBar
328 // doc for constBar
329 constBar = "bar" // comment for constBar
330 )
331
332 // doc for ConstExported
333 const ConstExported = "Exported" // comment for ConstExported
334
335 // doc for constUnexported
336 var constUnexported = "unexported" // comment for constUnexported
337
338 -- d/values/vars.go --
339 package values
340
341 var (
342 // doc for VarFoo
343 VarFoo = "Foo" // comment for VarFoo
344 // doc for varFoo
345 varFoo = "foo" // comment for varFoo
346 // doc for VarBar
347 VarBar = "Bar" // comment for VarBar
348 // doc for varBar
349 varBar = "bar" // comment for varBar
350 )
351
352 // doc for VarExported
353 var VarExported = "Exported" // comment for VarExported
354
355 // doc for varUnexported
356 var varUnexported = "unexported" // comment for varUnexported
357
358 -- @withValue --
359 Current package "example.com/d" (package main):
360
361 main.go (current file):
362 ```go
363 package main
364
365 import(
366 "example.com/d/values"
367 )
368
369 var y values.ConstFoo
370 ```
371
372 Current file "main.go" contains this import declaration:
373 ```go
374 import(
375 "example.com/d/values"
376 )
377 ```
378
379 The imported packages declare the following symbols:
380
381 "example.com/d/values" (package values)
382 consts.go:
383 ```go
384 package values
385
386 const (
387 // doc for ConstFoo
388 ConstFoo = "Foo" // comment for ConstFoo
389 // doc for ConstBar
390 ConstBar = "Bar" // comment for ConstBar
391 )
392
393 // doc for ConstExported
394 const ConstExported = "Exported" // comment for ConstExported
395
396 ```
397
398 vars.go:
399 ```go
400 package values
401
402 var (
403 // doc for VarFoo
404 VarFoo = "Foo" // comment for VarFoo
405 // doc for VarBar
406 VarBar = "Bar" // comment for VarBar
407 )
408
409 // doc for VarExported
410 var VarExported = "Exported" // comment for VarExported
411
412 ```
413
414 -- e/main.go --
415 package main
416
417 func main() {} //@mcptool("go_context", `{"file":"$WORKDIR/e/main.go"}`, output=samePackage)
418
419 -- e/foo.go --
420 package main
421
422 var (
423 foo string
424 Foo string
425 )
426
427 -- e/bar.go --
428 package main
429
430 const (
431 bar = ""
432 Bar = ""
433 )
434
435 -- e/baz.go --
436 package main
437
438 func baz(int) string {
439 return ""
440 }
441
442 func Baz(string) int {
443 return 0
444 }
445
446 -- @samePackage --
447 Current package "example.com/e" (package main):
448
449 main.go (current file):
450 ```go
451 package main
452
453 func main()
454
455 ```
456
457 bar.go:
458 ```go
459 package main
460
461 const (
462 bar = ""
463 Bar = ""
464 )
465 ```
466
467 baz.go:
468 ```go
469 package main
470
471 func baz(int) string
472
473 func Baz(string) int
474
475 ```
476
477 foo.go:
478 ```go
479 package main
480
481 var (
482 foo string
483 Foo string
484 )
485 ```
486
487 -- f/main.go --
488 package main
489
490 import "fmt"
491
492 func Foo() { //@mcptool("go_context", `{"file":"$WORKDIR/f/main.go"}`, output=withoutStdLib)
493 fmt.Println("foo")
494 }
495
496 -- @withoutStdLib --
497 Current package "example.com/f" (package main):
498
499 main.go (current file):
500 ```go
501 package main
502
503 import "fmt"
504
505 func Foo()
506
507 ```
508
509 Current file "main.go" contains this import declaration:
510 ```go
511 import "fmt"
512 ```
513