Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Second GeneratorFragment
Second GeneratorFragment [message #754366] Wed, 02 November 2011 11:01 Go to next message
jan.loebel is currently offline jan.loebelFriend
Messages: 2
Registered: November 2011
Junior Member
Hi there,

I want to include a second generator for my domain specific language. I have tried to copy the generated MyDSLGeneratorWME.mwe2 and the MyDslGenerator.xtend to a new package and renamed both files from "MyDSL" to "Another". After that I wrote a new Class to override the injection of guice.

New Class:
package org.xtext.example.mydsl.generator.another;

import org.xtext.example.mydsl.MyDslRuntimeModule;
import org.xtext.example.mydsl.MyDslStandaloneSetup;

import com.google.inject.Guice;
import com.google.inject.Injector;

public class AnotherInjector extends MyDslStandaloneSetup {

	public Injector createInjector() {
		return Guice.createInjector(new AnotherRuntimeModule());
	}
	
	public class AnotherRuntimeModule extends MyDslRuntimeModule {
		@Override
		public Class<? extends org.eclipse.xtext.generator.IGenerator> bindIGenerator() {
			return AnotherGenerator.class;
		}
	}	
}


Then I changed the AnotherGeneratorMWE.mwe2-file and replaced "register = org.xtext.example.mydsl.MyDslStandaloneSetup {}" by "register = another.AnotherInjector {}".

But when I run the MWE2-File it starts the normal Generator and not the "AnotherGenerator.class". Is there any other way to use a second generator?

Thanks for your help!
Best regards,
Jan
Re: Second GeneratorFragment [message #754375 is a reply to message #754366] Wed, 02 November 2011 11:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

no this is the way it should work - and it works for me. did you do a clean build on the project before calling the workflow?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Second GeneratorFragment [message #754376 is a reply to message #754375] Wed, 02 November 2011 11:34 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

did you also rename the module within the mwe2-file (first line usually). If not, there may now be two modules with the same name in the index and when running MWE2 the wrong one is used.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Second GeneratorFragment [message #754379 is a reply to message #754366] Wed, 02 November 2011 11:42 Go to previous message
jan.loebel is currently offline jan.loebelFriend
Messages: 2
Registered: November 2011
Junior Member
Smile Thanks, I missed to rename the first line of the mwe2-file. Thanks a lot!
Previous Topic:Xtext doesn't generate files in <proj_name>.impl and <proj_name>.util
Next Topic:Problem serializing valid file content with expression
Goto Forum:
  


Current Time: Thu Apr 25 09:51:29 GMT 2024

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

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

Back to the top