Skip to content

Commit b77973b

Browse files
committed
always use new stdlib modules for autocomplete
1 parent f41f781 commit b77973b

13 files changed

+799
-483
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10901090
*)
10911091
let completeAsBuiltin =
10921092
match typePath with
1093-
| Some t ->
1094-
TypeUtils.completionPathFromMaybeBuiltin t ~package:full.package
1093+
| Some t -> TypeUtils.completionPathFromMaybeBuiltin t
10951094
| None -> None
10961095
in
10971096
let completionPath =
@@ -1801,8 +1800,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
18011800
if Debug.verbose () then print_endline "[complete_typed_value]--> Texn";
18021801
[
18031802
create
1804-
(full.package.builtInCompletionModules.exnModulePath @ ["Error(error)"]
1805-
|> ident)
1803+
(["Exn.t"; "Error(error)"] |> ident)
18061804
~kind:(Label "Catches errors from JavaScript errors.")
18071805
~docstring:
18081806
[

analysis/src/Packages.ml

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -148,61 +148,6 @@ let newBsPackage ~rootPath =
148148
pathsForModule;
149149
opens;
150150
namespace;
151-
builtInCompletionModules =
152-
(if
153-
opens_from_bsc_flags
154-
|> List.find_opt (fun opn ->
155-
match opn with
156-
| ["RescriptCore"] -> true
157-
| _ -> false)
158-
|> Option.is_some
159-
|| fst rescriptVersion >= 12
160-
then
161-
{
162-
arrayModulePath = ["Array"];
163-
optionModulePath = ["Option"];
164-
stringModulePath = ["String"];
165-
intModulePath = ["Int"];
166-
floatModulePath = ["Float"];
167-
promiseModulePath = ["Promise"];
168-
listModulePath = ["List"];
169-
resultModulePath = ["Result"];
170-
exnModulePath = ["Exn"];
171-
regexpModulePath = ["RegExp"];
172-
}
173-
else if
174-
opens_from_bsc_flags
175-
|> List.find_opt (fun opn ->
176-
match opn with
177-
| ["Belt"] -> true
178-
| _ -> false)
179-
|> Option.is_some
180-
then
181-
{
182-
arrayModulePath = ["Array"];
183-
optionModulePath = ["Option"];
184-
stringModulePath = ["Js"; "String2"];
185-
intModulePath = ["Int"];
186-
floatModulePath = ["Float"];
187-
promiseModulePath = ["Js"; "Promise"];
188-
listModulePath = ["List"];
189-
resultModulePath = ["Result"];
190-
exnModulePath = ["Js"; "Exn"];
191-
regexpModulePath = ["Js"; "Re"];
192-
}
193-
else
194-
{
195-
arrayModulePath = ["Js"; "Array2"];
196-
optionModulePath = ["Belt"; "Option"];
197-
stringModulePath = ["Js"; "String2"];
198-
intModulePath = ["Belt"; "Int"];
199-
floatModulePath = ["Belt"; "Float"];
200-
promiseModulePath = ["Js"; "Promise"];
201-
listModulePath = ["Belt"; "List"];
202-
resultModulePath = ["Belt"; "Result"];
203-
exnModulePath = ["Js"; "Exn"];
204-
regexpModulePath = ["Js"; "Re"];
205-
});
206151
uncurried;
207152
}))
208153
| None -> None

analysis/src/SharedTypes.ml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -483,19 +483,6 @@ type file = string
483483

484484
module FileSet = Set.Make (String)
485485

486-
type builtInCompletionModules = {
487-
arrayModulePath: string list;
488-
optionModulePath: string list;
489-
stringModulePath: string list;
490-
intModulePath: string list;
491-
floatModulePath: string list;
492-
promiseModulePath: string list;
493-
listModulePath: string list;
494-
resultModulePath: string list;
495-
exnModulePath: string list;
496-
regexpModulePath: string list;
497-
}
498-
499486
type package = {
500487
genericJsxModule: string option;
501488
suffix: string;
@@ -504,7 +491,6 @@ type package = {
504491
dependenciesFiles: FileSet.t;
505492
pathsForModule: (file, paths) Hashtbl.t;
506493
namespace: string option;
507-
builtInCompletionModules: builtInCompletionModules;
508494
opens: path list;
509495
uncurried: bool;
510496
rescriptVersion: int * int;

analysis/src/TypeUtils.ml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,17 +1253,16 @@ let pathToBuiltin path =
12531253
Predef.builtin_idents
12541254
|> List.find_opt (fun (_, i) -> Ident.same i (Path.head path))
12551255

1256-
let completionPathFromMaybeBuiltin path ~package =
1256+
let completionPathFromMaybeBuiltin path =
12571257
match pathToBuiltin path with
1258-
| Some ("array", _) -> Some package.builtInCompletionModules.arrayModulePath
1259-
| Some ("option", _) -> Some package.builtInCompletionModules.optionModulePath
1260-
| Some ("string", _) -> Some package.builtInCompletionModules.stringModulePath
1261-
| Some ("int", _) -> Some package.builtInCompletionModules.intModulePath
1262-
| Some ("float", _) -> Some package.builtInCompletionModules.floatModulePath
1263-
| Some ("promise", _) ->
1264-
Some package.builtInCompletionModules.promiseModulePath
1265-
| Some ("list", _) -> Some package.builtInCompletionModules.listModulePath
1266-
| Some ("result", _) -> Some package.builtInCompletionModules.resultModulePath
1258+
| Some ("array", _) -> Some ["Array"]
1259+
| Some ("option", _) -> Some ["Option"]
1260+
| Some ("string", _) -> Some ["String"]
1261+
| Some ("int", _) -> Some ["Int"]
1262+
| Some ("float", _) -> Some ["Float"]
1263+
| Some ("promise", _) -> Some ["Promise"]
1264+
| Some ("list", _) -> Some ["List"]
1265+
| Some ("result", _) -> Some ["Result"]
12671266
| Some ("dict", _) -> Some ["Dict"]
12681267
| Some ("char", _) -> Some ["Char"]
12691268
| _ -> None

tests/analysis_tests/tests/src/Completion.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ let _ = x =>
389389
// ^com
390390

391391
let _ = _ => {
392-
open Js
393392
// []->ma
394393
// ^com
395394
()

0 commit comments

Comments
 (0)