Skip to content

Commit 3bbdbee

Browse files
committed
Hover: expand definition of type arguments.
1 parent c8afd43 commit 3bbdbee

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

analysis/src/Shared.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ let findTypeConstructors (tel : Types.type_expr list) =
4949
let rec loop (te : Types.type_expr) =
5050
match te.desc with
5151
| Tlink te1 | Tsubst te1 | Tpoly (te1, _) -> loop te1
52-
| Tconstr (path, _, _) -> addPath path
52+
| Tconstr (path, args, _) ->
53+
addPath path;
54+
args |> List.iter loop
5355
| Tarrow (_, te1, te2, _) ->
5456
loop te1;
5557
loop te2

analysis/tests/src/Hover.res

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,15 @@ module TypeSubstitutionRecords = {
190190
module CompV4 = {
191191
type props<'n, 's> = {n?: 'n, s: 's}
192192
let make = props => {
193-
let _ = props.n == Some (10)
193+
let _ = props.n == Some(10)
194194
React.string(props.s)
195195
}
196196
}
197197

198198
let mk = CompV4.make
199199
// ^hov
200+
201+
type useR = {x: int, y: list<option<r<float>>>}
202+
203+
let testUseR = (v: useR) => v
204+
// ^hov

analysis/tests/src/expected/Div.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Hover src/Div.res 0:10
22
getLocItem #3: heuristic for <div>
3-
{"contents": "```rescript\n(\n string,\n ~props: ReactDOMRe.domProps=?,\n array<React.element>,\n) => React.element\n```\n\n```rescript\ntype element\n```"}
3+
{"contents": "```rescript\n(\n string,\n ~props: ReactDOMRe.domProps=?,\n array<React.element>,\n) => React.element\n```\n\n```rescript\ntype domProps = ReactDOM.Props.domProps\n```\n\n```rescript\ntype element\n```"}
44

55
Complete src/Div.res 3:17
66
posCursor:[3:17] posNoWhite:[3:16] Found expr:[3:4->3:17]

analysis/tests/src/expected/Hover.res.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Hover src/Hover.res 148:6
105105
{"contents": "```rescript\nint\n```\n\n doc comment 2 "}
106106

107107
Hover src/Hover.res 165:23
108-
{"contents": "```rescript\nfoo<bar>\n```\n\n```rescript\ntype foo<'a> = {content: 'a, zzz: string}\n```"}
108+
{"contents": "```rescript\nfoo<bar>\n```\n\n```rescript\ntype foo<'a> = {content: 'a, zzz: string}\n```\n\n```rescript\ntype bar = {age: int}\n```"}
109109

110110
Hover src/Hover.res 167:22
111111
{"contents": "```rescript\nfoobar\n```\n\n```rescript\ntype foobar = foo<bar>\n```"}
@@ -161,3 +161,6 @@ Completable: Cpath Value[y2].content.""
161161
Hover src/Hover.res 197:4
162162
{"contents": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n```rescript\ntype props<'n, 's> = {?n: 'n, s: 's}\n```\n\n```rescript\ntype element\n```"}
163163

164+
Hover src/Hover.res 202:16
165+
{"contents": "```rescript\nuseR\n```\n\n```rescript\ntype useR = {x: int, y: list<option<r<float>>>}\n```\n\n```rescript\ntype r<'a> = {i: 'a, f: float}\n```"}
166+

0 commit comments

Comments
 (0)