Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 267369 - [navigation] 'Open Implementation' should also be available as command
Summary: [navigation] 'Open Implementation' should also be available as command
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Raksha Vasisht CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-06 09:31 EST by Markus Keller CLA
Modified: 2009-08-04 03:23 EDT (History)
2 users (show)

See Also:


Attachments
Patch with the fix. (26.62 KB, patch)
2009-07-30 05:25 EDT, Raksha Vasisht CLA
daniel_megert: review-
Details | Diff
Patch with review changes. (26.38 KB, patch)
2009-08-03 02:39 EDT, Raksha Vasisht CLA
daniel_megert: iplog+
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2009-03-06 09:31:09 EST
I20090304-0834

'Open Implementation' should also be available as a command, so I can assign a key binding like for 'Open Super Implementation'.
Comment 1 Dani Megert CLA 2009-03-09 10:48:17 EDT
This might be true for all hyperlinks, right?
Comment 2 Markus Keller CLA 2009-03-09 11:25:05 EDT
> This might be true for all hyperlinks, right?

Yes, Open Declaration and Step Into Selection are already available as commands, but URL and NLS hyperlinks are also missing.

I think separate commands would be better than bug 78522, since commands are directly accessible but the general popup menu would need more work to become accessible.
Comment 3 Markus Keller CLA 2009-05-27 05:41:01 EDT
And when the links are available as commands, the popup should also show their keybindings if defined (appended in gray, like for quick assists).
Comment 4 Nilesh Kapadia CLA 2009-06-26 12:53:26 EDT
While there is this plugin available which provides this:

http://eclipse-tools.sourceforge.net/implementors/index.html

I think a keybinding for this should be provided out-of-box
Comment 5 Raksha Vasisht CLA 2009-07-30 05:25:49 EDT
Created attachment 142988 [details]
Patch with the fix.

Added a new action Open Implementation to the navigator menu similar to Open Super Implementation.
Comment 6 Dani Megert CLA 2009-07-31 09:23:58 EDT
Raksha, I'm not too happy with the patch. There are various problems that you should have detected before attaching the patch:

1. Assigning a key binding as requested in comment 0 does not work. This cannot 
   work as you forgot to define the command. You can also see this by the 
   warning on the plugin.xml file that your patch introduces.

2. You seem not to have API tooling installed. Your patch is
   - missing @since 3.6 tag on several methods
   - the bundle version in the MANIFEST.MF needs to be updated since new API is 
     added

3. Invoking the action if the caret is not on code causes an NPE (see below)

4. You can't open an editor as a side effect. I suggest for now we only offer
   the action in the editor (text selection), otherwise we'd have to deal with 
   the Quick Hierarchy being able to open on a view. Would be cool but out of 
   scope for this bug. We could do that later.


Some other things to fix:
- The constant in IJavaHelpContextIds.java is in the section where 3.2 
  constants are defined. That's wrong. Please add a new @since 3.6 section and 
  add it there.

- Tool tips have to be in title case

- Don't use this comment:
	/* (non-Javadoc)
	 * Method declared on SelectionDispatchAction.
	 */

  but rather:

	/*
	 * @see <method goes here>
	 */

- JavaElementImplementationHyperlink.findImplementations(...) is a poor name as
  it does not return anything and does more than just finding the 
  implementations

- class comment for OpenImplementationAction is insufficient

- OpenImplementationAction must not allow to be extended



The NPE (from 3. above):
!ENTRY org.eclipse.ui 4 0 2009-07-31 14:00:46.343
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.ui.actions.OpenImplementationAction.run(OpenImplementationAction.java:168)
	at org.eclipse.jdt.ui.actions.OpenImplementationAction.run(OpenImplementationAction.java:115)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:230)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:234)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Comment 7 Raksha Vasisht CLA 2009-08-03 02:39:24 EDT
Created attachment 143237 [details]
Patch with review changes.

1) Added the command to plugin.xml

2)Only one method in JavaElementImplementationHyperlink was missing @3.6 tag. Added it.

3) Pops up a error message for empty selections.

4) Now the action is enabled only for text selections and disabled for all structured selections (disabled in other views) 
 
Added other required tags and comments.
Comment 8 Dani Megert CLA 2009-08-03 05:49:30 EDT
>2)Only one method in JavaElementImplementationHyperlink was missing @3.6 tag.
>Added it.
This is not true. The some constants were also missing the tag.

>- Don't use this comment:
You've still not done that on all method, see e.g. OpenImplementationAction,selectionChanged*
Why?

>3) Pops up a error message for empty selections.
This is wrong. If I have the caret inside e.g. 'foo' then it has to work. Only if there's no method under the caret you need to show the dialog.

Committed to HEAD with fixes for above issues plus some minor corrections:
- OpenImplementationAction has wrong copyright date: 2000, 2009
  ==> should be just 2009
- renamed 'findandOpenImplementations' to 'openImplementations'
- improved Javadoc for JavaElementImplementationHyperlink.openQuickHierarchy(...)
- added empty line between Javadoc text and tags
Comment 9 Dani Megert CLA 2009-08-03 06:13:14 EDT
Filed bug 285412 to track the missing support in views.
Comment 10 Dani Megert CLA 2009-08-04 03:23:22 EDT
Verified for 3.6 M1 using I20090803-1800 on Linux-GTK.