Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cannot cast to XbaseScopeProvider(Code completion for DataTypes raises ClassCastException)
Cannot cast to XbaseScopeProvider [message #836678] Wed, 04 April 2012 15:38 Go to next message
Gregor Frey is currently offline Gregor Frey
Messages: 12
Registered: April 2012
Junior Member
Hi,
I declare a DataType by a reference to JavaTypes like:

DataType:
'DataType' name=QualifiedName ':' type=JvmTypeReference;


When I use the code completion in the editor like here:

Element Name : Name

defined by the rule:

Element:
'Element' name=ID ':' type=[DataType];


the code completion raises a class cast exception:

!ENTRY org.apache.log4j 2 0 2012-04-04 21:25:30.331
!MESSAGE org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider - Error in polymorphic dispatcher : de.makkiato.apparatus.bodl.scoping.BodlScopeProvider cannot be cast to org.eclipse.xtext.xbase.scoping.XbaseScopeProvider

!STACK 0
java.lang.ClassCastException: de.makkiato.apparatus.bodl.scoping.BodlScopeProvider cannot be cast to org.eclipse.xtext.xbase.scoping.XbaseScopeProvider

It seems that the BodlScopeProvider is not generated as expected. Where and how can I configure the generation of the ScopeProvider?

Thanks for any help.

Gregor
Re: Cannot cast to XbaseScopeProvider [message #836685 is a reply to message #836678] Wed, 04 April 2012 15:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Hi,

you can
- change the supertype manually - if you chosed your grammar to extend Xbase after you initially created it
- let your grammar extend Xbase (grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase) if you create a new DSL

~Christian
Re: Cannot cast to XbaseScopeProvider [message #836696 is a reply to message #836685] Wed, 04 April 2012 16:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
P.S: do you have somethiong like that in your workflow:

// generates the required bindings only if the grammar inherits from Xbase
            fragment = xbase.XbaseGeneratorFragment {}
Re: Cannot cast to XbaseScopeProvider [message #836745 is a reply to message #836696] Wed, 04 April 2012 17:43 Go to previous messageGo to next message
Gregor Frey is currently offline Gregor Frey
Messages: 12
Registered: April 2012
Junior Member
Unfortunately both measures are not sufficient. Thanks anyway! My grammar extends Xbase and the Generator line was already in the mwe2 file. I attach my grammar and my workflow.
Perhaps you might have another idea what goes wrong?
Gregor
Re: Cannot cast to XbaseScopeProvider [message #837108 is a reply to message #836745] Thu, 05 April 2012 05:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Hi,

if i create a new project with your grammar it generates no scopeprovider at all. =>

	// contributed by org.eclipse.xtext.generator.xbase.XbaseGeneratorFragment
	public Class<? extends org.eclipse.xtext.scoping.IScopeProvider> bindIScopeProvider() {
		return org.eclipse.xtext.xbase.scoping.XbaseScopeProvider.class;
	}


=> where does your scopeprovider and its binding come from?

~Christian
Re: Cannot cast to XbaseScopeProvider [message #837150 is a reply to message #837108] Thu, 05 April 2012 06:21 Go to previous messageGo to next message
Gregor Frey is currently offline Gregor Frey
Messages: 12
Registered: April 2012
Junior Member
Hi Christian,
the ScopeProvider get's generated. When I delete the class and run the workflow again, the ScopeProvider returns like this:

/*
* generated by Xtext
*/
package de.makkiato.apparatus.bodl.scoping;

import org.eclipse.xtext.xbase.scoping.XbaseScopeProvider;

/**
* This class contains custom scoping description.
*
* see : ...#scoping
* on how and when to use it
*
*/
public class BodlScopeProvider extends XbaseScopeProvider {

}

I use Eclipse 3.7.2 and Xtext 2.0.1.

I'll try the smae project from scratch again.
Ciao
Gregor
Re: Cannot cast to XbaseScopeProvider [message #837153 is a reply to message #837150] Thu, 05 April 2012 06:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Hi,

i was testing with Xtext 2.2.1 => there have been some changes since.

~Christian
Re: Cannot cast to XbaseScopeProvider [message #837182 is a reply to message #837153] Thu, 05 April 2012 07:17 Go to previous messageGo to next message
Gregor Frey is currently offline Gregor Frey
Messages: 12
Registered: April 2012
Junior Member
Hi,
yes, with Xtext 2.2.1 the ScopeProvider is not generated. But maybe this is due to my selection of choosing the option "use stable API only" when I recreated the project.
But now I get guice errors when I bring up the generated editor and create a new instance of my language:

!ENTRY org.eclipse.ui 4 0 2012-04-05 13:02:38.983
!MESSAGE Unable to create editor ID de.makkiato.appgen.Bodl: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in plugin.xml.
!STACK 0
com.google.common.util.concurrent.UncheckedExecutionException: com.google.inject.CreationException: Guice creation errors:

1) No implementation for org.eclipse.xtext.ui.refactoring.ui.IRenameSupport$Factory was bound.
while locating org.eclipse.xtext.ui.refactoring.ui.IRenameSupport$Factory
for field at org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringController.renameSupportFactory(Unknown Source)
while locating org.eclipse.xtext.ui.refactoring.ui.RenameRefactoringController
for field at org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler.renameRefactoringController(Unknown Source)
at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:55)

Is there a dependency missing?
Ciao
Gregor
Re: Cannot cast to XbaseScopeProvider [message #837191 is a reply to message #837182] Thu, 05 April 2012 07:32 Go to previous messageGo to next message
Gregor Frey is currently offline Gregor Frey
Messages: 12
Registered: April 2012
Junior Member
Sorry, the error was my mistake. Probably I got the file extension wrong.

So, now, in 2.2.1, there is no issue with ScopeProvider, even when I use the "experimental", "non-stable" features.
I would recommend to put this version to the Eclipse update site too, because there I got the 2.0.1 version, that generated the critical ScopeProvider.

Thanks, Christian, for your help!
Ciao
Gregor
Re: Cannot cast to XbaseScopeProvider [message #837192 is a reply to message #837182] Thu, 05 April 2012 07:32 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4387
Registered: July 2009
Senior Member
Hi,

simply make sure you merge plugin.xml_gen to plugin.xml

~Christian
Previous Topic:cached models
Next Topic:Why download antlr per project?
Goto Forum:
  


Current Time: Sun May 19 10:21:03 EDT 2013

Powered by FUDForum. Page generated in 0.01999 seconds