Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Extending template with dynamic overriding and class inheritance
[Acceleo] Extending template with dynamic overriding and class inheritance [message #879652] Thu, 31 May 2012 15:34 Go to next message
Michaël Melchiore is currently offline Michaël MelchioreFriend
Messages: 47
Registered: April 2012
Member
Hi,

I have been experimenting with template dynamic overriding for a few days. It is a very convenient feature that was worth switching to Acceleo 3 for.

Yet, there is one case I cannot make to work :

Metamodels
Metamodel MM1
-- Package mm1
-- -- Class ModelRoot --containing C1 and C2 instances--
-- -- Class C1
-- -- Class C2

Metamodel MM2
-- Package mm2
-- -- Class RandomClass
-- -- Package addon
-- -- -- Class C3 extends C1
-- -- -- Class C4 extends C2


Acceleo
Module M1 based on MM1
template T0(ModelRoot) --main template=entry point
template T1(C1, String, String) --called by T0
template T2(C2, String, String) --called by T0

Module M2 extending module M1 and based on MM1 and MM2
template T1(C3, String, String) overriding T1
template T2(C4, String, String) overriding T2


MM2 and M2 are part of an addon that can specialize the output of M1 generator for some specific instances of C1 and C2. To do so, the addon features a M2M transformation that processes ModelRoot and replaces targeted instances of C1 and C2 with instances of C3 and C4. Then, M2 provides overriding versions of T1 for those specific classes.

This works... mostly. For a reason that still escapes me, T1(C3) is never activated while T2(C4) is. The editor does show the following error:

template T1(C3, String, String) overriding T1
                                           ^^
                                           No public template 'T1' found.


If I replace C3 with C1, the error disappears. This seams to indicate that C3 is not recognized as a subclass of C1. This is strange since the editor let me access inherited C1 attributes from the template body !

I cannot send the project I am working on. Worse, I have been unable to reproduce the behavior on an example. Could you guys have directions as to where I should investigate ?

Michaël


Edit: I am using Acceleo 3.2.1.v20120511-0335 with Eclipse 3.6.2.M20110210-1200

[Updated on: Fri, 01 June 2012 06:50]

Report message to a moderator

Re: [Acceleo] Extending template with dynamic overriding and class inheritance [message #885101 is a reply to message #879652] Tue, 12 June 2012 13:22 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

I would use the following code:
template T1(C1, String, String) overriding T1 ? (C1.oclIsKindOf(C3))


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] Extending template with dynamic overriding and class inheritance [message #885711 is a reply to message #885101] Wed, 13 June 2012 13:17 Go to previous messageGo to next message
Michaël Melchiore is currently offline Michaël MelchioreFriend
Messages: 47
Registered: April 2012
Member
I have done the following

template T1(C1, String, String) overriding T1 ? (C1.oclIsKindOf(C3))
[let aC3instance : C3 = C1.oclAsTypeOf(C3)

##### Use aC3instance everywhere ######

[/let]


This does solve my problem, thank you. But, is it a workaround or is the syntax I used in my example illegal ?

Regards,

Michaël
Re: [Acceleo] Extending template with dynamic overriding and class inheritance [message #890131 is a reply to message #885711] Thu, 21 June 2012 08:43 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

template T1(C3, String, String) overriding T1
                                           ^^
                                           No public template 'T1' found.


If I remember correctly, we are requiring that the overriding template has the same signature as the overridden template.


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Previous Topic:[Ant/Xpand]problem with mwe script that uses xpt script
Next Topic:[JET]
Goto Forum:
  


Current Time: Thu Apr 25 19:24:31 GMT 2024

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

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

Back to the top