Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Unexpected inheritance behavior
[Acceleo] Unexpected inheritance behavior [message #641792] Sun, 28 November 2010 05:56 Go to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
I was able to successfully use the inheritance mechanism initially, but have run into some unexpected behavior.

If I try to create a template that looks like this, everything works as expected.

[module a extends b]
[template public ItemActivity(i : ItemActivity) overrides Activity]
	[file ('/src/abc/'.concat(i.name.concat('.java')), false, 'Cp1252')]
		[doOtherTemplateStuff(i)/]
	[/file]
[/template]
[template public doOtherTemplateStuff(i : ItemActivity) overrides doOtherTemplateStuff]
   [super/]
   xyzzy1
[/template]
[/module]

[module b]
[template public Activity(a : Activity)]
	[doOtherTemplateStuff(a)/]
[/template]
[template public doOtherTemplateStuff(a : Activity)]
   [super/]
   xyzzy2
[/template]
[/module]


If on the other hand I do this (changing [doOtherTemplateStuff(i)/] to [super/]:

[module a]
[template public ItemActivity(i : ItemActivity) overrides Activity]
	[file ('/src/abc/'.concat(i.name.concat('.java')), false, 'Cp1252')]
		[super/]
	[/file]
[/template]

[template public doOtherTemplateStuff(i : ItemActivity) overrides doOtherTemplateStuff]
   [super/]
   xyzzy1
[/template]
[/module]

[module b]
[template public Activity(a : Activity)]
	[doOtherTemplateStuff(a)/]
[/template]
[/module]

[template public doOtherTemplateStuff(a : Activity)]
   xyzzy2
[/template]
[/module]


then I get no output. What am I missing?

Thanks!
Jeff

[Updated on: Mon, 29 November 2010 19:11]

Report message to a moderator

Re: [Acceleo] Unexpected inheritance behavior [message #641906 is a reply to message #641792] Mon, 29 November 2010 08:36 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Jeff,

To override a template, you have to have : your module "extends" another module and your template "overrides" another template ... your examples mix these in randomly, I believe these problems are typos but :

- your "module b" has a template that overrides another even though the module itself doesn't extend any module.
- your second "module a" doesn't have an extends clause even though its templates try and overrides template from b.

That being said, I don't know what a "super" call nested in a file block would do. If you do have the "extends" and "overrides" clauses right, then we most likely have a bug with this "super" nesting. Could you rise a bug in such a case?

Laurent Goubet
Obeo
Re: [Acceleo] Unexpected inheritance behavior [message #642093 is a reply to message #641906] Mon, 29 November 2010 19:07 Go to previous messageGo to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
Thanks as always for the prompt response. I apologize for the hastily typed example; I did make a typo and will edit it for future readers. It's module a that extends module b, and module b's template shouldn't have an overrides statement.

I will file a bug for this. I would think this is a common use case, or am I missing something? How else would you capture common behavior that spans multiple files/paths?

I had been suspecting that the problem was that I wasn't able to pass the "i" ItemActivity parameter in the super call that is expecting Activity. (ItemActivity specializes Activity if this wasn't already obvious.) Is the parameter implicitly passed anyhow?

Thanks,
Jeff
Re: [Acceleo] Unexpected inheritance behavior [message #642169 is a reply to message #642093] Tue, 30 November 2010 08:27 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050806010707060003020506
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Jeff,

I must admit the calls to "super" aren't something that have been
thoroughly tested. I cannot test ATM and do not remember exactly the
code behind these ... thus my requesting that you file a bug :p.

There is a possibility the problem lies in the arguments passed to
"super"... but I'll have to check the code before answering for sure.

Laurent Goubet
Obeo

On 29/11/2010 20:07, glenviewjeff wrote:
> Thanks as always for the prompt response. I apologize for the hastily
> typed example; I did make a typo and will edit it for future readers.
> It's module a that extends module b, and module b's template shouldn't
> have an overrides statement.
> I will file a bug for this. I would think this is a common use case, or
> am I missing something? How else would you capture common behavior that
> spans multiple files/paths?
>
> I had been suspecting that the problem was that I wasn't able to pass
> the "i" ItemActivity parameter in the super call that is expecting
> Activity. (ItemActivity specializes Activity if this wasn't already
> obvious.) Is the parameter implicitly passed anyhow?
> Thanks,
> Jeff


--------------050806010707060003020506
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------050806010707060003020506--
Previous Topic:[Acceleo] Acceleo as standalone
Next Topic:[Xpand] EXPAND problem
Goto Forum:
  


Current Time: Thu Apr 25 01:37:29 GMT 2024

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

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

Back to the top