Skip to content

Commit 85c4304

Browse files
committed
basic completion for opts
1 parent 0252a5b commit 85c4304

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,22 @@ let completeTypedValue t ~env ~full ~prefix =
15421542
~env))
15431543
in
15441544
items
1545+
| Some (Toption (env, t)) ->
1546+
let items =
1547+
[
1548+
Completion.create ~name:"None"
1549+
~kind:(Label (t |> Shared.typeToString))
1550+
~env;
1551+
Completion.create ~name:"Some(_)"
1552+
~kind:(Label (t |> Shared.typeToString))
1553+
~env;
1554+
]
1555+
in
1556+
if prefix = "" then items
1557+
else
1558+
items
1559+
|> List.filter (fun (item : Completion.t) ->
1560+
Utils.startsWith item.name prefix)
15451561
| _ -> []
15461562

15471563
let processCompletable ~debug ~full ~scope ~env ~pos ~forHover

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,19 @@ Complete src/CompletionFunctionArguments.res 14:25
3232
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)
35-
[]
35+
[{
36+
"label": "None",
37+
"kind": 4,
38+
"tags": [],
39+
"detail": "bool",
40+
"documentation": null
41+
}, {
42+
"label": "Some(_)",
43+
"kind": 4,
44+
"tags": [],
45+
"detail": "bool",
46+
"documentation": null
47+
}]
3648

3749
Complete src/CompletionFunctionArguments.res 19:27
3850
posCursor:[19:27] posNoWhite:[19:26] Found expr:[17:8->23:1]
@@ -108,7 +120,13 @@ Complete src/CompletionFunctionArguments.res 50:32
108120
posCursor:[50:32] posNoWhite:[50:31] Found expr:[50:11->50:33]
109121
Pexp_apply ...[50:11->50:30] (...[50:31->50:32])
110122
Completable: Value[someFnTakingVariant]($0=S)
111-
[]
123+
[{
124+
"label": "Some(_)",
125+
"kind": 4,
126+
"tags": [],
127+
"detail": "someVariant",
128+
"documentation": null
129+
}]
112130

113131
Complete src/CompletionFunctionArguments.res 53:43
114132
posCursor:[53:43] posNoWhite:[53:42] Found expr:[53:11->53:44]

0 commit comments

Comments
 (0)