Creating a eclipse plugin with text hover

前端 未结 1 932
你的背包
你的背包 2020-12-18 13:06

I would like to make a Eclipse plugin (text editor). I would \"read\" the text under the cursor and show a dynamical generated hover that depends on the text. N

相关标签:
1条回答
  • 2020-12-18 13:34

    Your fault is that you created a completly new Editor instead of a plugin for the existing Java Editor. Plugins will be activated via extension points. In your case you have to 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 holds the path to your Class that 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 ;-)

    0 讨论(0)
提交回复
热议问题