Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Disambiguate class reference
[Acceleo] Disambiguate class reference [message #1806427] Wed, 08 May 2019 22:00 Go to next message
Michaël Melchiore is currently offline Michaël MelchioreFriend
Messages: 47
Registered: April 2012
Member
Hello,

I am currently writing an Acceleo (3.5.2) template where one of my input metamodel has a class named "Collection".

In the following template, the Acceleo compiler tags underlined text with the error ""Collection" unexpected token(s)"

[template public generateElement(aCollection : CollectionEntity) {
target : Collection = aCollection.referencedElement.oclAsType(Collection);
}]

I think this error is weird since my syntax is valid. Replacing "Collection" with any other classes from my input metamodels does remove the error.
So, I think there is somekind of name conflict here, perhaps with OCL own "Collection" ?

Do you know a way to solve of workaround this issue ?
I cannot change the input metamodel.

Kind regards,

Michaël




Re: [Acceleo] Disambiguate class reference [message #1806432 is a reply to message #1806427] Thu, 09 May 2019 04:34 Go to previous messageGo to next message
Adriano Carvalho is currently offline Adriano CarvalhoFriend
Messages: 54
Registered: November 2018
Member
Did you try prefixing"Collection" with the metamodel name?

I don't know Acceleo's syntax but should be something like "metamodel_name.Collection" (where "." may also be "::" or "!*).
Re: [Acceleo] Disambiguate class reference [message #1806437 is a reply to message #1806432] Thu, 09 May 2019 06:52 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

While "Collection" is not a reserved word in OCL, it is built-in to the grammar; it is therefore referred to as a restricted name. These can be used with care. Package qualification as suggested earlier should work. If the context is clear the old ("_Collection") or new ("_'Collection'") style of escaping may also work. If you are unlucky you may need both: PackageName::_'Collection'.

Regards

ED Willink

[Updated on: Thu, 09 May 2019 11:09]

Report message to a moderator

Previous Topic:a difficult query to solve
Next Topic:M2T Ecore2XML / Ecore2JSON Tutorial/Guide/Help
Goto Forum:
  


Current Time: Mon Dec 02 21:16:11 GMT 2024

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

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

Back to the top