File tree Expand file tree Collapse file tree 3 files changed +20
-14
lines changed Expand file tree Collapse file tree 3 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,16 @@ let load_cmt ~config comp_unit ml_or_mli =
310310 Ok (source_file, cmt_infos)
311311 | None -> Error ()
312312
313+ let find_declaration_uid ~env ~decl_uid path =
314+ let rec non_alias_declaration_uid path =
315+ let md = Env. find_module path env in
316+ match md.md_type with
317+ | Mty_ident _ | Mty_signature _ | Mty_functor _ | Mty_for_hole -> md.md_uid
318+ | Mty_alias path -> non_alias_declaration_uid path
319+ in
320+ try non_alias_declaration_uid path
321+ with Not_found -> decl_uid
322+
313323let uid_of_path ~config ~env ~ml_or_mli ~decl_uid path ns =
314324 let module Shape_reduce =
315325 Shape. Make_reduce (struct
@@ -333,7 +343,7 @@ let uid_of_path ~config ~env ~ml_or_mli ~decl_uid path ns =
333343 end )
334344 in
335345 match ml_or_mli with
336- | `MLI -> Some decl_uid
346+ | `MLI -> Some (find_declaration_uid ~ decl_uid ~env path)
337347 | `ML ->
338348 let shape = Env. shape_of_path ~namespace: ns env path in
339349 log ~title: " shape_of_path" " initial: %a"
Original file line number Diff line number Diff line change @@ -65,12 +65,11 @@ Jump to an aliased module `A|.f`:
6565 }
6666
6767Jump to the declaration of an aliased module `A|. f `.
68- With the new shape implementation it is expected that we jump to the
69- declaration of the alias and not to the aliased module itself .
68+ The alias is traversed.
7069 $ $ MERLIN single locate -look-for mli -position 5 : 2 \
7170 > -filename . /main. ml < . /main. ml | jq ' .value'
7271 {
73- " file" : " $ TESTCASE_ROOT /main.ml " ,
72+ " file" : " $ TESTCASE_ROOT /anothermod.mli " ,
7473 " pos" : {
7574 " line" : 1 ,
7675 " col" : 0
@@ -168,12 +167,11 @@ Jump to an aliased module `A|.f`:
168167 }
169168
170169Jump to the declaration of an aliased module `A|. f `:
171- With the new shape implementation it is expected that we jump to the
172- declaration of the alias and not to the aliased module itself .
170+ The alias is traversed.
173171 $ $ MERLIN single locate -look-for mli -position 5 : 2 \
174172 > -filename . /main. ml < . /main. ml | jq ' .value'
175173 {
176- " file" : " $ TESTCASE_ROOT /main.ml " ,
174+ " file" : " $ TESTCASE_ROOT /anothermod.mli " ,
177175 " pos" : {
178176 " line" : 1 ,
179177 " col" : 0
Original file line number Diff line number Diff line change 2929 }
3030 }
3131
32- FIXME: it would be more useful to traverse the alias and jump to 2 : 2
3332 $ $ MERLIN single locate -look-for mli -position 11 : 10 \
3433 > -filename . /main. ml < . /main. ml | jq ' .value'
3534 {
3635 " file" : " $ TESTCASE_ROOT /main.ml" ,
3736 " pos" : {
38- " line" : 10 ,
39- " col" : 0
37+ " line" : 2 ,
38+ " col" : 2
4039 }
4140 }
4241 $ $ MERLIN single locate -look-for ml -position 2 : 10 \
@@ -49,13 +48,12 @@ FIXME: it would be more useful to traverse the alias and jump to 2:2
4948 }
5049 }
5150
52- FIXME: it would be more useful to traverse the alias and jump to main 2 : 2
5351 $ $ MERLIN single locate -look-for mli -position 2 : 10 \
5452 > -filename . /other. ml < . /other. ml | jq ' .value'
5553 {
56- " file" : " $ TESTCASE_ROOT /other .ml" ,
54+ " file" : " $ TESTCASE_ROOT /main .ml" ,
5755 " pos" : {
58- " line" : 1 ,
59- " col" : 0
56+ " line" : 2 ,
57+ " col" : 2
6058 }
6159 }
You can’t perform that action at this time.
0 commit comments