Content assist with javaCompletionProposalComputer for Eclipse JSDT gives no proposal

旧时模样 提交于 2019-12-05 07:27:24

问题


Content assist with org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer for Eclipse JSDT gives no proposal.

In Preferences -> JavaScript -> Editor -> Content Assist -> Advanced "Nodeclipse Proposals" are visible, and selected.

as advised by Bananaweizen to Content assist for Eclipse JSDT based Editor

in plugin.xml

<extension point="org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer"
   id="nodeclispe_textual_proposals"
   name="Nodeclipse Text Proposals">
   <proposalCategory icon="icons/npm/npm.gif"/>
 </extension>
 <extension point="org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer"
   id="NodeclipseProposals"
   name="Nodeclipse Proposals">
   <javaCompletionProposalComputer
      class="org.nodeclipse.ui.contentassist.JSDTProposalComputer"
      categoryId="org.eclipse.ui.texteditor.textual_proposals">
      <partition type="__java_javadoc"/>
   </javaCompletionProposalComputer>
 </extension>

JSDTProposalComputer is just wrapper for NodeContentAssistant
(that implements IContentAssistProcessor), that works perfectly well for TextEditor based Editor.

public class JSDTProposalComputer implements IJavaCompletionProposalComputer {

    IContentAssistProcessor assistant = new NodeContentAssistant();

    @Override
    public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
        return Arrays.asList(assistant.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
    }

    @Override
    public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
        return Arrays.asList(assistant.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
    }

examples from help are

  • HippieProposalComputer - http://svn.codespot.com/a/eclipselabs.org/mobile-web-development-with-phonegap/tags/r1.2/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/HippieProposalComputer.java
  • HippieProposalProcessor - http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.5.2/org.eclipse.ui.workbench/texteditor/3.5.1/org/eclipse/ui/texteditor/HippieProposalProcessor.java

All code is on GitHUb contentassist package https://github.com/Enide/nodeclipse-1/tree/master/org.nodeclipse.ui/src/org/nodeclipse/ui/contentassist


回答1:


If you need a simple example implementation implementing Pauls answer you may check out this tutorial: http://codeandme.blogspot.co.at/2014/05/extending-jsdt-adding-your-own-content.html




回答2:


Exactly as @zulus said:

try to add activate="true" in javaCompletionProposalComputer and remove

what worked is:

<extension point="org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer"
   id="nodeclispe_textual_proposals"
   name="Nodeclipse Text Proposals">
   <proposalCategory icon="icons/npm/npm.gif"/>
 </extension>
 <extension point="org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer"
   id="NodeclipseProposals"
   name="Nodeclipse Proposals">
   <javaCompletionProposalComputer
      class="org.nodeclipse.ui.contentassist.JSDTProposalComputer"
      categoryId="org.eclipse.ui.texteditor.textual_proposals"
      activate="true">
   </javaCompletionProposalComputer>
 </extension>


(source: nodeclipse.org)



来源:https://stackoverflow.com/questions/20779899/content-assist-with-javacompletionproposalcomputer-for-eclipse-jsdt-gives-no-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!