[Acceleo] Problem calling AcceleoService programatically [message #1020941] |
Tue, 19 March 2013 04:26  |
Eclipse User |
|
|
|
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 09:26   |
Eclipse User |
|
|
|
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
|
|
|
Re: [Acceleo] Problem calling AcceleoService programatically [message #1021749 is a reply to message #1021661] |
Wed, 20 March 2013 12:05  |
Eclipse User |
|
|
|
Stephane Begaudeau wrote on Wed, 20 March 2013 09:26What version of Acceleo are you using and where is your meta-model located (in another project in the workspace, in a plug-in)?
Hi, I am using the Juno-ReleaseTrain-Version: 3.3.2
But your point about the plugin-structure might be the right hint. This is how it looks
- simplegenerator (here is the ecore and the generated Java-model-classes)
- simplegenerator.edit
- simplegenerator.editor (from here I call Acceleo -> dependecy on simplegenerator.acceleo)
- simplegenerator.acceleo
Still, when I add a dependency to simplgenerator for simplegenerator.acceleo I still have the same problem.
I attached my little testproject. I hold the presentation today so it is not important any more, but still I´d like to solve the issue to dive deeper into the framework.
|
|
|
Powered by
FUDForum. Page generated in 0.31022 seconds