8

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.

Eric Wilson
  • 54,930
  • 75
  • 197
  • 265

3 Answers3

12

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.

Stephan
  • 14,314
  • 7
  • 33
  • 60
javawebapps
  • 368
  • 2
  • 10
  • 1
    F4 shows more or less the same thing but in an actual view, rather than kind of a "popup". You might prefer one or the other. – Tyler Jun 21 '11 at 20:24
7

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"...

Tonny Madsen
  • 12,448
  • 4
  • 30
  • 68
  • Hah, I don't know how I always missed this dialog. Just made CTRL + click, which selects open declaration. – User Nov 17 '13 at 18:44
3

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.

Nick
  • 5,705
  • 5
  • 26
  • 36