Bug 176282 Link With Editor in Navigator and Project Explorer should work for IEditInput that can adapt to IFile
If I define an IEditorInput implementation that returns an IFile when asked for an IFile.class adapter, the Link With Editor capability of the Navigator or Project Explorer should work properly. But it appears that this capability is supported by doing an instanceof IFileEditorInput test instead. That's far less flexible and doesn't seem like the right way to implement it. I talked to Dani about this problem, and he said he fixed it right away for the Package Explorer, which currently has the same proble. Perhaps this isn't a big concern, but I also noticed problems with how equals is defined for FileEditorInput. It only considers itself equal to another IFileEditorInput, even though it implements IPathEditorInput too. Yet JavaFileEditorInput will consider itself equal to another IPathEditorInput with a matching path. So one could have a JavaFileEditorInput that's considers itself equal to a particular FileEditorInput but the opposite would not be true. I think that makes equals poorly defined. I also don't think the hashCode method for JavaFileEditorInput is properly defined to match the equality algorithm. I suppose this hasn't caused any real problems...
bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceLinkHelper.java
/* (non-Javadoc)
	 * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui.IEditorInput)
	 */
	public IStructuredSelection findSelection(IEditorInput anInput) {
		if (anInput instanceof IFileEditorInput)
			return new StructuredSelection(((IFileEditorInput) anInput).getFile());
		return StructuredSelection.EMPTY;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
	 */
	public void activateEditor(IWorkbenchPage aPage,
			IStructuredSelection aSelection) {
		if (aSelection == null || aSelection.isEmpty())
			return;
		if (aSelection.getFirstElement() instanceof IFile) {
			IEditorInput fileInput = new FileEditorInput((IFile) aSelection.getFirstElement());
			IEditorPart editor = null;
			if ((editor = aPage.findEditor(fileInput)) != null)
				aPage.bringToTop(editor);
		}
	}
}