Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define a custom action for "Open Declaration" (shortcut F3) in Eclipse

How do I register an additional handler/action/command for "Open Declaration" (aka F3) in a plugin?

I want to use F3 on String literals in Java code to navigate to the files declaring resource bundle keys. I already have a context menu action ready that does the job. All that's missing is a way to bind it to the key that users are used to.

Extra credit for a complete annotated list of extension points. I'm getting tired of having to spend half a day to find the extension point I have to use for a feature. And by "annotated" I mean more than

Identifier: org.eclipse.ui.workbench.texteditor.quickdiffReferenceProvider
Description: Allows contributors to add reference providers for the quick diff display.
like image 696
Stroboskop Avatar asked Dec 10 '09 16:12

Stroboskop


People also ask

How to Open declaration in Eclipse shortcut?

When your cursor is on the method press F3 , eclipse will take you to the declaration . By default it's bound to F3 , but you can rebind it to a different key, go to Windows >> Preferences >> Keys, and change the Open Declaration binding... Elye M. Elye M.

What does F3 does in eclipse?

f3 — jumps to include file or variable declaration/definition. if you want to use the mouse for this, press the ctrl key and hover over the source with the mouse. shortcut for navigate > open declaration .

What is open declaration in Eclipse?

Open declaration will attempt to navigate to the exact definition of the selected element if the selected element is a reference or a declaration. Otherwise, it will attempt to navigate to a declaration of the selected element.

How do I go back a function call in eclipse?

Press Alt + Left Arrow and Alt + Right Arrow like you would in a web browser.


2 Answers

See section on keybindings in Eclipse Commands tutorial for detailed instructions how to implement command handlers and bind them to keys, menus and toolbars.

There is a full list of extension points provided in Eclipse help, though you have to drill down to get the full description and code samples. There is also an "Add extension point" wizard in plugin editor, which shows a brief description, link to the full help and for some extension points even have predefined templates.

like image 114
Eugene Kuleshov Avatar answered Oct 24 '22 06:10

Eugene Kuleshov


Perhaps you know this, but although the F3 keyboard shortcut won't take you to the declaring resource bundle key, there are two similar things that do work:

  • Hovering over the string with the mouse will show you the converted string.
  • Control-clicking the string will jump you to the declaring resource bundle key.

Obviously, these both require use of the mouse; if you are a keyboard-only kind of person, you might not be happy with these.

This doesn't directly answer your question, but I hope it helps.

like image 44
Mike Morearty Avatar answered Oct 24 '22 07:10

Mike Morearty