| [Acceleo] Problem when generating methods with the same name [message #1060130] |
Thu, 23 May 2013 05:06 |
Javier García Messages: 70 Registered: April 2013 |
Member |
|
|
Hi guys,
I recently run into some problems with my Acceleo transformation. It works mostly perfect, I transform an UML model into Java code and now I have in several classes two methods that have the same name, but different parameters (method overloading I believe it's called) and when Acceleo generates it, the weirdest thing happens, I get three methods generated. Now when I create the method I also copy any comments it has attached, so I can clearly see that one of the methods gets generated once, and the other method gets generated twice.
So why does this happen? does it get confused somehow due to both methods sharing the same name? is this a known bug?(I couldn't find any info). It's really the only case in which I get this error, every other method gets created just once.
I will just post here the code I use in case it's useful:
[template private operations(aClass : Class)]
[for (anOperation : Operation | aClass.getOperations()->union(aClass.getImplementedInterfaces().ownedOperation))]
/**
* The documentation of the method [anOperation.name.toLowerFirst()/].
*
[for (aParameter : Parameter | anOperation.ownedParameter) ? (aParameter.direction <> ParameterDirectionKind::return)]
* @param [aParameter.name/]
[/for]
[if (not anOperation.type.oclIsUndefined())]
* @return
[/if]
*
* @generated
*/
[anOperation.visibility/] [if (anOperation.type.oclIsUndefined())]void[else][anOperation.type.name/][/if] [anOperation.name.toLowerFirst()/]([anOperation.parameters()/]) {
//
/*
* This is the code from the former method:
* [for (aComment : Comment | anOperation.ownedComment)] [aComment._body/][/for]
*/
// TODO should be implemented
[if (anOperation.type.oclIsUndefined())]//return null;[else][/if] [comment it should be not anOperation... but for some reason it doesn't work properly if we do it that way. /]
//
}
[/for]
[/template]
Thanks in advance,
regards,
Javier
|
|
|
Powered by
FUDForum. Page generated in 0.01636 seconds