[Acceleo] Dependency on a Reusable Base Generator not Working [message #1799566] |
Mon, 10 December 2018 11:45 |
Thomas Pusztai Messages: 27 Registered: September 2018 |
Junior Member |
|
|
Hi,
I'm trying to write some code generators using Acceleo 3.7.5. for generating code from UML models. I started with one generator that generates Java code, which went very well. However, I now need to be able to support generators for multiple target languages.
My idea is to create a base generator, which contains the general procedure that iterates over the model and calls various Acceleo modules to generate code for the UML model elements. In the base generator these modules are empty, but in a generator for a specific language I would use dynamic template overriding to generate code for the respective target language.
I started by setting up the base generator project and moving the Java services and the associated Acceleo queries there. I then set up the code generator project for the Java language to use the base generator as a dependency and be able to override templates, as described on this Acceleo documentation page in the secion "Additional Concepts -> Dynamic Overriding".
When I try to run the Java generator now, I always get multiple exceptions like the following:
!ENTRY org.eclipse.acceleo.engine 2 2 2018-12-10 12:02:22.894
!MESSAGE Unresolved compilation error, expression was null.
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Unresolved compilation error, expression was null.
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1895)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:1049)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoQueryInvocation(AcceleoEvaluationVisitor.java:880)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1951)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:1049)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoForBlock(AcceleoEvaluationVisitor.java:448)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1922)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:1049)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoTemplate(AcceleoEvaluationVisitor.java:922)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1906)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:1049)
at org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(QueryImpl.java:146)
at org.eclipse.ocl.ecore.QueryImpl.evaluate(QueryImpl.java:56)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.doEvaluate(AcceleoEngine.java:365)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.evaluate(AcceleoEngine.java:142)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerateTemplate(AcceleoService.java:984)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate(AcceleoService.java:641)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:209)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:172)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.doGenerate(AbstractAcceleoGenerator.java:159)
at master.thesis.architecture.fog.uml.gen.java.main.FogUml2Java.doGenerate(FogUml2Java.java:202)
at JavaCodeGenerator.ui.common.GenerateAll.doGenerate(GenerateAll.java:81)
at JavaCodeGenerator.ui.popupMenus.AcceleoGenerateCodeGeneratorAction$1.run(AcceleoGenerateCodeGeneratorAction.java:78)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
!ENTRY org.eclipse.acceleo.engine 2 2 2018-12-10 12:02:22.905
!MESSAGE Invalid loop iteration at line 54 in Module fogUml2Java for block for (unresolved query invocation : null()). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.ModelImpl@5d31e0c6 (name: HealthCare, visibility: <unset>) (URI: null) (viewpoint: <unset>).
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 54 in Module fogUml2Java for block for (unresolved query invocation : null()). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.ModelImpl@5d31e0c6 (name: HealthCare, visibility: <unset>) (URI: null) (viewpoint: <unset>).
at fogUml2Java.main(Model)(fogUml2Java.mtl:54)
at fogUml2Java.main(Model)(fogUml2Java.mtl:50)
Line 54 in the fogUml2Java module, which is mentioned in the stack trace, calls the getAllModelClasses() query that I have moved to the base generator project:
[for (modelClass : Class | fogModel.getAllModelClasses())]
[modelClass.genModelClassJavaFile()/]
[/for]
I have updated the module import statement correctly after creating the base generator and I'm also able to navigate to the query by Ctrl+Clicking it. I've tried running the Java generator in three different ways, but the result was always basically the same:
- BaseGenerator and JavaGenerator in the Eclipse development instance and running the JavaGenerator using "Run As -> Launch Acceleo Application".
- BaseGenerator deployed in an Eclipse runtime instance, which has the JavaGenerator project open and running the JavaGenerator using "Run As -> Launch Acceleo Application".
- Base Generator, JavaGenerator, and an Acceleo UI Launcher for the JavaGenerator deployed in an Eclipse runtime instance and running the JavaGenerator using the UI launcher.
How can I fix this problem, such that the JavaGenerator will find the BaseGenerator dependency?
Best regards,
Thomas
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03959 seconds