[HOWTO] CTRL+CLICK Method => Nav to implementation
Answered
I thought one could quickly navigate to the particular implementation of a method using the ctrl+click gesture.
If I have a class Foo that implements say the Runnable interface and I have:
public class Test {
public void someMethod() {
Foo foo = new Foo();
foo.run();
}
}
Shouldn't ctrl+click on run() above take me to Foo's run() and not the Runnable interface? Or am I maybe thinking of some other editor.
I realize that once in Runnable, I can select from one of the many classes in classpath the implement the method.
Sri
Please sign in to leave a comment.
Ctrl-Click goes to declaration, no implementation. It's the difference between Ctrl-B and Ctrl-Alt-B.
In fact it's customizable. Check keymap options.
--
Best regards,
Mike Aizatsky.
-
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"
OK, I see what what both Russell and Mike have pointed out.
However every time I ctrl+click on a method, I want to go to the implementation in the class that is in context. In the original example that's reproduced here,
public class Test {
public void someMethod() {
Foo foo = new Foo();
foo.run();
}
}
that would be the implementation in the class Foo. It is immaterial to me that the run() method is implemented by 18 other classes in my classpath.
I understand that I can customize the keymappings. However, is it possible to make IDEA see that I have clicked foo.run(); then since foo is of type Foo, look in the class Foo -- instead of presenting a list?
Sri
It should work exactly the same way you've described. And I actually have
checked this out and everything appears just OK.
Are you sure you declare
Foo foo = new Foo();
and not
Runnable foo = new Foo();
?
--
Best regards,
Maxim Shafirov
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"
"Srivaths Sankaran" <sri.sankaran@sas.com> wrote in message
news:1341882.1055777532943.JavaMail.itn@is.intellij.net...
method using the ctrl+click gesture.
>
have:
>
>
Runnable interface? Or am I maybe thinking of some other editor.
>
in classpath the implement the method.
>
You are correct. It was
Runnable foo = new Foo();
My mistake.
I wonder if it calls for too much mind reading if we want the same
functionality with the above declaration...:)
Sri
Does not work here.
Excerpt:
Ctrl+Click on "getValidationStatus()" jumps to the interface. And Ctrl+Alt+Click opens three implementations - none of them being the declared one.
Link: https://github.com/JabRef/jabref/blob/3009e8105a779f6c6570b10c42e71ebd671099cc/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java#L116
Hey Oliver.
Please isolate the case in a separate demo class and provide the code for it, and also contents of the related classes/interfaces.