Skip to content

Commit 87c01a4

Browse files
committed
Use the pattern path found to trigger completion.
1 parent eb1d185 commit 87c01a4

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

analysis/src/CompletionFrontEnd.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,12 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
676676
(Loc.toString pat.ppat_loc);
677677
(match pat.ppat_desc with
678678
| Ppat_construct (lid, _) ->
679+
let lidPath = flattenLidCheckDot lid in
679680
if debug then
680681
Printf.printf "XXX Ppat_construct %s:%s\n"
681-
(flattenLidCheckDot lid |> String.concat ".")
682-
(Loc.toString lid.loc)
682+
(lidPath |> String.concat ".")
683+
(Loc.toString lid.loc);
684+
setResult (Cpath (CPId (lidPath, Value)))
683685
| _ -> ());
684686
Ast_iterator.default_iterator.pat iterator pat)
685687
in

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

+34-2
Original file line numberDiff line numberDiff line change
@@ -1389,13 +1389,45 @@ posCursor:[362:8] posNoWhite:[362:7] Found expr:[361:2->365:3]
13891389
posCursor:[362:8] posNoWhite:[362:7] Found pattern:[362:7->364:5]
13901390
posCursor:[362:8] posNoWhite:[362:7] Found pattern:[362:7->362:8]
13911391
XXX Ppat_construct T:[362:7->362:8]
1392-
[]
1392+
Completable: Cpath Value[T]
1393+
[{
1394+
"label": "That",
1395+
"kind": 4,
1396+
"tags": [],
1397+
"detail": "That\n\ntype v = This | That",
1398+
"documentation": null
1399+
}, {
1400+
"label": "This",
1401+
"kind": 4,
1402+
"tags": [],
1403+
"detail": "This\n\ntype v = This | That",
1404+
"documentation": null
1405+
}, {
1406+
"label": "TableclothMap",
1407+
"kind": 9,
1408+
"tags": [],
1409+
"detail": "file module",
1410+
"documentation": null
1411+
}, {
1412+
"label": "TypeDefinition",
1413+
"kind": 9,
1414+
"tags": [],
1415+
"detail": "file module",
1416+
"documentation": null
1417+
}]
13931418

13941419
Complete tests/src/Completion.res 373:21
13951420
posCursor:[373:21] posNoWhite:[373:20] Found expr:[371:8->376:3]
13961421
posCursor:[373:21] posNoWhite:[373:20] Found expr:[372:2->376:3]
13971422
posCursor:[373:21] posNoWhite:[373:20] Found pattern:[373:7->375:5]
13981423
posCursor:[373:21] posNoWhite:[373:20] Found pattern:[373:7->373:21]
13991424
XXX Ppat_construct AndThatOther.T:[373:7->373:21]
1400-
[]
1425+
Completable: Cpath Value[AndThatOther, T]
1426+
[{
1427+
"label": "ThatOther",
1428+
"kind": 4,
1429+
"tags": [],
1430+
"detail": "ThatOther\n\ntype v = And | ThatOther",
1431+
"documentation": null
1432+
}]
14011433

0 commit comments

Comments
 (0)