Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xbase generation exception
xbase generation exception [message #895571] Fri, 13 July 2012 15:06 Go to next message
Frantisek Kocun is currently offline Frantisek KocunFriend
Messages: 16
Registered: July 2009
Junior Member
Hi, I got exception when I try to generate XExpression

Caused by: java.lang.ClassCastException: org.eclipse.xtext.common.types.access.jdt.JdtTypeProvider cannot be cast to org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider
at org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory.findTypeProvider(ClasspathTypeProviderFactory.java:49)
at org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory.findTypeProvider(ClasspathTypeProviderFactory.java:1)
at org.eclipse.xtext.common.types.access.AbstractTypeProviderFactory.findOrCreateTypeProvider(AbstractTypeProviderFactory.java:38)
at org.eclipse.xtext.common.types.util.TypeReferences.findDeclaredType(TypeReferences.java:188)


Generating XExpression in tutorial "Five simple steps to your JVM language" works like the a charm. I did it this way:

xbaseCompiler.toJavaStatement(xExpression, res, false)


But we don't have the same setup as in tutorial. We start generator on a click on button in Eclipse (because we have more generators to choose from) when element xtext file is selected. To generate we load resources like this (our model can be split in several files):

protected ResourceSet loadResourceSet(IProject project)
{
// creates empty ResourceSet based on the given project
XtextResourceSet resourceSet = (XtextResourceSet) resourceSetProvider.get(project);

// get Xtext index
IResourceDescriptions index = resourceDescriptionsProvider.createResourceDescriptions();
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);

// iterate over every resource descriptor (each describes exactly 1 file)
for (IResourceDescription rd : index.getAllResourceDescriptions())
{
// load eagerly iterated Resource to ResourceSet
if(rd.getURI().toString().contains("zoro.pn") || rd.getURI().toString().contains("export.pn"))
resourceSet.getResource(rd.getURI(), true);
}

return resourceSet;
}


Does anyone knows where the problem is?
And we use xtext version 2.2.1.v201112130541.

Thanks

Fero
Re: xbase generation exception [message #895597 is a reply to message #895571] Fri, 13 July 2012 17:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
hi

are you sure you have done your guice binding right?
do you use the
fragment = types.TypesGeneratorFragment {}
and fragment = xbase.XbaseGeneratorFragment {}

~Christian
>


--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xbase generation exception [message #895599 is a reply to message #895597] Fri, 13 July 2012 17:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
And can you share how you setup/guiceify your handler?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xbase generation exception [message #895828 is a reply to message #895599] Mon, 16 July 2012 08:41 Go to previous message
Frantisek Kocun is currently offline Frantisek KocunFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks Christian for answer

I changed guice binding to JdtTypeProviderFactory a it works! Is it ok this way? Btw. it is another plugin but runs in the same eclipse instance as the ui plugin.
public class PaternosterGenModule extends AbstractGenericModule
{

	private final AbstractUIPlugin plugin;

	public PaternosterGenModule(AbstractUIPlugin plugin)
	{
		this.plugin = plugin;
	}

	@Override
	public void configure(Binder binder)
	{
		super.configure(binder);

		binder.bind(AbstractUIPlugin.class).toInstance(plugin);
		binder.bind(IDialogSettings.class).toInstance(plugin.getDialogSettings());
	}

	public IWorkspaceRoot bindIWorkspaceRootToInstance()
	{
		return ResourcesPlugin.getWorkspace().getRoot();
	}
	
	public Class<? extends IResourceSetProvider> bindIResourceSetProvider()
	{
		return XtextResourceSetProvider.class;
	}
	
	public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
		return org.eclipse.xtext.common.types.access.jdt.JdtTypeProviderFactory.class;
	}
}
Previous Topic:Invalid property category path
Next Topic:This is a bug with the quikfix?
Goto Forum:
  


Current Time: Sun Feb 23 17:30:50 GMT 2020

Powered by FUDForum. Page generated in 0.01682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top