用于Eclipse的JavaCompletionProposalComputer的内容辅助JSDT没有提出任何建议

时间:2013-12-26 06:02:31

标签: java eclipse-plugin content-assist jsdt nodeclipse

Eclipse JSDT的org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer内容协助不提供任何建议。

Preferences -> JavaScript -> Editor -> Content Assist -> Advanced “Nodeclipse Proposals”是可见的,并被选中。

根据Bananaweizen的建议Content assist for Eclipse JSDT based Editor

在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只是NodeContentAssistant的包装器 (实现IContentAssistProcessor),对于基于TextEditor的编辑器非常有效。

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()));
    }
来自help

示例

所有代码都在GitHUb contentassisthttps://github.com/Enide/nodeclipse-1/tree/master/org.nodeclipse.ui/src/org/nodeclipse/ui/contentassist

2 个答案:

答案 0 :(得分:0)

正如@zulus所说:

  

尝试在javaCompletionProposalComputer中添加activate =“true”并删除

有效的是:

<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>

http://www.nodeclipse.org/img/Completion-for-base-Node.js-modules.PNG

答案 1 :(得分:0)

如果您需要一个实现Pauls的简单示例实现,您可以查看本教程:http://codeandme.blogspot.co.at/2014/05/extending-jsdt-adding-your-own-content.html