Stream: t-compiler/rust-analyzer

Topic: MBE: mapping spans in IDE

matklad (Apr 11 2019 at 10:12, on Zulip):

cc @Igor Matuszewski

So, the high level goal here is to make this work:

macro_rules! s {
    ($i:ident) => { struct $i; }

s!(Foo); // arrive here

fn foo(_: Foo) { // press go to definition on `Foo` here

matklad (Apr 11 2019 at 10:14, on Zulip):

Currently, go to definition gives the wrong span (which is actually by itself is pretty cool!)

matklad (Apr 11 2019 at 10:15, on Zulip):

key code pointers:


matklad (Apr 11 2019 at 10:16, on Zulip):

Original FIle function:

It should be extended to return a span-transofmation function as well

matklad (Apr 11 2019 at 10:18, on Zulip):

and here's the exact place where we get the wrgon span for goto definition:

matklad (Apr 11 2019 at 10:19, on Zulip):

note that we call original_file here, which returns the source file (as opposed to the maro pseudo file, where the node actually resides), while the ndoe still has offsets in the macro-generated file

matklad (Apr 11 2019 at 10:21, on Zulip):

btw, might be a good idea to create a GitHub issue for this zulip thread as well

Last update: Jul 28 2021 at 03:45UTC