aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/regtest/marker/testdata/hover/linkable_generics.txt
blob: be8e9e5cd7ad54b2dd9cfb09701aa2266cd97c66 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
This file contains tests for documentation links to generic code in hover.

-- flags --
-min_go=go1.18

-- go.mod --
module mod.com

go 1.19

-- a.go --
package a

import "mod.com/generic"

func _() {
	// Hovering over instantiated object should produce accurate type
	// information, but link to the generic declarations.

	var x generic.GT[int] //@hover("GT", "GT", xGT)
	_ = x.F //@hover("x", "x", x),hover("F", "F", xF)

	f := generic.GF[int] //@hover("GF", "GF", fGF)
	_ = f //@hover("f", "f", f)
}

-- generic/generic.go --
package generic

// Hovering over type parameters should link to documentation.
//
// TODO(rfindley): should it? We should probably link to the type.
type GT[P any] struct{ //@hover("GT", "GT", GT),hover("P", "P", GTP)
	F P //@hover("F", "F", F),hover("P", "P", FP)
}

func (GT[P]) M(p P) { //@hover("GT", "GT", GTrecv),hover("M","M", M),hover(re"p (P)", re"p (P)", pP)
}

func GF[P any] (p P) { //@hover("GF", "GF", GF)
}

-- @F/hover.md --
```go
field F P
```

@hover("F", "F", F),hover("P", "P", FP)


[`(generic.GT).F` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.F)
-- @FP/hover.md --
```go
type parameter P any
```
-- @GF/hover.md --
```go
func GF[P any](p P)
```

[`generic.GF` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GF)
-- @GT/hover.md --
```go
type GT[P any] struct {
	F P //@hover("F", "F", F),hover("P", "P", FP)
}

func (GT[P]).M(p P)
```

Hovering over type parameters should link to documentation.

TODO(rfindley): should it? We should probably link to the type.


[`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)
-- @GTP/hover.md --
```go
type parameter P any
```
-- @GTrecv/hover.md --
```go
type GT[P any] struct {
	F P //@hover("F", "F", F),hover("P", "P", FP)
}

func (GT[P]).M(p P)
```

Hovering over type parameters should link to documentation.

TODO(rfindley): should it? We should probably link to the type.


[`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)
-- @M/hover.md --
```go
func (GT[P]).M(p P)
```

[`(generic.GT).M` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.M)
-- @f/hover.md --
```go
var f func(p int)
```
-- @fGF/hover.md --
```go
func generic.GF(p int) // func[P any](p P)
```

[`generic.GF` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GF)
-- @pP/hover.md --
```go
type parameter P any
```
-- @x/hover.md --
```go
var x generic.GT[int]
```

@hover("GT", "GT", xGT)
-- @xF/hover.md --
```go
field F int
```

@hover("F", "F", F),hover("P", "P", FP)


[`(generic.GT).F` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT.F)
-- @xGT/hover.md --
```go
type GT[P any] struct {
	F P //@hover("F", "F", F),hover("P", "P", FP)
}

func (generic.GT[P]).M(p P)
```

Hovering over type parameters should link to documentation.

TODO(rfindley): should it? We should probably link to the type.


[`generic.GT` on pkg.go.dev](https://pkg.go.dev/mod.com/generic#GT)