-
Notifications
You must be signed in to change notification settings - Fork 57
/
Hover.res
255 lines (190 loc) · 3.83 KB
/
Hover.res
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
let abc = 22 + 34
// ^hov
type t = (int, float)
// ^hov
module Id = {
// ^hov
type x = int
}
@ocaml.doc("This module is commented")
module Dep: {
@ocaml.doc("Some doc comment")
let customDouble: int => int
} = {
let customDouble = foo => foo * 2
}
module D = Dep
// ^hov
let cd = D.customDouble
// ^hov
module HoverInsideModuleWithComponent = {
let x = 2 // check that hover on x works
// ^hov
@react.component
let make = () => React.null
}
@ocaml.doc("Doc comment for functionWithTypeAnnotation")
let functionWithTypeAnnotation: unit => int = () => 1
// ^hov
@react.component
let make = (~name) => React.string(name)
// ^hov
module C2 = {
@react.component
let make2 = (~name: string) => React.string(name)
// ^hov
}
let num = 34
// ^hov
module type Logger = {
// ^hov
let log: string => unit
}
module JsLogger: Logger = {
// ^hov
let log = (msg: string) => Js.log(msg)
let _oneMore = 3
}
module JJ = JsLogger
// ^def
module IdDefinedTwice = {
// ^hov
let _x = 10
let y = 20
let _x = 10
}
module A = {
let x = 13
}
module B = A
// ^hov
module C = B
// ^hov
module Comp = {
@react.component
let make = (~children: React.element) => children
}
module Comp1 = Comp
let _ =
<Comp>
<div />
<div />
</Comp>
// ^hov
let _ =
<Comp1>
<div />
<div />
</Comp1>
// ^hov
type r<'a> = {i: 'a, f: float}
let _get = r => r.f +. r.i
// ^hov
let withAs = (~xx as yyy) => yyy + 1
// ^hov
module AA = {
type cond<'a> = [< #str(string)] as 'a
let fnnxx = (b: cond<_>) => true ? b : b
}
let funAlias = AA.fnnxx
let typeOk = funAlias
// ^hov
let typeDuplicate = AA.fnnxx
// ^hov
@live let dd = 34
// ^hov
let arity0a = (. ()) => {
//^hov
let f = () => 3
f
}
let arity0b = (. (), . ()) => 3
// ^hov
let arity0c = (. (), ()) => 3
// ^hov
let arity0d = (. ()) => {
// ^hov
let f = () => 3
f
}
/**doc comment 1*/
let docComment1 = 12
// ^hov
/** doc comment 2 */
let docComment2 = 12
// ^hov
module ModWithDocComment = {
/*** module level doc comment 1 */
/** doc comment for x */
let x = 44
/*** module level doc comment 2 */
}
module TypeSubstitutionRecords = {
type foo<'a> = {content: 'a, zzz: string}
type bar = {age: int}
type foobar = foo<bar>
let x1: foo<bar> = {content: {age: 42}, zzz: ""}
// ^hov
let x2: foobar = {content: {age: 42}, zzz: ""}
// ^hov
// x1.content.
// ^com
// x2.content.
// ^com
type foo2<'b> = foo<'b>
type foobar2 = foo2<bar>
let y1: foo2<bar> = {content: {age: 42}, zzz: ""}
let y2: foobar2 = {content: {age: 42}, zzz: ""}
// y1.content.
// ^com
// y2.content.
// ^com
}
module CompV4 = {
type props<'n, 's> = {n?: 'n, s: 's}
let make = props => {
let _ = props.n == Some(10)
React.string(props.s)
}
}
let mk = CompV4.make
// ^hov
type useR = {x: int, y: list<option<r<float>>>}
let testUseR = (v: useR) => v
// ^hov
let usr: useR = {
x: 123,
y: list{},
}
// let f = usr
// ^hov
module NotShadowed = {
/** Stuff */
let xx_ = 10
/** More Stuff */
let xx = xx_
}
module Shadowed = {
/** Stuff */
let xx = 10
/** More Stuff */
let xx = xx
}
let _ = NotShadowed.xx
// ^hov
let _ = Shadowed.xx
// ^hov
type recordWithDocstringField = {
/** Mighty fine field here. */
someField: bool,
}
let x: recordWithDocstringField = {
someField: true,
}
// x.someField
// ^hov
let someField = x.someField
// ^hov
type variant = | /** Cool variant! */ CoolVariant | /** Other cool variant */ OtherCoolVariant
let coolVariant = CoolVariant
// ^hov