[Acceleo] Null when accessing reference from a linked metamodel [message #1854298] |
Thu, 11 August 2022 12:41  |
Eclipse User |
|
|
|
Greetings,
I am new to Acceleo and I am facing the following issue when a template deals with two related metamodels.
I am running generation as a standalone Java program.
Here is what I have:
Metamodel A:
EObject: Model -> as controller of type EObject: Controller -> as ref of type EObject: Entity (from Model B)
Metamodel B:
EObject: Entity
I include both metamodels:
[module generate('http://www.acme.org/ModelA', 'http://www.acme.org/ModelB')]
The main EObject that is passed into the template is of type Model
[template public generateElement(model : ModelA::Model)]
...
When call
[let name : String = model.controller.ref.name]
I get the following error:
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined "Let" expression at line 8 in Module generate for block let name : String = model.controller.ref.null.
At the same time, the following two ways work:
1. I pass a reference to Entity separately in the arguments and make the call to be:
[template public generateElement(model : ModelA::Model, entity: ModelB:Entity)]
where entity is the same model.controller.ref
then the following works well:
[let name : String = entity.name]
2. I still pass one EObject into the template. I define ref first:
[let entity : Entity = model.controller.ref.oclAsType(Entity)] and then
[let name : String = entity.name]
and this works just fine.
So the question on this second option why two step operation works fine, but accessing the ref's name attribute directly as model.controller.ref.name fails?
Thank you!
Oleg
|
|
|
|
Re: [Acceleo] Null when accessing reference from a linked metamodel [message #1854301 is a reply to message #1854299] |
Thu, 11 August 2022 14:49  |
Eclipse User |
|
|
|
Hi Ed,
Thank you for your reply. I went ahead and made a simple two metamodel cross-reference example and all actually worked. So, I have narrowed down to at least the referenced model somehow being wrongly defined or improperly packaged.
So, this is not an Acceleo project.
I should have done better on isolation the issue.
Thanks again,
Oleg
|
|
|
Powered by
FUDForum. Page generated in 0.04957 seconds