Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How can I use JvmModelInferrer and old Generator approach in parallel(I want to generate some classes using the JvmModelInferrer and some plain files using the old generator approach in one project)
How can I use JvmModelInferrer and old Generator approach in parallel [message #1690899] Tue, 31 March 2015 20:00 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
How do I have to configure my Xtext project to enable the use of JvmModelInferrer and the old generator parallel in one project ?

I already have the following in my mwe2-File:
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
                ...
    		// provides the necessary bindings for java types integration
    		fragment = types.TypesGeneratorFragment auto-inject {}
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {}
    		
    		// generates the required bindings only if the grammar inherits from Xtype
    		fragment = xbase.XtypeGeneratorFragment auto-inject {}


The basic generator class does get generated but it is not called when I save my model.
What is wrong ?
Re: How can I use JvmModelInferrer and old Generator approach in parallel [message #1690900 is a reply to message #1690899] Tue, 31 March 2015 20:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
Hi,

the jvmmodelinferrer uses its own igenerator: jvmmodelgenerator. thus you should subclass jvmmodelgenerator


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How can I use JvmModelInferrer and old Generator approach in parallel [message #1690942 is a reply to message #1690899] Wed, 01 April 2015 06:43 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 747
Registered: July 2009
Location: Dortmund, Germany
Senior Member

or create another IGenerator as generator root, inject the JvmModelGenerator and dispatch to it and the other templates.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: How can I use JvmModelInferrer and old Generator approach in parallel [message #1690982 is a reply to message #1690942] Wed, 01 April 2015 12:15 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Karsten Thoms wrote on Wed, 01 April 2015 02:43
or create another IGenerator as generator root, inject the JvmModelGenerator and dispatch to it and the other templates.


I created my own IGenerator implementation:
class IGeneratorRoot implements IGenerator {
	
	@Inject
	JvmModelGenerator jvmModelGenerator
	
	@Inject
	ContentProviderGenerator contentProviderGenerator
	
	 
	override doGenerate(Resource input, IFileSystemAccess fsa) {
		jvmModelGenerator.doGenerate(input, fsa)
		contentProviderGenerator.doGenerate(input, fsa)
	}
}

and added this to my RuntimeModule:
public Class<? extends ContentProviderGenerator> bindContentProviderGenerator() {
	return ContentProviderGenerator.class;
}

@SuppressWarnings("restriction")
public Class<? extends JvmModelGenerator> bindJvmModelGenerator() {
	return JvmModelGenerator.class;
}

@Override
public Class<? extends IGenerator> bindIGenerator() {
	return IGeneratorRoot.class;
}


but I get the following error:
1496 [Worker-2] ERROR org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder  - The source element must be contained in a resource
java.lang.IllegalArgumentException: The source element must be contained in a resource
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.isValidSource(JvmTypesBuilder.java:651)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.associate(JvmTypesBuilder.java:642)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toParameter(JvmTypesBuilder.java:823)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer.lambda$8(ContentProviderJvmModelInferrer.java:300)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer$$Lambda$15/1169816667.apply(Unknown Source)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.initializeSafely(JvmTypesBuilder.java:208)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toMethod(JvmTypesBuilder.java:689)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer.lambda$0(ContentProviderJvmModelInferrer.java:320)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer$$Lambda$1/1722450363.apply(Unknown Source)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.initializeSafely(JvmTypesBuilder.java:208)
	at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toClass(JvmTypesBuilder.java:386)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer._infer(ContentProviderJvmModelInferrer.java:323)
	at de.mdsd.xtext.android.contentprovider.jvmmodel.ContentProviderJvmModelInferrer.infer(ContentProviderJvmModelInferrer.java:329)
	at org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:382)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:227)
	at org.eclipse.xtext.xbase.resource.BatchLinkableResource.getContents(BatchLinkableResource.java:148)
	at org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver.getEntryPoints(LogicalContainerAwareBatchTypeResolver.java:44)
	at org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver.getTypeResolver(DefaultBatchTypeResolver.java:63)
	at org.eclipse.xtext.xbase.typesystem.internal.CachingBatchTypeResolver$1.get(CachingBatchTypeResolver.java:49)
	at org.eclipse.xtext.xbase.typesystem.internal.CachingBatchTypeResolver$1.get(CachingBatchTypeResolver.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:77)
	at org.eclipse.xtext.xbase.typesystem.internal.CachingBatchTypeResolver.doResolveTypes(CachingBatchTypeResolver.java:46)
	at org.eclipse.xtext.xbase.typesystem.internal.AbstractBatchTypeResolver.resolveTypes(AbstractBatchTypeResolver.java:69)
	at org.eclipse.xtext.xbase.resource.BatchLinkingService.resolveBatched(BatchLinkingService.java:64)
	at org.eclipse.xtext.xbase.resource.BatchLinkableResource.resolveLazyCrossReferences(BatchLinkableResource.java:165)
	at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:522)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.postParse(XtextDocumentReconcileStrategy.java:174)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.doReconcile(XtextDocumentReconcileStrategy.java:152)
	at org.eclipse.xtext.ui.editor.reconciler.XtextDocumentReconcileStrategy.reconcile(XtextDocumentReconcileStrategy.java:66)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.doRun(XtextReconciler.java:445)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.access$3(XtextReconciler.java:425)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:366)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler$1.process(XtextReconciler.java:1)
	at org.eclipse.xtext.util.concurrent.IUnitOfWork$Void.exec(IUnitOfWork.java:37)
	at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:121)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.modify(XtextDocument.java:428)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.internalModify(XtextDocument.java:162)
	at org.eclipse.xtext.ui.editor.reconciler.XtextReconciler.run(XtextReconciler.java:363)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


I guess there is something wrong with the injection.
Re: How can I use JvmModelInferrer and old Generator approach in parallel [message #1690988 is a reply to message #1690982] Wed, 01 April 2015 12:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
I dont think so can comment the call of your generator out and retry. Maybe you have an error in your inferrer as well

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How can I use JvmModelInferrer and old Generator approach in parallel [message #1691018 is a reply to message #1690982] Wed, 01 April 2015 15:17 Go to previous message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
Sorry it was an error in my ModelInferrer code.
Previous Topic:xtext project creation programmatically
Next Topic:Generate a static initializer with JvmModelInferrer
Goto Forum:
  


Current Time: Sun Apr 18 21:28:42 GMT 2021

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

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

Back to the top