[jbosstools-issues] [JBoss JIRA] (ERT-191) ClassCastException from KeywordCompletionProposalComputer & IdentifierCompletionProposalComputer witn Neon M7 [EBZ#493393]

Friendly Jira Robot (JIRA) issues at jboss.org
Wed May 11 17:26:00 EDT 2016


Friendly Jira Robot created ERT-191:
---------------------------------------

             Summary: ClassCastException from KeywordCompletionProposalComputer & IdentifierCompletionProposalComputer witn Neon M7 [EBZ#493393]
                 Key: ERT-191
                 URL: https://issues.jboss.org/browse/ERT-191
             Project: Eclipse Release Train
          Issue Type: Task
          Components: JSDT
            Reporter: Friendly Jira Robot


The Eclipse Neon M7 provides KeywordCompletionProposalComputer & IdentifierCompletionProposalComputer classes which doesn't use "instanceof" to check that the given ContentAssistInvocationContext is a JavaContentAssistInvocationContext:

```
public class IdentifierCompletionProposalComputer implements IJavaCompletionProposalComputer {

  public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
		JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
```

It's a big problem for typescript.java which is based on JSDT and which defines TypeScriptContentAssistInvocationContext (see issue at 
https://github.com/angelozerr/typescript.java/issues/56)

So with oEclipse Neon M7, when I do completion with my TypeScriptEditor based on JSDT Edit, I have a popup error with this error

```
java.lang.ClassCastException: ts.eclipse.ide.jsdt.internal.ui.editor.contentassist.TypeScriptContentAssistInvocationContext cannot be cast to org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext
	at org.eclipse.wst.jsdt.internal.ui.text.java.KeywordCompletionProposalComputer.computeCompletionProposals(KeywordCompletionProposalComputer.java:45)

```

and 

```
java.lang.ClassCastException: ts.eclipse.ide.jsdt.internal.ui.editor.contentassist.TypeScriptContentAssistInvocationContext cannot be cast to org.eclipse.wst.jsdt.ui.text.java.JavaContentAssistInvocationContext
	at org.eclipse.wst.jsdt.internal.ui.text.java.IdentifierCompletionProposalComputer.computeCompletionProposals(IdentifierCompletionProposalComputer.java:49)

```

It should b every cool if you could check that ContentAssistInvocationContext is an instanceof JavaContentAssistInvocationContext:

```
public class IdentifierCompletionProposalComputer implements IJavaCompletionProposalComputer {

  public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
  if (context instanceof JavaContentAssistInvocationContext) {
		JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
```

for :

 * http://git.eclipse.org/c/jsdt/webtools.jsdt.git/tree/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/IdentifierCompletionProposalComputer.java
 * http://git.eclipse.org/c/jsdt/webtools.jsdt.git/tree/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/KeywordCompletionProposalComputer.java

For your infomration, I have created my own TypeScriptContentAssistInvocationContext, because I need IResource and I don't use IJavaCompilationUnit. If http://git.eclipse.org/c/jsdt/webtools.jsdt.git/tree/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/ui/text/java/JavaContentAssistInvocationContext.java could just define a getter for the Editor, I think I could use directly JavaContentAssistInvocationContext to retrieve my IResource from the getEditor getter.

Hope this issue will be able to fixed for Neon release, otherwise typescript.java will not work with Eclipse Neon release -(  (we must desactivate the whole JSDT completions to avoid having those 2 popup errors)

Many thanks for your help!



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jbosstools-issues mailing list