Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Null when accessing reference from a linked metamodel([Acceleo] Null when accessing reference from a linked metamodel)
[Acceleo] Null when accessing reference from a linked metamodel [message #1854298] Thu, 11 August 2022 16:41 Go to next message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 34
Registered: August 2016
Member
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 #1854299 is a reply to message #1854298] Thu, 11 August 2022 17:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

(Assuming that "ModelB:Entity" is an irrelevant typo rather than an indication of widespread mistyping)

It seems likely that things are not as you expect, but since you do not provide us with any metamodels that might for instance allow us to examine "ref", it is very hard to say how your expectation is wrong.

It is possible that Acceleo's parsing is adrift; IIRC I sometimes found errors that could be worked around by more simpler steps. But I often find that my suspicion of tool problems often proves unsound after detailed investigation. Mistakes are easy but you give us no chance to help.

Regards

Ed Willink
Re: [Acceleo] Null when accessing reference from a linked metamodel [message #1854301 is a reply to message #1854299] Thu, 11 August 2022 18:49 Go to previous message
Oleg Cohen is currently offline Oleg CohenFriend
Messages: 34
Registered: August 2016
Member
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
Previous Topic:using a map/dictionary data structure with Acceleo
Next Topic:How to overwrite previously generated file?
Goto Forum:
  


Current Time: Fri Apr 26 14:23:04 GMT 2024

Powered by FUDForum. Page generated in 0.03048 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top