Skip to content

Commit 1b65fea

Browse files
committed
expand options where it makes sense
1 parent 85c4304 commit 1b65fea

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,10 @@ let rec extractType ~env ~package (t : Types.type_expr) =
15091509
| Ttuple expressions -> Some (Tuple (env, expressions))
15101510
| _ -> None
15111511

1512-
let completeTypedValue t ~env ~full ~prefix =
1512+
let rec completeTypedValue t ~env ~full ~prefix ~expandOption =
15131513
match t |> extractType ~env ~package:full.package with
1514+
| Some (Toption (env, typ)) when expandOption ->
1515+
typ |> completeTypedValue ~env ~full ~prefix ~expandOption:false
15141516
| Some (Tbool env) ->
15151517
let items =
15161518
[
@@ -1938,7 +1940,10 @@ Note: The `@react.component` decorator requires the react-jsx config to be set i
19381940
in
19391941
match targetLabel with
19401942
| None -> []
1941-
| Some (_, typ) -> typ |> completeTypedValue ~env ~full ~prefix)
1943+
| Some (Labelled _, typ) ->
1944+
typ |> completeTypedValue ~env ~full ~prefix ~expandOption:true
1945+
| Some (Unlabelled _, typ) ->
1946+
typ |> completeTypedValue ~env ~full ~prefix ~expandOption:false)
19421947
| CnamedArg (cp, prefix, identsSeen) ->
19431948
let labels =
19441949
match

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ posCursor:[14:25] posNoWhite:[14:24] Found expr:[14:11->14:26]
3333
Pexp_apply ...[14:11->14:17] (~isOff14:19->14:24=...__ghost__[0:-1->0:-1])
3434
Completable: Value[someFn](~isOff)
3535
[{
36-
"label": "None",
36+
"label": "true",
3737
"kind": 4,
3838
"tags": [],
3939
"detail": "bool",
4040
"documentation": null
4141
}, {
42-
"label": "Some(_)",
42+
"label": "false",
4343
"kind": 4,
4444
"tags": [],
4545
"detail": "bool",
@@ -138,5 +138,11 @@ Complete src/CompletionFunctionArguments.res 56:44
138138
posCursor:[56:44] posNoWhite:[56:43] Found expr:[56:11->56:45]
139139
Pexp_apply ...[56:11->56:30] (~configOpt256:32->56:42=...[56:43->56:44])
140140
Completable: Value[someFnTakingVariant](~configOpt2=O)
141-
[]
141+
[{
142+
"label": "One",
143+
"kind": 4,
144+
"tags": [],
145+
"detail": "One\n\n",
146+
"documentation": null
147+
}]
142148

0 commit comments

Comments
 (0)