Community
Participate
Working Groups
The workaround is as simple as adding "extends AbstractHyperlinkDetector" to the class definition. But this should either be fixed or at least be mentioned in the IHyperlinkDetector Interface.
The exception is thrown, when links are to be shown; Holding ctrl and moving the mouse over the editor.
> CustomHyperlinkDetector There is no such class in the Eclipse SDK. See also http://www.eclipse.org/eclipse/platform-text/development/bug-incomplete.htm
Created attachment 230361 [details] TestProject to reproduce the bug To reproduce the bug: 1. Import the plugin project attached 2. Launch Eclipse with the imported plugin in a new (or existing) workspace 3. Open or create any textfile (Tested with files ending in txt, java & xml) with any TextEditor (Tested with DefaultTextEditor, CompilationUnitEditor, WTP XMl Editor, Android XML Editor) 4. Hold CTRL and move mouse into open Editor 5. Boom: java.lang.ClassCastException: test.HyperlinkDetectorTest cannot be cast to org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector at org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor$1.run(HyperlinkDetectorDescriptor.java:102) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor.createHyperlinkDetector(HyperlinkDetectorDescriptor.java:114) at org.eclipse.ui.texteditor.HyperlinkDetectorRegistry$HyperlinkDetectorDelegate.detectHyperlinks(HyperlinkDetectorRegistry.java:72) at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:286) at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:258) at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseMove(HyperlinkManager.java:462) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:212) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 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:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438) at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
HyperlinkDetectorDescriptor is from org.eclipse.ui.workbench.texteditor (3.8.0.v20120523-1310) "Text Editor Framework" [Active]
(In reply to comment #2) > > CustomHyperlinkDetector > > There is no such class in the Eclipse SDK. > > See also > http://www.eclipse.org/eclipse/platform-text/development/bug-incomplete.htm The name was meant as a placeholder for a user contributed class implementing IHyperlinkDetector. In the attached Testproject it is named HyperlinkDetectorTest
I think the point is that the extension point documentation for Juno SR2, which reads "the fully qualified class name implementing the interface org.eclipse.jface.text.hyperlink.IHyperlinkDetector. Subclass org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector if you want to access context that is provided by the target", makes it sound like subclassing AbstractHyperlinkDetector is optional. WTP has at least one detector that does not.
(In reply to comment #6) > WTP has at least one detector that does not. But wouldn't it then run into the ClassCastException? And wouldn't you have seen this immediately when testing it? Note that the code and the extension point doc are like that since 3.3 (2007).
Created attachment 230385 [details] Fix
(In reply to comment #7) > (In reply to comment #6) > > WTP has at least one detector that does not. > > But wouldn't it then run into the ClassCastException? And wouldn't you have > seen this immediately when testing it? Apparently the class was copied in at the project's inception in 2007 but never declared/contributed as an extension. I only found it by using the type hierarchy.
Fixed with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=1a558034808c92939635cc35dd9a4943988d1678