You know how in Eclipse, pressing F3 over a method will take you to its declaration? Well I have a method that is part of an interface; clicking F3 over this naturally takes me to the declaring interface.
Obviously there is an object implementing this interface and this is where the method is actually implemented. I want, when I press F3, to jump to the implementation, not the interface declaration. I know that the implementation may not be known at compile-time, so is there a way for Eclipse to show me all the classes implementing the interface so that I can select which implemented method to view? Right now when this happens I am just manually searching for this to find the implemented method.
Here's what I do:
In the interface, move the cursor to the method name. Press F4. => Type Hierarchy view appears
In the lower part of the view, the method should already be selected. In its toolbar, click "Lock view and show members in hierarchy" (should be the leftmost toolbar icon).
In the upper part of the view, you can browse through all implementations of the method.
The procedure isn't very quick, but it gives you a good overview.
Well... well... I hope you use Eclipse Helios, because what you asked is available on Helios.
Put your text cursor again on the method and click menu Navigate → Open Implementation. Now if you have more than one implementation of the method, you will get choice to pick which implementation to open.
By defining a keybinding on Preferences → General → Keys you can even use the feature easier, but before you do that, see if this shortcut is fast enough for you.
Press Ctrl + click and hold. Now move your mouse over the same method. Tadam… you will get choice.
If you pick Open Implementation you’ll get the same choice as before.
Press Ctrl + T on the method name (rather than F3). This gives the type hierarchy as a pop-up so is slightly faster than using F4 and the type hierarchy view.
Also, when done on a method, subtypes that don't implement/override the method will be greyed out, and when you double click on a class in the list it will take you straight to the method in that class.
There's a big productivity boost if you add an Alt + F3 key binding to the Open Implementation feature, and just use F3 to go to interfaces, and Alt + F3 to go to implementations.
Highlight an interface and use Ctrl+T to open "Quick Type Hierarchy".
ctrl + mouse hover + click "Open Implementation"
On ctrl + hover, you should see the following menu:
Tested on Eclipse Mars.2 (4.5.2)
Here is what I do:
I press command (on Mac, probably control on PC) and then hover over the method or class. When you do this a popup window will appear with the choices "Open Declaration", "Open Implementation", "Open Return Type". You can then click on what you want and Eclipse brings you right there. I believe this works for version 3.6 and up.
It is just as quick as IntelliJ I think.
See In eclipse, ctrl-click goes to the declaration of the method I clicked. For interfaces with one implementation, how can I just directly to that implementation? for some alternative solutions.
Anyway, I think you might be looking for something like this:
http://eclipse-tools.sourceforge.net/implementors/
I always use this implementors plugin to find all the implementation of an Interface
http://eclipse-tools.sourceforge.net/updates/
it's my favorite and the best
If you are really looking to speed your code navigation, you might want to take a look at nWire for Java. It is a code exploration plugin for Eclipse. You can instantly see all the related artifacts. So, in that case, you will focus on the method call and instantly see all possible implementations, declarations, invocations, etc.
The best solution would be Ctrl+Alt+I.
Related
I want to jump from an class (method) that implement an interface (method) to the interface method by a keyboard shortcut in Eclipse.
Is there a shortcut to do this?
Goto to "Window" -> "Preferences" -> "General" -> "Keys
There search for "Open Super Implementation" and create a key binding for that.
Press F4 with focus on the method.
answer to the question described in comments under flafoux answer, but to clearly explain the answer, giving here...
Select Method in implementation and Press F4 button
It shows Type Hierarchy
On Type Hierarchy, on the top section click on toolbar button Show Supertype hierarchy (this step is only required once)
On Type Hierarchy, detail section shows Interface method
Click on the (automatically selected) method
Use Quick Type Hierachy, Ctrl + T.
When this is used while the cursor is inside a method you will get a popup which lets you select among the superclasses which declare the current method. By pressing Ctrl + T again while the popup is still open it lets you select among implemented interfaces which declare the current method.
Is there a keyboard shortcut in Xcode for jumping to the implementation of a method? I am aware of the fact the command+click will jump to definition, but I want to jump to the implementation method, not the definition. Also, I want to use keyboard shortcuts, with no involvement of the mouse (including clicks).
Keyboard shortcut for 'jump to definition' in XCode 4.5: Control-Command-J
Another useful shortcut after jumping to definition is Control-Command-Left (which takes you back).
Command + click will work, If you want "keyboard only" shortcut you need to map it under Preferences->key bindings->Edit->Find->jump to definition
Hold Command and click on the method you want to see it's implementation.
There is an addin for Visual Studio called MouseNavi that allows you to use mouse thumb buttons to navigate your history.
Does a similar extension exist for Eclipse?
I don't know of any Eclipse plugin that does this, but assuming you're using Windows:
This one should enable you to do what you want: http://www.highrez.co.uk/downloads/XMouseButtonControl.htm
With that tool you can assign each mouse button a sequence of keys (Alt+Left for example) and because it can be made application specific it won't interfere with other programs where you don't want that mapping.
Alt+Left and Alt+Right to navigate through the latest opened editors.
Also, Alt+L to open up the shortcuts popup, so you can see what's available.
No real mouse navigation control though (not that I know of... at least). Although, should not be very difficult to create one and attach it to the same handlers that deal with the navigation commands.
^Q takes you to last edited location. You can cycle using it. No mouse bindings.
I often use the Eclipse feature (Galileo) of suggested error corrections to automatically create code stubs or to refactor things. For example, I would write a method that calls other methods which don't exist yet, then move the mouse over the error message and click on "create method". Or, change this to the class name and choose "add static modifier" from the quick fixes.
I think this is very convenient because it lets me stay in one place in my code and sort of "remotely" wire up what's not currently visible on my screen. What I think is annoying though, is that I have to leave the keyboard, hover my mouse over the error symbol, wait for the tooltip to pop up, and click on the option (doing that, I sometimes move the mouse a little over the edge and the tooltip goes away again - very annoying).
Am I missing a faster method here? I can't seem to find a keyboard shortcut, but then I have overlooked stuff from the huge preference dialog before.
Ctrl+1 : Quick Fix.
(Cmd+1 on Mac)
Just put your cursor on the part you suspect you can perform an action (correction, refactoring, ...) and hit the Quick Fix shortcut. The same popup will be displayed, and you can select the right option with the up and down keys.
That, combined with Ctrl+3 (Quick Access) gives you most of eclipse features at your fingertips ;)
See also:
Eclipse Tip: Shortcut to Quick Fix
My Favorite Eclipse Shortcut: Quick Fix
Eclipse hotkeys: eclipse shortcuts gold mine.
As an additional tip, a specific type of quick fix I use all the time has a dedicated shortcut:
Alt+Shift+J: Add Javadoc comment stub for current method.
After using ctrl+1 like mentioned in the top answer, press ctrl + enter to apply the selected fix all to problems of the same category.
In general, keyboard shortcuts in IDEs (and code tools in general) are coming from a user principle that holds that the more your hands/fingers can remain poised over the keyboard (as in the f-j centered "touch typist" position), the more productive you can become. This is probably why the use of the number keypad is not encouraged, or other keys, less common to the most basic layout keyboard, are not used. Many hold that useful keyboard shortcuts should be easily reachable from this position.
One thing I will say about eclipse keyboard shortcuts is that if you use a popular Windows presentation utility called Zoom-it, you need to turn that off when using eclipse. There are several show-stopper conflicts between the two, such as Ctrl-1 and Ctrl-3.
NetBeans 6.5 with Python support provides the docstring documentation for a function/method in a popup when auto-completing, but is there another way to view docstrings?
Perhaps achieved by mousing over a function/method name, or clicking somewhere?
The best I can seem to do is "Go to source" in the right-click menu.
I received the following answer from Tor Norbye at Sun:
Hold the ctrl key (or Cmd on Mac) and then hover.
Also, Ctrl-Shift-Space (e.g. code completion + shift) will display -just- the completion doc (which means it doesn't just look at the prefix of the caret, but the whole identifier and left hand side type if it can resolve it, to compute one specific match rather than many).
You can also use this keyboard shortcut on Mac. Shift + Meta + Backslash
You may be referring to the function Show Documentation Popup in Netbeans
Try
Ctrl+Shift+SPACE or
Ctrl+Shift+BACK_SLASH
related: How to see Javadoc documentation on mouse hover in NetBeans?