Creating a text-hung eclipse plugin

I would like to make an Eclipse plugin (text editor). I would β€œread” the text under the cursor and show a dynamically generated hover depending on the text. Now I have a problem that I do not know how I can read the text and β€œadd” the hang.

This is my first Eclipse plugin , so I'm happy for every piece of advice I can get.

Edit:

I would like to integrate it into the default Eclipse Java editor. I tried to create a new plugin with an editor template, but I think this is the wrong way.

Last Modified:

The answer from PKeidel is exactly what I'm looking for :)

Thanks PKeidel

+3
source share
1 answer

Your mistake is that you created a completely new editor instead of the plug-in for your existing Java editor. Plugins will be activated using extension points . In your case, you should use org.eclipse.jdt.ui.javaEditorTextHovers more ....

 <plugin> <extension point="org.eclipse.jdt.ui.javaEditorTextHovers"> <hover activate="true" class="path.to_your.hoverclass" id="id.path.to_your.hoverclass"> </hover> </extension> </plugin> 


The class argument contains the path to your class, which implements IJavaEditorTextHover .

 public class LangHover implements IJavaEditorTextHover { @Override public String getHoverInfo(ITextViewer textviewer, IRegion region) { if(youWantToShowAOwnHover) return "Your own hover Text goes here""; return null; // Shows the default Hover (Java Docs) } } 

That should do it; -)

+4
source

All Articles