Skip to content

Commit ef22038

Browse files
committed
Complete treatment of QualifiedRecordAccess.
1 parent 84da2b9 commit ef22038

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

analysis/src/NewCompletions.ml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,10 @@ let isCapitalized name =
556556
match c with 'A' .. 'Z' -> true | _ -> false
557557

558558
type completion =
559-
| AbsAttribute of string list (* e.g. _somepath_.A.B.field *)
559+
| QualifiedRecordAccess of string list (* e.g. _.A.B.field where _ indicates a path ending in a lowercase id *)
560560
| RecordAccess of string list * string list * string (* e.g. A.B.var .f1.f2 .f3 *)
561-
| Path of string list (* e.g. A.B.var or A.B *)
561+
| Path of string list
562+
(* e.g. A.B.var or A.B *)
562563

563564
let determineCompletion dotpath =
564565
let rec loop dotpath =
@@ -574,13 +575,22 @@ let determineCompletion dotpath =
574575
| Path path -> Path (one :: path)
575576
| RecordAccess (valuePath, middleFields, lastField) ->
576577
RecordAccess (one :: valuePath, middleFields, lastField)
577-
| AbsAttribute _ as x -> x
578+
| QualifiedRecordAccess _ as completion ->
579+
(* A. _.B.field -> _.B.field *)
580+
completion
578581
else
579582
match loop rest with
580-
| Path path -> AbsAttribute path
583+
| Path path ->
584+
(* x. B.field -> _.B.field *)
585+
QualifiedRecordAccess path
581586
| RecordAccess ([name], middleFields, lastField) ->
582587
RecordAccess ([one], name :: middleFields, lastField)
583-
| x -> x)
588+
| RecordAccess (valuePath, middleFields, lastField) ->
589+
(* x.A.B.v.f1.f2.f3 --> .A.B.v.f1.f2.f3 *)
590+
QualifiedRecordAccess (valuePath @ middleFields @ [lastField])
591+
| QualifiedRecordAccess _ as completion ->
592+
(* x. _.A.f -> _.A.f *)
593+
completion)
584594
in
585595
loop dotpath
586596

@@ -864,7 +874,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
864874
}
865875
else None))))
866876
| None -> [])
867-
| AbsAttribute path -> (
877+
| QualifiedRecordAccess path -> (
868878
match getEnvWithOpens ~pos ~env ~package ~opens path with
869879
| None -> []
870880
| Some (env, suffix) ->

0 commit comments

Comments
 (0)