I'm writing an eclipse editor plugin for a custom file format and want to offer a way to quickly jump to the definition of an entity from a named reference to it - basically the "open declaration" functionality of the eclipse Java editor.
I know I can do this by registering an editor action and putting it in the context menu, but I'd really like the way all Java identifiers turn into links to their declaration when you press CTRL in the Java editor - how can I do that? I can't find anything about it in the documentation.
In eclipse, you can paste the link to a comment, hold down control and click it. If you want to be able to just press it without holding anything down, go to Window -> Preferences -> General -> Editors -> Text Editors -> Hyperlinking, then click on URL and remove the modifier key, click apply, click ok and you're done!
Eclipse projects If you want to use Eclipse to create arbitrary text files that are not associated with a code project, then you can create a project file just for your text files. To create a new project, navigate to the File menu and select New Project. From the list of project templates, select General.
The text editor framework provides the abstract implementation of an Eclipse text editor. The File Buffers plug-in which introduces text file buffers for shared access to the content of a text file in form of an IDocument and and associated IAnnotationModel.
Tip. You can set which Eclipse editor or external program to use to open a specific type of file based on its file extension. Just select Window→ Preferences→ Workbench→ File Associations, select the file type, and associate an editor or program with it (if nothing else, you can use Eclipse's default text editor).
I think you are looking for hyper link detectors. Extension point is: org.eclipse.ui.workbench.texteditor.hyperlinkDetectors, Here is snippet from Mylyn plugin.xml:
<extension point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
<hyperlinkDetector
class="org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector"
id="org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.task"
name="%TaskHyperlinkDetector.name"
targetId="org.eclipse.ui.DefaultTextEditor">
</hyperlinkDetector>
Also check out AbstractHyperlinkDetector, useful abstract class you can extend to provide your custom detector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With