Debian Codegraph @

gopls/internal/test/marker/testdata/completion/variadic.txt

raw
1 This test checks completion related to variadic functions.
2
3 -- flags --
4 -ignore_extra_diags
5
6 -- variadic.go --
7 package variadic
8
9 func foo(i int, strs ...string) {}
10
11 func bar() []string { //@item(vFunc, "bar", "func() []string", "func")
12 return nil
13 }
14
15 func _() {
16 var (
17 i int //@item(vInt, "i", "int", "var")
18 s string //@item(vStr, "s", "string", "var")
19 ss []string //@item(vStrSlice, "ss", "[]string", "var")
20 v any //@item(vIntf, "v", "any", "var")
21 )
22
23 foo() //@rank(re"()\\)", vInt, vStr),rank(re"()\\)", vInt, vStrSlice)
24 foo(123, ) //@rank(re"()\\)", vStr, vInt),rank(re"()\\)", vStrSlice, vInt)
25 foo(123, "", ) //@rank(re"()\\)", vStr, vInt),rank(re"()\\)", vStr, vStrSlice)
26 foo(123, s, "") //@rank(re"(), \"", vStr, vStrSlice)
27
28 // snippet will add the "..." for you
29 foo(123, ) //@snippet(re"()\\)", vStrSlice, "ss..."),snippet(re"()\\)", vFunc, "bar()..."),snippet(re"()\\)", vStr, "s")
30
31 // don't add "..." for any
32 foo(123, ) //@snippet(re"()\\)", vIntf, "v")
33 }
34
35 func qux(...func()) {}
36 func f() {} //@item(vVarArg, "f", "func()", "func")
37
38 func _() {
39 qux(f) //@snippet(re"()\\)", vVarArg, "f")
40 }
41
42 func _() {
43 foo(0, []string{}...) //@complete(re"()\\)")
44 }
45
46 -- variadic_intf.go --
47 package variadic
48
49 type baz interface {
50 baz()
51 }
52
53 func wantsBaz(...baz) {}
54
55 type bazImpl int
56
57 func (bazImpl) baz() {}
58
59 func _() {
60 var (
61 impls []bazImpl //@item(vImplSlice, "impls", "[]bazImpl", "var")
62 impl bazImpl //@item(vImpl, "impl", "bazImpl", "var")
63 bazes []baz //@item(vIntfSlice, "bazes", "[]baz", "var")
64 )
65
66 wantsBaz() //@rank(re"()\\)", vImpl, vImplSlice),rank(re"()\\)", vIntfSlice, vImplSlice)
67 }