@@ -496,23 +496,6 @@ let resolveOpens ~env ~previous opens ~package =
496
496
(* loop(previous) *)
497
497
previous opens
498
498
499
- type kind =
500
- | Module of moduleKind
501
- | Value of Types .type_expr
502
- | Type of Type .t
503
- | Constructor of constructor * Type .t declared
504
- | Field of field * Type .t declared
505
- | FileModule of string
506
-
507
- let kindToInt kind =
508
- match kind with
509
- | Module _ -> 9
510
- | FileModule _ -> 9
511
- | Constructor (_ , _ ) -> 4
512
- | Field (_ , _ ) -> 5
513
- | Type _ -> 22
514
- | Value _ -> 12
515
-
516
499
let completionForDeclareds ~pos declareds prefix transformContents =
517
500
(* Log.log("completion for declares " ++ prefix); *)
518
501
Hashtbl. fold
@@ -528,15 +511,15 @@ let completionForDeclareds ~pos declareds prefix transformContents =
528
511
529
512
let completionForDeclaredModules ~pos ~env ~suffix =
530
513
completionForDeclareds ~pos env.QueryEnv. file.stamps.modules suffix (fun m ->
531
- Module m)
514
+ Kind. Module m)
532
515
533
516
let completionForDeclaredValues ~pos ~env ~suffix =
534
517
completionForDeclareds ~pos env.QueryEnv. file.stamps.values suffix (fun m ->
535
- Value m)
518
+ Kind. Value m)
536
519
537
520
let completionForDeclaredTypes ~pos ~env ~suffix =
538
521
completionForDeclareds ~pos env.QueryEnv. file.stamps.types suffix (fun m ->
539
- Type m)
522
+ Kind. Type m)
540
523
541
524
let completionForExporteds exporteds
542
525
(stamps : (int, 'a SharedTypes.declared) Hashtbl.t ) prefix transformContents
@@ -552,15 +535,15 @@ let completionForExporteds exporteds
552
535
553
536
let completionForExportedModules ~env ~suffix =
554
537
completionForExporteds env.QueryEnv. exported.modules env.file.stamps.modules
555
- suffix (fun m -> Module m)
538
+ suffix (fun m -> Kind. Module m)
556
539
557
540
let completionForExportedValues ~env ~suffix =
558
541
completionForExporteds env.QueryEnv. exported.values env.file.stamps.values
559
- suffix (fun v -> Value v)
542
+ suffix (fun v -> Kind. Value v)
560
543
561
544
let completionForExportedTypes ~env ~suffix =
562
545
completionForExporteds env.QueryEnv. exported.types env.file.stamps.types
563
- suffix (fun t -> Type t)
546
+ suffix (fun t -> Kind. Type t)
564
547
565
548
let completionForConstructors ~(env : QueryEnv.t ) ~suffix =
566
549
Hashtbl. fold
@@ -575,7 +558,7 @@ let completionForConstructors ~(env : QueryEnv.t) ~suffix =
575
558
| _ -> results)
576
559
env.exported.types []
577
560
|> List. map (fun (c , t ) ->
578
- {(emptyDeclared c.cname.txt) with item = Constructor (c, t)})
561
+ {(emptyDeclared c.cname.txt) with item = Kind. Constructor (c, t)})
579
562
580
563
let completionForFields ~(env : QueryEnv.t ) ~suffix =
581
564
Hashtbl. fold
@@ -590,7 +573,7 @@ let completionForFields ~(env : QueryEnv.t) ~suffix =
590
573
| _ -> results)
591
574
env.exported.types []
592
575
|> List. map (fun (f , t ) ->
593
- {(emptyDeclared f.fname.txt) with item = Field (f, t)})
576
+ {(emptyDeclared f.fname.txt) with item = Kind. Field (f, t)})
594
577
595
578
let isCapitalized name =
596
579
if name = " " then false
@@ -669,8 +652,8 @@ let getEnvWithOpens ~pos ~(env : QueryEnv.t) ~package ~(opens : QueryEnv.t list)
669
652
in
670
653
loop opens
671
654
672
- let detail name contents =
673
- match contents with
655
+ let detail name ( kind : Kind.t ) =
656
+ match kind with
674
657
| Type {decl} -> decl |> Shared. declToString name
675
658
| Value typ -> typ |> Shared. typeToString
676
659
| Module _ -> " module"
@@ -827,7 +810,9 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
827
810
allFiles |> FileSet. elements
828
811
|> Utils. filterMap (fun name ->
829
812
if Utils. startsWith name suffix && not (String. contains name '-' )
830
- then Some ({(emptyDeclared name) with item = FileModule name}, env)
813
+ then
814
+ Some
815
+ ({(emptyDeclared name) with item = Kind. FileModule name}, env)
831
816
else None )
832
817
in
833
818
locallyDefinedValues @ valuesFromOpens @ localModuleNames
@@ -878,7 +863,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
878
863
Some
879
864
( {
880
865
(emptyDeclared field.fname.txt) with
881
- item = Field (field, typ);
866
+ item = Kind. Field (field, typ);
882
867
},
883
868
env )
884
869
else None ))))
@@ -933,7 +918,7 @@ let processCompletable ~processDotPath ~full ~package ~rawOpens
933
918
let declareds = processDotPath ~exact: true (componentPath @ [" make" ]) in
934
919
let labels =
935
920
match declareds with
936
- | ({SharedTypes. item = Value typ } , _env ) :: _ ->
921
+ | ({SharedTypes. item = Kind. Value typ } , _env ) :: _ ->
937
922
let rec getFields (texp : Types.type_expr ) =
938
923
match texp.desc with
939
924
| Tfield (name , _ , t1 , t2 ) ->
@@ -996,7 +981,7 @@ let processCompletable ~processDotPath ~full ~package ~rawOpens
996
981
(fun
997
982
({SharedTypes. name = {txt = name } ; deprecated; docstring; item} , _env )
998
983
->
999
- mkItem ~name ~kind: (kindToInt item) ~deprecated
984
+ mkItem ~name ~kind: (Kind. toInt item) ~deprecated
1000
985
~detail: (detail name item) ~docstring )
1001
986
| Cpipe (pipe , partialName ) -> (
1002
987
let arrayModulePath = [" Js" ; " Array2" ] in
@@ -1107,13 +1092,13 @@ let processCompletable ~processDotPath ~full ~package ~rawOpens
1107
1092
let declareds = dotpath |> processDotPath ~exact: false in
1108
1093
declareds
1109
1094
|> List. filter (fun ({item} , _env ) ->
1110
- match item with Value _ -> true | _ -> false )
1095
+ match item with Kind. Value _ -> true | _ -> false )
1111
1096
|> List. map
1112
1097
(fun
1113
1098
( {SharedTypes. name = {txt = name } ; deprecated; docstring; item} ,
1114
1099
_env )
1115
1100
->
1116
- mkItem ~name: (completionName name) ~kind: (kindToInt item)
1101
+ mkItem ~name: (completionName name) ~kind: (Kind. toInt item)
1117
1102
~detail: (detail name item) ~deprecated ~docstring )
1118
1103
| _ -> [] )
1119
1104
| None -> [] )
0 commit comments