@@ -510,9 +510,10 @@ let getComplementaryCompletionsForTypedValue ~opens ~allFiles ~scope ~env prefix
510
510
in
511
511
localCompletionsWithOpens @ fileModules
512
512
513
- let getCompletionsForPath ~debug ~package ~opens ~allFiles ~pos ~exact ~scope
513
+ let getCompletionsForPath ~debug ~package ~opens ~full ~pos ~exact ~scope
514
514
~completionContext ~env path =
515
515
if debug then Printf. printf " Path %s\n " (path |> String. concat " ." );
516
+ let allFiles = allFilesInPackage full.package in
516
517
match path with
517
518
| [] -> []
518
519
| [prefix] ->
@@ -621,18 +622,17 @@ let completionsGetCompletionType ~full = function
621
622
| {Completion. kind = ExtractedType (typ , _ ); env} :: _ -> Some (typ, env)
622
623
| _ -> None
623
624
624
- let rec completionsGetCompletionType2 ~debug ~full ~opens ~rawOpens ~allFiles
625
- ~ pos ~ scope = function
625
+ let rec completionsGetCompletionType2 ~debug ~full ~opens ~rawOpens ~pos ~ scope
626
+ = function
626
627
| {Completion. kind = Value typ; env} :: _
627
628
| {Completion. kind = ObjLabel typ; env} :: _
628
629
| {Completion. kind = Field ({typ} , _ ); env} :: _ ->
629
630
Some (TypeExpr typ, env)
630
631
| {Completion. kind = FollowContextPath ctxPath ; env} :: _ ->
631
632
ctxPath
632
633
|> getCompletionsForContextPath ~debug ~full ~env ~exact: true ~opens
633
- ~raw Opens ~all Files ~pos ~scope
634
- |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~all Files
635
- ~pos ~scope
634
+ ~raw Opens ~pos ~scope
635
+ |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~pos ~scope
636
636
| {Completion. kind = Type typ ; env} :: _ -> (
637
637
match TypeUtils. extractTypeFromResolvedType typ ~env ~full with
638
638
| None -> None
@@ -642,21 +642,20 @@ let rec completionsGetCompletionType2 ~debug ~full ~opens ~rawOpens ~allFiles
642
642
| _ -> None
643
643
644
644
and completionsGetTypeEnv2 ~debug (completions : Completion.t list ) ~full ~opens
645
- ~rawOpens ~allFiles ~ pos ~scope =
645
+ ~rawOpens ~pos ~scope =
646
646
match completions with
647
647
| {Completion. kind = Value typ ; env} :: _ -> Some (typ, env)
648
648
| {Completion. kind = ObjLabel typ ; env} :: _ -> Some (typ, env)
649
649
| {Completion. kind = Field ({typ} , _ ); env} :: _ -> Some (typ, env)
650
650
| {Completion. kind = FollowContextPath ctxPath ; env} :: _ ->
651
651
ctxPath
652
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files ~pos
653
- ~env ~exact: true ~scope
654
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
655
- ~scope
652
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
653
+ ~exact: true ~scope
654
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
656
655
| _ -> None
657
656
658
- and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~ pos
659
- ~env ~ exact ~ scope ?(mode = Regular ) contextPath =
657
+ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~ env ~ exact
658
+ ~scope ?(mode = Regular ) contextPath =
660
659
if debug then
661
660
Printf. printf " ContextPath %s\n "
662
661
(Completable. contextPathToString contextPath);
@@ -702,8 +701,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
702
701
| Regular -> (
703
702
match
704
703
cp
705
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
706
- ~pos ~env ~ exact:true ~scope
704
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
705
+ ~exact: true ~scope
707
706
|> completionsGetCompletionType ~full
708
707
with
709
708
| None -> []
@@ -725,8 +724,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
725
724
| CPOption cp -> (
726
725
match
727
726
cp
728
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
729
- ~pos ~env ~ exact:true ~scope
727
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
728
+ ~exact: true ~scope
730
729
|> completionsGetCompletionType ~full
731
730
with
732
731
| None -> []
@@ -738,15 +737,14 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
738
737
])
739
738
| CPId (path , completionContext ) ->
740
739
path
741
- |> getCompletionsForPath ~debug ~package ~opens ~all Files ~pos ~exact
740
+ |> getCompletionsForPath ~debug ~package ~opens ~full ~pos ~exact
742
741
~completion Context ~env ~scope
743
742
| CPApply (cp , labels ) -> (
744
743
match
745
744
cp
746
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
747
- ~pos ~env ~exact: true ~scope
748
- |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~all Files
749
- ~pos ~scope
745
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
746
+ ~exact: true ~scope
747
+ |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~pos ~scope
750
748
with
751
749
| Some ((TypeExpr typ | ExtractedType (Tfunction {typ} )), env ) -> (
752
750
let rec reconstructFunctionType args tRet =
@@ -785,19 +783,19 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
785
783
| CPField (CPId (path , Module), fieldName ) ->
786
784
(* M.field *)
787
785
path @ [fieldName]
788
- |> getCompletionsForPath ~debug ~package ~opens ~all Files ~pos ~exact
786
+ |> getCompletionsForPath ~debug ~package ~opens ~full ~pos ~exact
789
787
~completion Context:Field ~env ~scope
790
788
| CPField (cp , fieldName ) -> (
791
789
let completionsForCtxPath =
792
790
cp
793
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
794
- ~pos ~env ~ exact:true ~scope
791
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
792
+ ~exact: true ~scope
795
793
in
796
794
let extracted =
797
795
match
798
796
completionsForCtxPath
799
- |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~all Files
800
- ~pos ~ scope
797
+ |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~pos
798
+ ~scope
801
799
with
802
800
| Some (TypeExpr typ , env ) -> (
803
801
match typ |> TypeUtils. extractRecordType ~env ~package with
@@ -829,10 +827,9 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
829
827
(* TODO: Also needs to support ExtractedType *)
830
828
match
831
829
cp
832
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
833
- ~pos ~env ~exact: true ~scope
834
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
835
- ~scope
830
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
831
+ ~exact: true ~scope
832
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
836
833
with
837
834
| Some (typ , env ) -> (
838
835
match typ |> TypeUtils. extractObjectType ~env ~package with
@@ -857,10 +854,9 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
857
854
| CPPipe {contextPath = cp ; id = funNamePrefix ; lhsLoc; inJsx} -> (
858
855
match
859
856
cp
860
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
861
- ~pos ~env ~exact: true ~scope ~mode: Pipe
862
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
863
- ~scope
857
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
858
+ ~exact: true ~scope ~mode: Pipe
859
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
864
860
with
865
861
| None -> []
866
862
| Some (typ , envFromCompletionItem ) -> (
@@ -960,7 +956,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
960
956
let completions =
961
957
completionPath @ [funNamePrefix]
962
958
|> getCompletionsForPath ~debug ~completion Context:Value ~exact: false
963
- ~package ~opens ~all Files ~pos ~env ~scope
959
+ ~package ~opens ~full ~pos ~env ~scope
964
960
in
965
961
let completions =
966
962
completions
@@ -1007,8 +1003,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
1007
1003
ctxPaths
1008
1004
|> List. map (fun contextPath ->
1009
1005
contextPath
1010
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens
1011
- ~all Files ~pos ~ env ~exact: true ~scope )
1006
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos
1007
+ ~env ~exact: true ~scope )
1012
1008
|> List. filter_map (fun completionItems ->
1013
1009
match completionItems with
1014
1010
| {Completion. kind = Value typ } :: _ -> Some typ
@@ -1024,9 +1020,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
1024
1020
let findTypeOfValue path =
1025
1021
path
1026
1022
|> getCompletionsForPath ~debug ~completion Context:Value ~exact: true
1027
- ~package ~opens ~all Files ~pos ~env ~scope
1028
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
1029
- ~scope
1023
+ ~package ~opens ~full ~pos ~env ~scope
1024
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
1030
1025
in
1031
1026
let lowercaseComponent =
1032
1027
match pathToComponent with
@@ -1039,7 +1034,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
1039
1034
match
1040
1035
path
1041
1036
|> getCompletionsForPath ~debug ~completion Context:Type ~exact: true
1042
- ~package ~opens ~all Files ~pos ~env ~scope
1037
+ ~package ~opens ~full ~pos ~env ~scope
1043
1038
with
1044
1039
| {kind = Type {kind = Abstract (Some (p , _ ))} } :: _ ->
1045
1040
(* This case happens when what we're looking for is a type alias.
@@ -1070,10 +1065,10 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
1070
1065
let labels, env =
1071
1066
match
1072
1067
functionContextPath
1073
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1074
- ~pos ~env ~ exact:true ~scope
1075
- |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~all Files
1076
- ~pos ~ scope
1068
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1069
+ ~exact: true ~scope
1070
+ |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~pos
1071
+ ~scope
1077
1072
with
1078
1073
| Some ((TypeExpr typ | ExtractedType (Tfunction {typ} )), env ) ->
1079
1074
(typ |> TypeUtils. getArgs ~full ~env , env)
@@ -1108,10 +1103,9 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~allFiles ~pos
1108
1103
| CPatternPath {rootCtxPath; nested} -> (
1109
1104
match
1110
1105
rootCtxPath
1111
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1112
- ~pos ~env ~exact: true ~scope
1113
- |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~all Files
1114
- ~pos ~scope
1106
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1107
+ ~exact: true ~scope
1108
+ |> completionsGetCompletionType2 ~debug ~full ~opens ~raw Opens ~pos ~scope
1115
1109
with
1116
1110
| Some (typ , env ) -> (
1117
1111
match typ |> TypeUtils. resolveNestedPatternPath ~env ~full ~nested with
@@ -1416,20 +1410,19 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
1416
1410
let package = full.package in
1417
1411
let rawOpens = Scope. getRawOpens scope in
1418
1412
let opens = getOpens ~debug ~raw Opens ~package ~env in
1419
- let allFiles = FileSet. union package.projectFiles package.dependenciesFiles in
1413
+ let allFiles = allFilesInPackage package in
1420
1414
let findTypeOfValue path =
1421
1415
path
1422
1416
|> getCompletionsForPath ~debug ~completion Context:Value ~exact: true
1423
- ~package ~opens ~all Files ~pos ~env ~scope
1424
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
1425
- ~scope
1417
+ ~package ~opens ~full ~pos ~env ~scope
1418
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
1426
1419
in
1427
1420
match completable with
1428
1421
| Cnone -> []
1429
1422
| Cpath contextPath ->
1430
1423
contextPath
1431
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files ~pos
1432
- ~env ~ exact: forHover ~scope
1424
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1425
+ ~exact: forHover ~scope
1433
1426
| Cjsx ([id ], prefix , identsSeen ) when String. uncapitalize_ascii id = id ->
1434
1427
(* Lowercase JSX tag means builtin *)
1435
1428
let mkLabel (name , typString ) =
@@ -1486,10 +1479,9 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
1486
1479
let labels =
1487
1480
match
1488
1481
cp
1489
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1490
- ~pos ~env ~exact: true ~scope
1491
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
1492
- ~scope
1482
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1483
+ ~exact: true ~scope
1484
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
1493
1485
with
1494
1486
| Some (typ , _env ) ->
1495
1487
if debug then
@@ -1523,10 +1515,9 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
1523
1515
in
1524
1516
match
1525
1517
contextPath
1526
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1527
- ~pos ~env ~exact: true ~scope
1528
- |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~all Files ~pos
1529
- ~scope
1518
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1519
+ ~exact: true ~scope
1520
+ |> completionsGetTypeEnv2 ~debug ~full ~opens ~raw Opens ~pos ~scope
1530
1521
with
1531
1522
| Some (typ , env ) -> (
1532
1523
match
@@ -1557,8 +1548,8 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
1557
1548
in
1558
1549
match
1559
1550
contextPath
1560
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1561
- ~pos ~env ~ exact:true ~scope
1551
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1552
+ ~exact: true ~scope
1562
1553
|> completionsGetCompletionType ~full
1563
1554
with
1564
1555
| None -> regularCompletions
@@ -1637,8 +1628,8 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
1637
1628
in
1638
1629
let completionsForContextPath =
1639
1630
contextPath
1640
- |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~all Files
1641
- ~pos ~env ~ exact: forHover ~scope
1631
+ |> getCompletionsForContextPath ~debug ~full ~opens ~raw Opens ~pos ~env
1632
+ ~exact: forHover ~scope
1642
1633
in
1643
1634
completionsForContextPath
1644
1635
|> List. map (fun (c : Completion.t ) ->
0 commit comments