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