Hello,
are there plans to allow covariant return types on overridden mappings in a future version of the QVTO engine? The standard is not clear if this is allowed. It says "each parameter of the overriding operation should comply with the type of the corresponding parameter in the overridden operation".
That would allow this transformation:
modeltype UML "strict" uses uml('http://www.eclipse.org/uml2/3.0.0/UML');
transformation utp2testing(in i:UML, out o:UML);
abstract mapping NamedElement::transform(): NamedElement {
name := self.name;
}
mapping Package::transform() : Package
inherits NamedElement::transform {
}
mapping Model::transform() : Model
inherits Package::transform {
}
main() {
i.rootObjects()[Package]->transform()
}
So if the root object is a "UML::Model" the transform mapping will create a "UML::Model" with the name property set and return it as a "UML::Package" (which is the superclass of "UML::Model") to the main method.
Right now I have to write something like this:
modeltype UML "strict" uses uml('http://www.eclipse.org/uml2/3.0.0/UML');
transformation utp2testing(in i:UML, out o:UML);
abstract mapping NamedElement::transform(): NamedElement {
name := self.name;
}
mapping Package::transform() : NamedElement
inherits NamedElement::transform{
init {
result := object Package{}
}
}
mapping Package::toPackage() : Package {
result := self-> map transform()![Package]
}
mapping Model::transform() : NamedElement
inherits Package::transform{
init {
result := object Model{}
}
}
mapping Model::toModel() : Model {
result := self-> map transform()![Model]
}
main() {
i.rootObjects()[Package]->map toPackage()
}
Update:
The code above produces additional objects, because the init-sections of the inherited mappings are also invoked. Is this the intended behavior?
BTW: Is it possible to get an indicator on the side of the editor showing that a mapping overrides another one?
Thanks in advance,
Max
[Updated on: Thu, 29 April 2010 14:28]
Report message to a moderator