Skip to content

Commit 7a8c72a

Browse files
committed
rename
1 parent 7c3ebbd commit 7a8c72a

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

analysis/src/NewCompletions.ml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) =
754754
| _ -> None)
755755
| _ -> None
756756

757-
let getItems ~full ~rawOpens ~allFiles ~pos ~parts =
757+
let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
758758
Log.log
759759
("Opens folkz > "
760760
^ string_of_int (List.length rawOpens)
@@ -774,7 +774,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~parts =
774774
|> List.map (fun (e : QueryEnv.t) -> Uri2.toString e.file.uri)));
775775
(* Last open takes priority *)
776776
let opens = List.rev resolvedOpens in
777-
match parts with
777+
match dotpath with
778778
| [] -> []
779779
| [suffix] ->
780780
let locallyDefinedValues = localValueCompletions ~pos ~env suffix in
@@ -882,7 +882,7 @@ let mkItem ~name ~kind ~detail ~deprecated ~docstring =
882882
else Some {kind = "markdown"; value = docContent});
883883
}
884884

885-
let processCompletable ~findItems ~full ~package ~rawOpens
885+
let processCompletable ~processDotPath ~full ~package ~rawOpens
886886
(completable : PartialParser.completable) =
887887
match completable with
888888
| Cjsx ([id], prefix, identsSeen) when String.lowercase_ascii id = id ->
@@ -901,9 +901,9 @@ let processCompletable ~findItems ~full ~package ~rawOpens
901901
|> List.map mkLabel)
902902
@ keyLabels
903903
| Cjsx (componentPath, prefix, identsSeen) ->
904-
let items = findItems ~exact:true (componentPath @ ["make"]) in
904+
let declareds = processDotPath ~exact:true (componentPath @ ["make"]) in
905905
let labels =
906-
match items with
906+
match declareds with
907907
| {SharedTypes.item = Value typ} :: _ ->
908908
let rec getFields (texp : Types.type_expr) =
909909
match texp.desc with
@@ -959,10 +959,10 @@ let processCompletable ~findItems ~full ~package ~rawOpens
959959
Utils.startsWith name prefix && not (List.mem name identsSeen))
960960
|> List.map mkLabel)
961961
@ keyLabels
962-
| Cpath parts ->
963-
let items = parts |> findItems ~exact:false in
962+
| Cdotpath dotpath ->
963+
let declareds = dotpath |> processDotPath ~exact:false in
964964
(* TODO(#107): figure out why we're getting duplicates. *)
965-
items |> Utils.dedup
965+
declareds |> Utils.dedup
966966
|> List.map
967967
(fun {SharedTypes.name = {txt = name}; deprecated; docstring; item} ->
968968
mkItem ~name ~kind:(kindToInt item) ~deprecated
@@ -1023,7 +1023,7 @@ let processCompletable ~findItems ~full ~package ~rawOpens
10231023
in
10241024
match String.split_on_char '.' pipeId with
10251025
| x :: fieldNames -> (
1026-
match [x] |> findItems ~exact:true with
1026+
match [x] |> processDotPath ~exact:true with
10271027
| {SharedTypes.item = Value typ} :: _ -> (
10281028
let env = QueryEnv.fromFile full.file in
10291029
match getFields ~env ~typ fieldNames with
@@ -1073,9 +1073,9 @@ let processCompletable ~findItems ~full ~package ~rawOpens
10731073
if modulePathMinusOpens = "" then name
10741074
else modulePathMinusOpens ^ "." ^ name
10751075
in
1076-
let parts = modulePath @ [partialName] in
1077-
let items = parts |> findItems ~exact:false in
1078-
items
1076+
let dotpath = modulePath @ [partialName] in
1077+
let declareds = dotpath |> processDotPath ~exact:false in
1078+
declareds
10791079
|> List.filter (fun {item} ->
10801080
match item with Value _ -> true | _ -> false)
10811081
|> List.map
@@ -1131,7 +1131,7 @@ let processCompletable ~findItems ~full ~package ~rawOpens
11311131
|> List.map mkDecorator
11321132
| Clabel (funPath, prefix, identsSeen) ->
11331133
let labels =
1134-
match funPath |> findItems ~exact:true with
1134+
match funPath |> processDotPath ~exact:true with
11351135
| {SharedTypes.item = Value typ} :: _ ->
11361136
let rec getLabels (t : Types.type_expr) =
11371137
match t.desc with
@@ -1180,7 +1180,7 @@ let processCompletable ~findItems ~full ~package ~rawOpens
11801180
in
11811181
let env0 = QueryEnv.fromFile full.file in
11821182
let env, fields =
1183-
match [lhs] |> findItems ~exact:true with
1183+
match [lhs] |> processDotPath ~exact:true with
11841184
| {SharedTypes.item = Value typ} :: _ -> getObjectFields ~env:env0 typ
11851185
| _ -> (env0, [])
11861186
in
@@ -1211,11 +1211,11 @@ let getCompletable ~textOpt ~pos =
12111211
let computeCompletions ~completable ~full ~pos ~rawOpens =
12121212
let package = full.package in
12131213
let allFiles = FileSet.union package.projectFiles package.dependenciesFiles in
1214-
let findItems ~exact parts =
1215-
let items = getItems ~full ~rawOpens ~allFiles ~pos ~parts in
1216-
match parts |> List.rev with
1214+
let processDotPath ~exact dotpath =
1215+
let items = getItems ~full ~rawOpens ~allFiles ~pos ~dotpath in
1216+
match dotpath |> List.rev with
12171217
| last :: _ when exact ->
12181218
items |> List.filter (fun {SharedTypes.name = {txt}} -> txt = last)
12191219
| _ -> items
12201220
in
1221-
completable |> processCompletable ~findItems ~full ~package ~rawOpens
1221+
completable |> processCompletable ~processDotPath ~full ~package ~rawOpens

analysis/src/PartialParser.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ type completable =
187187
| Cdecorator of string (** e.g. @module *)
188188
| Clabel of string list * string * string list
189189
(** e.g. (["M", "foo"], "label", ["l1", "l2"]) for M.foo(...~l1...~l2...~label...) *)
190-
| Cpath of string list (** e.g. ["M", "foo"] for M.foo *)
190+
| Cdotpath of string list (** e.g. ["M", "foo"] for M.foo *)
191191
| Cjsx of string list * string * string list
192192
(** E.g. (["M", "Comp"], "id", ["id1", "id2"]) for <M.Comp id1=... id2=... ... id *)
193193
| Cobj of string * string list * string
@@ -208,15 +208,17 @@ let isLowercaseIdent id =
208208
let findCompletable text offset =
209209
let mkPath s =
210210
let len = String.length s in
211-
let parts = Str.split (Str.regexp_string ".") s in
212-
let parts = match s.[len - 1] with '.' -> parts @ [""] | _ -> parts in
213-
match parts with
211+
let dotpath = Str.split (Str.regexp_string ".") s in
212+
let dotpath =
213+
match s.[len - 1] with '.' -> dotpath @ [""] | _ -> dotpath
214+
in
215+
match dotpath with
214216
| [id] when String.lowercase_ascii id = id -> (
215217
match findJsxContext text (offset - len - 1) with
216-
| None -> Cpath parts
218+
| None -> Cdotpath dotpath
217219
| Some (componentName, identsSeen) ->
218220
Cjsx (Str.split (Str.regexp_string ".") componentName, id, identsSeen))
219-
| _ -> Cpath parts
221+
| _ -> Cdotpath dotpath
220222
in
221223
let mkPipe off partialName =
222224
let off = skipWhite text off in

0 commit comments

Comments
 (0)