Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext and EMF Dynamic Templates
Xtext and EMF Dynamic Templates [message #1705541] Mon, 17 August 2015 12:44
Thorsten Koch is currently offline Thorsten KochFriend
Messages: 4
Registered: June 2013
Junior Member
Hello everybody,

I have created a Xtext grammar and wanted to customize the generation process of the model code by means of the dynamic template approach of EMF. Therefore, I have adopted a JET template and created a subclass of the EMFGeneratorFragment. The source code of the CustomEMFGeneratorFragment is shown below.

public class CustomEMFGeneratorFragment extends EMFGeneratorFragment {
	
	String TEMPLATE_FILE_STRING = "";

	@Override
	protected void doGenerate(final GenModel genModel) {
		genModel.setDynamicTemplates(true);
		genModel.setTemplateDirectory(TEMPLATE_FILE_STRING);
		genModel.setCanGenerate(true);

		try {
			EMFSupport.saveResource(genModel.eResource());
		} catch(IOException e) {
			e.printStackTrace();
		}
		super.doGenerate(genModel);
	}
}


If I execute the Xtext workflow, the dynamicTemplate attribute as well as the templateDirectory attribute of the resulting genmodel are set correctly, however the generated source files are completely empty.

If I manually start the model generation by means of the *.genmodel, everything works as expected.

My question is whether Xtext does not support the usage of dynamic templates or if I missed something.

Thanks in advance.
Previous Topic:Grammer Help Needed
Next Topic:DI problem with EmbeddedEditor
Goto Forum:
  


Current Time: Thu Apr 25 11:45:38 GMT 2024

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

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

Back to the top