merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Improvement: jumping to a label's precise declaration.

Open voodoos opened this issue 3 years ago • 3 comments

When querying jump to declaration of a record's label foo.ba|r merlin would only jump to the beginning of the corresponding record type declaration.

This is due to the uid's of labels not being registered by the compiler in the Env.uid_to_loc table.

This PR adds these uid registration to typedecl.ml. This means that the fix will only work for the current buffer and we would need to be upstreamed for it to work when jumping to external compilation units.

cc @rgrinberg

voodoos avatar Jul 28 '22 08:07 voodoos

While making a test for "locating a label in another CU" I noticed that it was even more broken: after finding the Uid fails it should "fallback to the declaration's node's location" and it was not the case. This is fixed in the second commit.

voodoos avatar Jul 28 '22 09:07 voodoos

Looks good to me.

I guess the same problem exists for variant constructors?

rgrinberg avatar Jul 28 '22 15:07 rgrinberg

I guess the same problem exists for variant constructors?

I added a test and it worked as expected for constructors. However it relied on the "fallback" so I did the same change as for labels.

However I tested the polymorphic variants' tags and Merlin doesn't even try to locate these. But this will probably be the subject of another PR.

voodoos avatar Jul 29 '22 13:07 voodoos

@voodoos any ETA on when this will be merged?

rgrinberg avatar Nov 06 '22 06:11 rgrinberg