Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] More inheritance bugs?
[Acceleo] More inheritance bugs? [message #642377] Wed, 01 December 2010 05:44 Go to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
Hi Larurent:

I believe I may have run into another more serious bug. Before I spend the time to enter simplified code, I'll explain briefly and you can let me know if you've seen this and/or tested this scenario.

I have what should be a common scenario. There are two modules (say A and B) that extend a common base module C. Each of the two modules A and B override the same template T in the base module C.

What appears to be a bug is that I'm actually getting A's overridden T output in B instead of B's overridden T output.

Thanks,
Jeff
Re: [Acceleo] More inheritance bugs? [message #642387 is a reply to message #642377] Wed, 01 December 2010 07:35 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Jeff,

I tried several time but I couldn't reproduce your bug, I just have the normal result: click me

Could you explain a bit more (or take a screenshot like me) of the configuration that is creating your problem ?


Stephane Begaudeau, Obeo.



Re: [Acceleo] More inheritance bugs? [message #642497 is a reply to message #642387] Wed, 01 December 2010 15:33 Go to previous messageGo to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
Here's a boiled down version of the code. The generated code for edit gets the same execute body as the code for delete. Delete generates correctly. A workaround would be greatly appreciated.

[module main()/]

[template public mainTop(anItem : Item)]
	[comment @main /]
	[for (aDelete : Delete | anItem.menu.items->select(oclIsKindOf(Delete)))]
		[aDelete.Delete(anItem)/]
	[/for]
	[for (anEdit : Edit | anItem.menu.items->select(oclIsKindOf(Edit)))]
		[anEdit.Edit(anItem)/]
	[/for]
[/template]



[module Edit() extends MenuItemTemplate /]

[template public menuItemExecuteBody(anItem : Item) overrides menuItemExecuteBody]
	anItem.execute1(anItem.execute1);
[/template]

[template public Edit(e : Edit, anItem : Item)]
	[file ('/src/com/xyz/menuitems/'.concat(e.name.toUpperFirst().concat('.java')), false, 'Cp1252')]
		[menuItemMain(e,anItem)/]
	[/file]
[/template]



[module Delete() extends MenuItemTemplate/]

[template public Delete(d : Delete, anItem : Item)]
	[file ('/src/com/xyz/menuitems/'.concat(d.name.toUpperFirst().concat('.java')), false, 'Cp1252')]
		[menuItemMain(d,anItem)/]
	[/file]
[/template]

[template public menuItemExecuteBody(anItem : Item) overrides menuItemExecuteBody]
    execute2(an[anItem.name.toUpperFirst()/])
[/template]



[module MenuItemTemplate()/]

[template public menuItemTemplate(m : Item, anItem : Item)]
	[menuItemMain(m, anItem)/]
[/template]

[template public menuItemMain(m : Item, anItem : Item)]
	[menuItemPackage(anItem)/]
	[menuItemImports(anItem)/]
	[menuItemClass(m, anItem)/]		
[/template]

[template public menuItemClass(m : Item, anItem : Item)]
	public class [m.name.toUpperFirst()/] implements MenuItem {
		[menuItemExecuteMethod(anItem)/]
	}
[/template]

[template public menuItemPackage(anItem : Item)]
package com.xyz.[anItem.name.toLower()/].menuitems;
[/template]

[template public menuItemImports(anItem : Item)]
import com.xyz.[anItem.name.toLower()/].[anItem.name.toUpperFirst()/];
[/template]

[template public menuItemExecuteMethod(anItem : Item)]
	public void execute(final [anItem.name.toUpperFirst()/] an[anItem.name.toUpperFirst()/]) {
		[menuItemExecuteBody()/]
	}	
[/template]

[template public menuItemExecuteBody(anItem : Item)]
	error: unimplemented (by the way Acceleo team, it would be nice if there were language support for erroring here with an abstract keyword.)
[/template]

Re: [Acceleo] More inheritance bugs? [message #642521 is a reply to message #642497] Wed, 01 December 2010 16:24 Go to previous messageGo to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
Is this a misunderstanding of scope rules for inheritance? I am assuming that a module is akin to a class, and that when I override a template in one module, it shouldn't affect overrides in other modules.

If my assumption is wrong, please correct me.

Thanks!
Jeff
Re: [Acceleo] More inheritance bugs? [message #642623 is a reply to message #642521] Thu, 02 December 2010 03:11 Go to previous messageGo to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
I created a small project that demonstrates the bug/problem. You can get the files here.

Once you get everything built and you execute main.mtl, note that NameA.java ends up incorrectly having the line execute body:

I
temBExecute(anItemHolderName)

instead of

ItemAExecute(anItemHolderName)


Thanks!
Jeff
Re: [Acceleo] More inheritance bugs--Disregard [message #642633 is a reply to message #642623] Thu, 02 December 2010 05:13 Go to previous message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
Please disregard this problem. I think it was due to my misunderstanding of how inheritance works in Acceleo/MTL. I fixed the problem by adding the specialized Items: ItemA, ItemB to the parameter list of the problematic templates.

I think I was thinking of modules as similar to Java classes and expecting the overloading to work throughout the module automatically.

Thanks,
Jeff
Previous Topic:[Acceleo 3] Run transformation from java code
Next Topic:[Acceleo 3.1.0M3] install site.xml
Goto Forum:
  


Current Time: Sat Dec 20 09:51:16 GMT 2014

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

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