IntelliJ Rust :: jump to FooBar::some_func

Suppose we have

struct FooBar {
impl SomeTrait for FooBar {
  fn some_func(...) {}

Now, if we want to jump to struct, we can use "goto class". If we want to jump to the function we can try searching for "fn some_func(" (but it finds other impls too).

Is there a way, in IntelliJ to say "jump to FooBar::some_func" ?

Pre-emptive: No, we can't assume the trait is implemented in some file as where struct is defined.

The "stupid" way I do this is to move into some statement context, type FooBar::some_func, and then Go to Definiton on the method reference I just typed. Yes, this is editing code just to perform a navigation, but I remember how to Go to Definition off the top of my head so it's an operation I can do quickly and then undo adding what I just typed.

The even stupider way I end up doing it often is searching all files for SomeTrait for FooBar. It may be doggone simple and not use the IDE superpowers, but it's also simpler to remember and works.

More principled, the IntelliJ platform does offer a Go to Symbol operation that I believe IntelliJ IDEA does support. The menu item is Navigate | Symbol... and the default keybind is Ctrl+Shift+Alt+T (or you can any action Ctrl+Shift+A and type/choose Go to Symbol).

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.