Debian Codegraph @

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

raw
1 This test checks behavior of completion within comments.
2
3 -- flags --
4 -ignore_extra_diags
5
6 -- go.mod --
7 module golang.org/lsptests/comment
8
9 go 1.18
10
11 -- p.go --
12 package comment_completion
13
14 var p bool
15
16 //@complete(re"//()")
17
18 func _() {
19 var a int
20
21 switch a {
22 case 1:
23 //@complete(re"//()")
24 _ = a
25 }
26
27 var b chan int
28 select {
29 case <-b:
30 //@complete(re"//()")
31 _ = b
32 }
33
34 var (
35 //@complete(re"//()")
36 _ = a
37 )
38 }
39
40 // //@complete(re"() ", variableC)
41 var C string //@item(variableC, "C", "string", "var") //@complete(re"() ", variableC)
42
43 // //@complete(re"() ", constant)
44 const Constant = "example" //@item(constant, "Constant", "string", "const") //@complete(re"() ", constant)
45
46 // //@complete(re"() ", structType, fieldB, fieldA)
47 type StructType struct { //@item(structType, "StructType", "struct{...}", "struct") //@complete(re"() ", structType, fieldA, fieldB)
48 // //@complete(re"() ", fieldA, structType, fieldB)
49 A string //@item(fieldA, "A", "string", "field") //@complete(re"() ", fieldA, structType, fieldB)
50 b int //@item(fieldB, "b", "int", "field") //@complete(re"() ", fieldB, structType, fieldA)
51 }
52
53 // //@complete(re"() ", method, structRecv, paramX, resultY, fieldB, fieldA)
54 func (structType *StructType) Method(X int) (Y int) { //@item(structRecv, "structType", "*StructType", "var"),item(method, "Method", "func(X int) (Y int)", "method"),item(paramX, "X", "int", "var"),item(resultY, "Y", "int", "var")
55 // //@complete(re"() ", method, structRecv, paramX, resultY, fieldB, fieldA)
56 return
57 }
58
59 // //@complete(re"() ", newType)
60 type NewType string //@item(newType, "NewType", "string", "type") //@complete(re"() ", newType)
61
62 // //@complete(re"() ", testInterface, testA, testB)
63 type TestInterface interface { //@item(testInterface, "TestInterface", "interface{...}", "interface")
64 // //@complete(re"() ", testA, testInterface, testB)
65 TestA(L string) (M int) //@item(testA, "TestA", "func(L string) (M int)", "method"),item(paramL, "L", "var", "string"),item(resM, "M", "var", "int") //@complete(re"() ", testA, testInterface, testB)
66 TestB(N int) bool //@item(testB, "TestB", "func(N int) bool", "method"),item(paramN, "N", "var", "int") //@complete(re"() ", testB, testInterface, testA)
67 }
68
69 // //@complete(re"() ", function)
70 func Function() int { //@item(function, "Function", "func() int", "func") //@complete(re"() ", function)
71 // //@complete(re"() ", function)
72 return 0
73 }
74
75 // This tests that completing right after "//" (no space) above a declaration
76 // suggests the identifier name, prepending a space for proper doc comment style.
77 //@complete(re"//()", plainFunc)
78 // This tests completing with a partial prefix after "//" (no space) also
79 // prepends a space, covering the case where the user has typed "//Plain".
80 //Plain//@complete(re"//Plain()", plainFunc)
81 func PlainFunc() {} //@item(plainFunc, "PlainFunc", "func()", "func")
82
83 // This tests multiline block comments and completion with prefix
84 // Lorem Ipsum Multili//@complete(re"()Multi", multiline)
85 // Lorem ipsum dolor sit ametom
86 func Multiline() int { //@item(multiline, "Multiline", "func() int", "func")
87 // //@complete(re"() ", multiline)
88 return 0
89 }
90
91 // This test checks that gopls does not panic if the receiver is syntactically
92 // present but empty.
93 //
94 // //@complete(re"() ")
95 func () _() {}
96
97
98 // This test checks that gopls does not panic if there is a duplicate declaration.
99 func f() {}
100
101 // //@complete(re"() ")
102 func () f() {}