[Acceleo] Problem calling AcceleoService programatically [message #1020941] |
Tue, 19 March 2013 08:26 |
Marc Schlegel Messages: 69 Registered: July 2009 |
Member |
|
|
Hello everyone,
I am going to hold a little informal presentation for my company about M2T-Generators. Since I only used xText with xPand, I thought it would be a good idea to show some alternatives as well so I dove into Acceleo yesterday.
I think I got everything setup, but there must be still a little mistake. I created a project with the mtl-files and a Workflow-class (AbstractAcceleoGenerator) which is exported. The project is included in my ECore-Editor-project and the Command is calling the workflow.
I attached my template-modules, and this is how I call the Generator
Workflow wf = new Workflow(
URI.createFileURI(editorInput.getFullPath().toString()),
folder.getFullPath().toFile(),
Collections.emptyList());
wf.doGenerate(new BasicMonitor());
But nothing happens...so I debugged into it. Withing the AcceleoService#doGenerate there is a loop which traverses over my ECore-Model
while (targetElements.hasNext()) {
final EObject potentialTarget = targetElements.next();
if (argumentType.isInstance(potentialTarget)) {
final List<Object> actualArguments = new ArrayList<Object>();
actualArguments.add(potentialTarget);
actualArguments.addAll(arguments);
previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot,
monitor));
generationHasOccurred = true;
}
}
This is the problem
if (argumentType.isInstance(potentialTarget))
because it is never true.
argumentType is always EClassifier whereas potentialTarget is a Class from my ECore (which seems correct to me). So I guess I have to tell Acceleo that the starting-point is a of a certain type from my model (in this case DTOs).
Can someone help me out please and show me what I am missing?
Thanks
|
|
|
|
|
Re: [Acceleo] Problem calling AcceleoService programatically [message #1021661 is a reply to message #1021162] |
Wed, 20 March 2013 13:26 |
|
Hi,
ArgumentType should be the type of the parameter of your main template, the potential target is an element of your model. We first try with the root of your model and then we all its content:
// The input model itself is a potential argument
if (argumentType.isInstance(model)) {
final List<Object> actualArguments = new ArrayList<Object>();
actualArguments.add(model);
actualArguments.addAll(arguments);
previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot, monitor));
generationHasOccurred = true;
}
final TreeIterator<EObject> targetElements = model.eAllContents();
while (targetElements.hasNext()) {
final EObject potentialTarget = targetElements.next();
if (argumentType.isInstance(potentialTarget)) {
final List<Object> actualArguments = new ArrayList<Object>();
actualArguments.add(potentialTarget);
actualArguments.addAll(arguments);
previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot, monitor));
generationHasOccurred = true;
}
}
With the ecore tree that you have described, for some reasons this "argumentType.isInstance(model)" returns false. What version of Acceleo are you using and where is your meta-model located (in another project in the workspace, in a plug-in)?
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks
|
|
|
|
Powered by
FUDForum. Page generated in 0.03768 seconds