Suppose I have:
interface Foo {
void doStuff();
}
class FooImpl implements Foo {
public void doStuff() {
// stuff
}
}
When I see myFoo.doStuff()
in my code, if my cursor is over doStuff()
, pressing F3 will take me to the doStuff()
method in the interface Foo
. Of course, I often am much more interested in the implementation of this method, not just the signature.
Does Eclipse have an easy way to navigate from a declaration of a method in an interface to the implementation of that method in the implementing class?
In my case, there will not be ambiguity about what the implementing class is.
Highlight the method name, and press either CTRLT or F4. You'll see a type hierarchy, but linked to the method rather than the containing classes. Select the desired implementation class.
Or - if you have enabled Hyperlinking (see the preference page with that name) - you can press Control (or Command on MacOS) and click on the method name. It will then show a menu with "Open Declaration" and "Open Implementation"...
Select the method and press Ctrl+T.
Also clicking the gray
up-arrow on the left hand side of the editor close to the line numbers will take you to a method declaration in an interface. If that same arrow is green
, it will take you to a method definition in a super class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With