2

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

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

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • search for on http://help.eclipse.org/kepler/index.jsp gived no results, but on Juno http://help.eclipse.org/juno/index.jsp returns "JavaScript Completion Proposal Computer" & "Java Completion Proposal Computer – Paul Verest Dec 26 '13 at 06:39
  • Cannot find "JavaScript Completion Proposal Computer" on Kepler Help – Paul Verest Dec 26 '13 at 06:42
  • On this example categoryId not match proposalCategory id – zulus Jan 08 '14 at 10:06
  • Instead of this: try to add activate="true" in javaCompletionProposalComputer and remove – zulus Jan 08 '14 at 10:08
  • OK, that is to explorer `javaCompletionProposalComputer` options – Paul Verest Jan 08 '14 at 10:31
  • It worked, add your answer if you like it to be accepted. Next thing for me will be 1) understanding context (that is to define where is client side and where is server side) 2)why there is no icon in In Preferences -> JavaScript -> Editor -> Content Assist -> Advanced – Paul Verest Jan 08 '14 at 13:35
  • As I saw in code, JSDT contain only one context now. You can register own and use it on additional computers. Icon is an another extension point in UI plugin. Look at my eclipse-extjs plugin ;) – zulus Jan 09 '14 at 12:51

2 Answers2

1

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)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • 1
    Where do I find the file to edit? I just recently started having this error for some reason. On Mars. – Damainman Feb 18 '16 at 08:40
0

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

Christian
  • 446
  • 2
  • 14
  • SO is not for sharing links. Is this solution different? – Paul Verest May 19 '14 at 07:54
  • sorry for sharing the link. I thought having a downloadable, running out of the box solution would be helpful, too. The provided link also shows a default class implementation along with needed plugin dependencies – Christian May 20 '14 at 10:00