Skip to content

Proposal: allow opening files from the current project globally #6483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jscomp/core/js_implementation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let after_parsing_sig ppf outputprefix ast =
else
let modulename = module_of_filename outputprefix in
Lam_compile_env.reset ();
let initial_env = Res_compmisc.initial_env () in
let initial_env = Res_compmisc.initial_env ~modulename () in
Env.set_unit_name modulename;
let tsg = Typemod.transl_signature initial_env ast in
if !Clflags.dump_typedtree then
Expand Down Expand Up @@ -149,7 +149,7 @@ let after_parsing_impl ppf outputprefix (ast : Parsetree.structure) =
else
let modulename = Ext_filename.module_name outputprefix in
Lam_compile_env.reset ();
let env = Res_compmisc.initial_env () in
let env = Res_compmisc.initial_env ~modulename () in
Env.set_unit_name modulename;
let typedtree, coercion, _, _ =
Typemod.type_implementation_more
Expand Down
9 changes: 7 additions & 2 deletions jscomp/core/res_compmisc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ let open_implicit_module m env =
in
snd (Typemod.type_open_ Override env lid.loc lid)

let initial_env () =
let initial_env ?(modulename) () =
Ident.reinit ();
let open_modules = (match modulename with
| None -> !Clflags.open_modules
| Some modulename ->
!Clflags.open_modules |> List.filter(fun m -> m <> modulename)
) in
let initial = Env.initial_safe_string in
let env =
if !Clflags.nopervasives then initial
Expand All @@ -51,4 +56,4 @@ let initial_env () =
List.fold_left
(fun env m -> open_implicit_module m env)
env
(List.rev !Clflags.open_modules)
(List.rev open_modules)
2 changes: 1 addition & 1 deletion jscomp/core/res_compmisc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

val init_path : unit -> unit

val initial_env : unit -> Env.t
val initial_env : ?modulename : string -> unit -> Env.t