[Acceleo] More inheritance bugs? [message #642377] |
Wed, 01 December 2010 00:44  |
Eclipse User |
|
|
|
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 #642497 is a reply to message #642387] |
Wed, 01 December 2010 10:33   |
Eclipse User |
|
|
|
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--Disregard [message #642633 is a reply to message #642623] |
Thu, 02 December 2010 00:13  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04445 seconds