如何让 eclipse 转到接口方法的唯一实现?

如果我在一个接口中并且指向一个方法名,我能做什么来快速转到该方法的惟一实现?

使用 Eclipse 3.6。

109585 次浏览

I just checked this on my Eclipse 3.6 install: Hold control (command on Mac), hover over the method name and select "Open Implementation".

You may assign a keyboard shortcut to this action by using Window > Preferences > General > Keys and searching for "Open Implementation".

In the keymap (General > Keys) search for "open implementation" and map it to whatever you want. I chose Ctrl + Shift + I. Make sure you select "Editing Java Source" in the When box. I tested it, and having the cursor over the method name and pressing Ctrl + Shift + I took me directly to the implementation instead of showing the hierarchy that you get with Ctrl + T.

enter image description here

Also you can see an answer to a nearly identical question for other options:

F3 is the typical "go to implementation". For interfaces that go to the interface definition.

Instead use Ctrl + T to see all implementations of the interface definition. You can then easily go to the one you want with the arrow keys and Enter. I believe that the first one is automatically selected so that Ctrl-T + Enter will do what you need.

If someone still need this information nowadays (Eclipse version 2022), to jump into interface method definition starting from an @Override method, now in Eclipse you can see on the left, next to the method signature, a little white triangle. By clicking on that you will jump to the implemented interface method. here an image of the little triangle

Oterwise, if you are on a interface method definition and you need to jump to one of the implementations, you must use CTRL+T shortcut to see the list of available implementations and than click on one of them.