Skip to content

Commit 84da2b9

Browse files
committed
More cleanup.
1 parent 5628b6f commit 84da2b9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

analysis/src/NewCompletions.ml

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

558558
type completion =
559-
| AbsAttribute of string list
559+
| AbsAttribute of string list (* e.g. _somepath_.A.B.field *)
560560
| RecordAccess of string list * string list * string (* e.g. A.B.var .f1.f2 .f3 *)
561-
| Normal of string list
561+
| Path of string list (* e.g. A.B.var or A.B *)
562562

563563
let determineCompletion dotpath =
564564
let rec loop dotpath =
565565
match dotpath with
566566
| [] -> assert false
567-
| [one] -> Normal [one]
568-
| [one; two] when not (isCapitalized one) -> RecordAccess ([one], [], two)
569-
| [one; two] -> Normal [one; two]
567+
| [one] -> Path [one]
568+
| [one; two] ->
569+
if isCapitalized one then Path [one; two]
570+
else RecordAccess ([one], [], two)
570571
| one :: rest -> (
571572
if isCapitalized one then
572573
match loop rest with
573-
| Normal path -> Normal (one :: path)
574+
| Path path -> Path (one :: path)
574575
| RecordAccess (valuePath, middleFields, lastField) ->
575576
RecordAccess (one :: valuePath, middleFields, lastField)
576577
| AbsAttribute _ as x -> x
577578
else
578579
match loop rest with
579-
| Normal path -> AbsAttribute path
580+
| Path path -> AbsAttribute path
580581
| RecordAccess ([name], middleFields, lastField) ->
581582
RecordAccess ([one], name :: middleFields, lastField)
582583
| x -> x)
@@ -815,8 +816,8 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
815816
| _ -> (
816817
Log.log ("Completing for " ^ String.concat "<.>" dotpath);
817818
match determineCompletion dotpath with
818-
| Normal path -> (
819-
Log.log ("normal " ^ pathToString path);
819+
| Path path -> (
820+
Log.log ("Path " ^ pathToString path);
820821
match getEnvWithOpens ~pos ~env ~package ~opens path with
821822
| Some (env, suffix) ->
822823
Log.log "Got the env";

0 commit comments

Comments
 (0)