Xtext and EMF Dynamic Templates [message #1705541] |
Mon, 17 August 2015 12:44 |
Thorsten Koch 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.
|
|
|
Powered by
FUDForum. Page generated in 0.02993 seconds