Intellij-rust: Support "Go to Declaration" inside macros

Created on 5 Oct 2018  路  3Comments  路  Source: intellij-rust/intellij-rust

It would be very useful if "Go to Declaration" worked inside macro invocations.

For example, in the following macro invocation:

```rust
error_chain! {
foreign_links {
Json(serde_json::Error)
}
}
````

if you would be nice if "Go to Declaration" worked on serde_json::Error.

Eclipse CDT supports this for C/C++ macros. Their general implementation strategy is:

  • When expanding macros, keep track of a mapping between tokens in the source text, and where in the macro expansion they end up.
  • When performing "Go to Declaration" on a token inside a macro invocation, use the mapping to look up the corresponding token in the (final) expansion. (If there are multiple such tokens in the final expansion, can try each one, or pick the first, or something.)
  • Perform "Go to Declaration" as if it had been invoked on the token in the expansion.
feature macros type inference & name resolution

Most helpful comment

Yeah, this approach works great! I just made a prototype and it works as expected. I'll finish it right after #3015 landing.

All 3 comments

Yep, I'm going to try this approach. When will be free time =)

Yeah, this approach works great! I just made a prototype and it works as expected. I'll finish it right after #3015 landing.

Will be very soon. All preparations are done #3640

Was this page helpful?
0 / 5 - 0 ratings