Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/analysis/misc_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ let parse_identifier (config, source) pos =
let is_current_unit comp_unit =
match Env.get_unit_name () with
| Some current_unit ->
String.equal (Compilation_unit.name_as_string current_unit) comp_unit
String.equal (current_unit |> Unit_info.modname |>
Compilation_unit.name_as_string) comp_unit
| None -> false
10 changes: 7 additions & 3 deletions src/kernel/mocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ let setup_reader_config config =
let open Mconfig in
let open Clflags in
let ocaml = config.ocaml in
let to_compilation_unit name = Some (Compilation_unit.of_string name) in
Env.set_unit_name (Mconfig.unitname config |> to_compilation_unit);
let to_unit_info name =
Some (name |>
Compilation_unit.of_string |>
Unit_info.make_dummy ~input_name:name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't break anything, but using make_dummy scares me a bit. It seems like the type of thing that may cause something to break down the line. If we want to call Unit_info.make_with_known_compilation_unit, we can use config.query.filename to fill source_file.

I'm not sure about intf_or_impl - I don't know if Merlin knows that at this point (I'm not sure if Merlin decides this based on solely the filename or whether it's able to parse successfully). And I don't know that the file_prefix argument is for.

Maybe @lukemaurer can chime in on the significance of using make_dummy here, and what the deal is with file_prefix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I wanted @lukemaurer to review this piece. It was very low confidence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if there's a real source file then we don't want to be using make_dummy if we can avoid it. make_with_known_compilation_unit makes a lot of sense to me. The intf_or_impl thing is annoying - wish I could remember exactly what it's used for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to have lost my permissions to push to this repo. @lukemaurer can you look at the below commit: liam923/merlin@4123c5a

Specifically, I'm not sure what to pass for the file_prefix to Unit_info.make_with_known_compilation_unit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha I've gotten my permissions back. Commit 4123c5a is pushed here now.

in
Env.set_unit_name (Mconfig.unitname config |> to_unit_info);
Location.input_name := config.query.filename;
fast := ocaml.unsafe;
classic := ocaml.classic;
Expand All @@ -54,7 +58,7 @@ let setup_reader_config config =

let init_params params =
List.iter params ~f:(fun s ->
Env.register_parameter (s |> Global_module.Name.create_no_args))
Env.register_parameter (s |> Global_module.Parameter_name.of_string))

let setup_typer_config config =
setup_reader_config config;
Expand Down