| lazy rule doesn't return class [message #896645] |
Thu, 19 July 2012 05:34  |
Martin Benedict Messages: 22 Registered: June 2012 |
Junior Member |
|
|
Hello,
I'm working with lazy rules and currently I try to solve an issue on return types of lazy rules. I have defined a lazy rule that contains a do block. See code sample.
lazy rule DataTypeTransformation {
from
dt: HL7!HL7GenericDataType
using {
titled: UML!Stereotype = thisModule.getStereotype('titled');
dtpackage: UML!Package = UML!Package.allInstancesFrom('OUT') -> select(n | n.name = 'Datatypes').first();
}
to
cl: UML!Class (
name <- dt.baseType.name
)
do {
thisModule.debug('processing datatype ' + dt.baseType.name);
cl.applyStereotype(titled);
thisModule.knownDatatypes.put(dt.baseType.name, cl);
dtpackage.packagedElement.add(cl);
cl;
}
}
the calling code is the following:
type <- if (thisModule.knownDatatypes.get(p.type.baseType.name).oclIsUndefined()) then
thisModule.DataTypeTransformation(p.type.debug('create datatype ' + p.type.baseType.name ))
else
thisModule.getClass(p.type.baseType.name.debug('class exists ') + p.type.baseType.name)
endif
The problem I have is, that the lazy rule doesn't return the UML-class (cl). The type property of the attributes do not contain any class. If I remove the do block it works.
I have searched for a solution and found this: http://wiki.eclipse.org/ATL_Language_Troubleshooter#ATL_Called_Rules_Troubles.
I've added cl at the end of the do block, but this doesn't change anything. Are do blocks in lazy rules not allowed? Is the problem, that I add the class to dtpackage? How could I resolve this issue. I have to add the classes to the dtpackage, but only those that are refernced as type in a class.
It would be very nice, if there are some advices?
Thank You,
Martin
[Updated on: Thu, 19 July 2012 06:19] Report message to a moderator
|
|
|