Skip to content

Commit

Permalink
Use new information from uids to jump to the correct file.
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Oct 15, 2024
1 parent fce235d commit 2c8423f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/analysis/locate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,15 @@ let find_loc_of_uid ~config ~local_defs uid comp_unit =
end
else begin
log ~title "Loading the cmt file for unit %S" comp_unit;
let ml_or_mli =
match uid with
| Item { from = Intf; _ } -> `MLI
| _ -> config.ml_or_mli
in
let config = { config with ml_or_mli } in
match load_cmt ~config comp_unit with
| Ok (_pos_fname, cmt) ->
log ~title "Shapes successfully loaded, looking for %a" Logger.fmt
log ~title "Cmt successfully loaded, looking for %a" Logger.fmt
(fun fmt -> Shape.Uid.print fmt uid);
begin
match Shape.Uid.Tbl.find_opt cmt.cmt_uid_to_decl uid with
Expand Down
8 changes: 4 additions & 4 deletions tests/test-dirs/locate/issue1848.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ Locate the Bar on line 4
> end
> EOF

The expected location is 2:7 of foo.ml, but it instead goes to 1:9, which is the
constructor Foo
FIXME Module type Bar in foo.mli is a correct answer, but since there is only
one corresponding implementation we could jump there instead.
$ $MERLIN single locate -position 4:28 -look-for ml \
> -filename test1.ml < test1.ml | jq .value
{
"file": "$TESTCASE_ROOT/foo.ml",
"file": "$TESTCASE_ROOT/foo.mli",
"pos": {
"line": 1,
"col": 9
"col": 7
}
}

Expand Down

0 comments on commit 2c8423f

Please sign in to comment.