Skip to content

Commit 5628b6f

Browse files
committed
cleanup
1 parent 072a943 commit 5628b6f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

analysis/src/NewCompletions.ml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -557,28 +557,28 @@ let isCapitalized name =
557557

558558
type completion =
559559
| 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 *)
561561
| Normal of string list
562562

563563
let determineCompletion dotpath =
564564
let rec loop dotpath =
565565
match dotpath with
566566
| [] -> assert false
567567
| [one] -> Normal [one]
568-
| [one; two] when not (isCapitalized one) -> Attribute ([one], [], two)
568+
| [one; two] when not (isCapitalized one) -> RecordAccess ([one], [], two)
569569
| [one; two] -> Normal [one; two]
570570
| one :: rest -> (
571571
if isCapitalized one then
572572
match loop rest with
573573
| 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)
576576
| AbsAttribute _ as x -> x
577577
else
578578
match loop rest with
579579
| 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)
582582
| x -> x)
583583
in
584584
loop dotpath
@@ -615,16 +615,16 @@ let getEnvWithOpens ~pos ~(env : QueryEnv.t) ~package ~(opens : QueryEnv.t list)
615615
in
616616
loop opens
617617

618-
type k =
618+
type kind =
619619
| Module of moduleKind
620620
| Value of Types.type_expr
621621
| Type of Type.t
622622
| Constructor of constructor * Type.t declared
623623
| Field of field * Type.t declared
624624
| FileModule of string
625625

626-
let kindToInt k =
627-
match k with
626+
let kindToInt kind =
627+
match kind with
628628
| Module _ -> 9
629629
| FileModule _ -> 9
630630
| Constructor (_, _) -> 4
@@ -822,11 +822,11 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
822822
Log.log "Got the env";
823823
valueCompletions ~env suffix
824824
| None -> [])
825-
| Attribute (firstPath, rest, suffix) -> (
826-
Log.log ("suffix :" ^ suffix);
825+
| RecordAccess (valuePath, middleFields, lastField) -> (
826+
Log.log ("lastField :" ^ lastField);
827827
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
830830
| Some (env, name) -> (
831831
match ProcessCmt.findInScope pos name env.file.stamps.values with
832832
| None -> []
@@ -836,7 +836,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
836836
| None -> []
837837
| Some (env, fields, typ) -> (
838838
match
839-
rest
839+
middleFields
840840
|> List.fold_left
841841
(fun current name ->
842842
match current with
@@ -854,12 +854,12 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
854854
| None -> []
855855
| Some (_env, fields, typ) ->
856856
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
859859
Some
860860
{
861-
(emptyDeclared f.fname.txt) with
862-
item = Field (f, typ);
861+
(emptyDeclared field.fname.txt) with
862+
item = Field (field, typ);
863863
}
864864
else None))))
865865
| None -> [])

0 commit comments

Comments
 (0)