Debian Codegraph @

gopls/internal/test/marker/testdata/hover/linkable_generics.txt

raw
1 This file contains tests for documentation links to generic code in hover.
2
3 -- go.mod --
4 module mod.com
5
6 go 1.19
7
8 -- a.go --
9 package a
10
11 import "mod.com/generic"
12
13 func _() {
14 // Hovering over instantiated object should produce accurate type
15 // information, but link to the generic declarations.
16
17 var x generic.GT[int] //@hover("GT", "GT", xGT)
18 _ = x.F //@hover("x", "x", x),hover("F", "F", xF)
19
20 f := generic.GF[int] //@hover("GF", "GF", fGF)
21 _ = f //@hover("f", "f", f)
22 }
23
24 -- generic/generic.go --
25 package generic
26
27 // Hovering over type parameters should link to documentation.
28 //
29 // TODO(rfindley): should it? We should probably link to the type.
30 type GT[P any] struct{ //@hover("GT", "GT", GT),hover("P", "P", GTP)
31 F P //@hover("F", "F", F),hover("P", "P", FP)
32 }
33
34 func (GT[P]) M(p P) { //@hover("GT", "GT", GTrecv),hover("M","M", M),hover(re"p (P)", re"p (P)", pP)
35 }
36
37 func GF[P any] (p P) { //@hover("GF", "GF", GF)
38 }
39
40 -- @F --
41 ```go
42 field F P
43 ```
44
45 ---
46
47 @hover("F", "F", F),hover("P", "P", FP)
48
49
50 ---
51
52 [`(generic.GT).F` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.F)
53 -- @FP --
54 ```go
55 type parameter P any
56 ```
57 -- @GF --
58 ```go
59 func GF[P any](p P)
60 ```
61
62 ---
63
64 [`generic.GF` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GF)
65 -- @GT --
66 ```go
67 type GT[P any] struct {
68 F P //@hover("F", "F", F),hover("P", "P", FP)
69 }
70 ```
71
72 ---
73
74 Hovering over type parameters should link to documentation.
75
76 TODO(rfindley): should it? We should probably link to the type.
77
78
79 ```go
80 func (GT[P]) M(p P)
81 ```
82
83 ---
84
85 [`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)
86 -- @GTP --
87 ```go
88 type parameter P any
89 ```
90 -- @GTrecv --
91 ```go
92 type GT[P any] struct {
93 F P //@hover("F", "F", F),hover("P", "P", FP)
94 }
95 ```
96
97 ---
98
99 Hovering over type parameters should link to documentation.
100
101 TODO(rfindley): should it? We should probably link to the type.
102
103
104 ```go
105 func (GT[P]) M(p P)
106 ```
107
108 ---
109
110 [`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)
111 -- @M --
112 ```go
113 func (GT[P]) M(p P)
114 ```
115
116 ---
117
118 [`(generic.GT).M` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.M)
119 -- @f --
120 ```go
121 var f func(p int)
122 ```
123 -- @fGF --
124 ```go
125 func generic.GF(p int) // func[P any](p P)
126 ```
127
128 ---
129
130 [`generic.GF` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GF)
131 -- @pP --
132 ```go
133 type parameter P any
134 ```
135 -- @x --
136 ```go
137 var x generic.GT[int]
138 ```
139
140 ---
141
142 @hover("GT", "GT", xGT)
143 -- @xF --
144 ```go
145 field F int
146 ```
147
148 ---
149
150 @hover("F", "F", F),hover("P", "P", FP)
151
152
153 ---
154
155 [`(generic.GT).F` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.F)
156 -- @xGT --
157 ```go
158 type GT[P any] struct {
159 F P //@hover("F", "F", F),hover("P", "P", FP)
160 }
161 ```
162
163 ---
164
165 Hovering over type parameters should link to documentation.
166
167 TODO(rfindley): should it? We should probably link to the type.
168
169
170 ```go
171 func (generic.GT[P]) M(p P)
172 ```
173
174 ---
175
176 [`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)