Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Covariant return type on overridden mapping?
[QVTO] Covariant return type on overridden mapping? [message #530335] Thu, 29 April 2010 12:22
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
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

Previous Topic:[QVTo] NEW BUG: Accessing an extended transformation with configuration property cannot resolve that
Next Topic:[QVTO] Setting tagged value that is a multivalue
Goto Forum:
  


Current Time: Mon Oct 14 16:20:50 GMT 2019

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

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

Back to the top