@@ -555,25 +555,30 @@ let isCapitalized name =
555
555
let c = name.[0 ] in
556
556
match c with 'A' .. 'Z' -> true | _ -> false
557
557
558
- let determineCompletion parts =
559
- let rec loop parts =
560
- match parts with
558
+ type completion =
559
+ | AbsAttribute of path
560
+ | Attribute of string list * string
561
+ | Normal of path
562
+
563
+ let determineCompletion dotpath =
564
+ let rec loop dotpath =
565
+ match dotpath with
561
566
| [] -> assert false
562
- | [one] -> ` Normal (Tip one)
563
- | [one; two] when not (isCapitalized one) -> ` Attribute ([one], two)
564
- | [one; two] -> ` Normal (Nested (one, Tip two))
567
+ | [one] -> Normal (Tip one)
568
+ | [one; two] when not (isCapitalized one) -> Attribute ([one], two)
569
+ | [one; two] -> Normal (Nested (one, Tip two))
565
570
| one :: rest -> (
566
571
if isCapitalized one then
567
572
match loop rest with
568
- | ` Normal path -> ` Normal (Nested (one, path))
573
+ | Normal path -> Normal (Nested (one, path))
569
574
| x -> x
570
575
else
571
576
match loop rest with
572
- | ` Normal path -> ` AbsAttribute path
573
- | ` Attribute (path , suffix ) -> ` Attribute (one :: path, suffix)
577
+ | Normal path -> AbsAttribute path
578
+ | Attribute (path , suffix ) -> Attribute (one :: path, suffix)
574
579
| x -> x)
575
580
in
576
- loop parts
581
+ loop dotpath
577
582
578
583
(* Note: This is a hack. It will be wrong some times if you have a local thing
579
584
that overrides an open.
@@ -804,17 +809,17 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
804
809
else None )
805
810
in
806
811
locallyDefinedValues @ valuesFromOpens @ localModuleNames
807
- | multiple -> (
808
- Log. log (" Completing for " ^ String. concat " <.>" multiple );
809
- match determineCompletion multiple with
810
- | ` Normal path -> (
812
+ | _ -> (
813
+ Log. log (" Completing for " ^ String. concat " <.>" dotpath );
814
+ match determineCompletion dotpath with
815
+ | Normal path -> (
811
816
Log. log (" normal " ^ pathToString path);
812
817
match getEnvWithOpens ~pos ~env ~package ~opens path with
813
818
| Some (env , suffix ) ->
814
819
Log. log " Got the env" ;
815
820
valueCompletions ~env suffix
816
821
| None -> [] )
817
- | ` Attribute (target , suffix ) -> (
822
+ | Attribute (target , suffix ) -> (
818
823
Log. log (" suffix :" ^ suffix);
819
824
match target with
820
825
| [] -> []
@@ -854,7 +859,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
854
859
item = Field (f, typ);
855
860
}
856
861
else None )))))
857
- | ` AbsAttribute path -> (
862
+ | AbsAttribute path -> (
858
863
match getEnvWithOpens ~pos ~env ~package ~opens path with
859
864
| None -> []
860
865
| Some (env , suffix ) ->
@@ -1212,10 +1217,10 @@ let computeCompletions ~completable ~full ~pos ~rawOpens =
1212
1217
let package = full.package in
1213
1218
let allFiles = FileSet. union package.projectFiles package.dependenciesFiles in
1214
1219
let processDotPath ~exact dotpath =
1215
- let items = getItems ~full ~raw Opens ~all Files ~pos ~dotpath in
1220
+ let declareds = getItems ~full ~raw Opens ~all Files ~pos ~dotpath in
1216
1221
match dotpath |> List. rev with
1217
1222
| last :: _ when exact ->
1218
- items |> List. filter (fun {SharedTypes. name = {txt} } -> txt = last)
1219
- | _ -> items
1223
+ declareds |> List. filter (fun {SharedTypes. name = {txt} } -> txt = last)
1224
+ | _ -> declareds
1220
1225
in
1221
1226
completable |> processCompletable ~process DotPath ~full ~package ~raw Opens
0 commit comments