@@ -557,28 +557,28 @@ let isCapitalized name =
557
557
558
558
type completion =
559
559
| AbsAttribute of string list
560
- | Attribute of string list * string list * string
560
+ | RecordAccess of string list * string list * string (* e.g. A.B.var .f1.f2 .f3 *)
561
561
| Normal of string list
562
562
563
563
let determineCompletion dotpath =
564
564
let rec loop dotpath =
565
565
match dotpath with
566
566
| [] -> assert false
567
567
| [one] -> Normal [one]
568
- | [one; two] when not (isCapitalized one) -> Attribute ([one], [] , two)
568
+ | [one; two] when not (isCapitalized one) -> RecordAccess ([one], [] , two)
569
569
| [one; two] -> Normal [one; two]
570
570
| one :: rest -> (
571
571
if isCapitalized one then
572
572
match loop rest with
573
573
| Normal path -> Normal (one :: path)
574
- | Attribute ( firstPath , rest , suffix ) ->
575
- Attribute (one :: firstPath, rest, suffix )
574
+ | RecordAccess ( valuePath , middleFields , lastField ) ->
575
+ RecordAccess (one :: valuePath, middleFields, lastField )
576
576
| AbsAttribute _ as x -> x
577
577
else
578
578
match loop rest with
579
579
| Normal path -> AbsAttribute path
580
- | Attribute ([first ], path , suffix ) ->
581
- Attribute ([one], first :: path, suffix )
580
+ | RecordAccess ([name ], middleFields , lastField ) ->
581
+ RecordAccess ([one], name :: middleFields, lastField )
582
582
| x -> x)
583
583
in
584
584
loop dotpath
@@ -615,16 +615,16 @@ let getEnvWithOpens ~pos ~(env : QueryEnv.t) ~package ~(opens : QueryEnv.t list)
615
615
in
616
616
loop opens
617
617
618
- type k =
618
+ type kind =
619
619
| Module of moduleKind
620
620
| Value of Types .type_expr
621
621
| Type of Type .t
622
622
| Constructor of constructor * Type .t declared
623
623
| Field of field * Type .t declared
624
624
| FileModule of string
625
625
626
- let kindToInt k =
627
- match k with
626
+ let kindToInt kind =
627
+ match kind with
628
628
| Module _ -> 9
629
629
| FileModule _ -> 9
630
630
| Constructor (_ , _ ) -> 4
@@ -822,11 +822,11 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
822
822
Log. log " Got the env" ;
823
823
valueCompletions ~env suffix
824
824
| None -> [] )
825
- | Attribute ( firstPath , rest , suffix ) -> (
826
- Log. log (" suffix :" ^ suffix );
825
+ | RecordAccess ( valuePath , middleFields , lastField ) -> (
826
+ Log. log (" lastField :" ^ lastField );
827
827
Log. log
828
- (" -------------- Looking for " ^ (firstPath |> SharedTypes. pathToString));
829
- match getEnvWithOpens ~pos ~env ~package ~opens firstPath with
828
+ (" -------------- Looking for " ^ (valuePath |> SharedTypes. pathToString));
829
+ match getEnvWithOpens ~pos ~env ~package ~opens valuePath with
830
830
| Some (env , name ) -> (
831
831
match ProcessCmt. findInScope pos name env.file.stamps.values with
832
832
| None -> []
@@ -836,7 +836,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
836
836
| None -> []
837
837
| Some (env , fields , typ ) -> (
838
838
match
839
- rest
839
+ middleFields
840
840
|> List. fold_left
841
841
(fun current name ->
842
842
match current with
@@ -854,12 +854,12 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
854
854
| None -> []
855
855
| Some (_env , fields , typ ) ->
856
856
fields
857
- |> Utils. filterMap (fun f ->
858
- if Utils. startsWith f .fname.txt suffix then
857
+ |> Utils. filterMap (fun field ->
858
+ if Utils. startsWith field .fname.txt lastField then
859
859
Some
860
860
{
861
- (emptyDeclared f .fname.txt) with
862
- item = Field (f , typ);
861
+ (emptyDeclared field .fname.txt) with
862
+ item = Field (field , typ);
863
863
}
864
864
else None ))))
865
865
| None -> [] )
0 commit comments