Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Referencing ecore primitive types in Xtend
Referencing ecore primitive types in Xtend [message #546006] Fri, 09 July 2010 20:59 Go to next message
Edwin Park is currently offline Edwin ParkFriend
Messages: 124
Registered: July 2009
Senior Member
Hi,

I'm trying to do some M2M transformation of an Xtext metamodel to Ecore using Xtend. But when I try to e.g. set the EType of an EAttribute to EDate:

create EAttribute eAttribute(Property property):
setEType(EDate);

It fails with "Couldn't find operation 'setEType(xpand2::Type)' for ecore::EAttribute". It turns out whenever I try referencing Ecore primitive types like EString, EBoolean, EDate, they are automaticaly translated into their Java equivalents (String, Boolean, java::util::Date).

Is there some way I can access the actual ecore::EDate type (or other ecore primitive types) so that I can set it in my EAttribute?

Thanks,
Edwin

Re: Referencing ecore primitive types in Xtend [message #546038 is a reply to message #546006] Sat, 10 July 2010 08:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello,

yes there is a way. e.g. use a JAVA Extension

package template;

import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EcorePackage;

public class Helper {
	
	public static EDataType getEDate() {
		return EcorePackage.Literals.EDATE;
	}

}


create ecore::EAttribute this getEAttr() :
	this.setEType(getEDate()) ->
	this.setName("attr");
	
ecore::EDataType getEDate() :
	JAVA template.Helper.getEDate();


Regards
Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing ecore primitive types in Xtend [message #546054 is a reply to message #546038] Sat, 10 July 2010 12:35 Go to previous message
Edwin Park is currently offline Edwin ParkFriend
Messages: 124
Registered: July 2009
Senior Member
Perfect! Thanks!
Previous Topic:[Xtend] Criterion for element equality in Xtend sets?
Next Topic:[Xtend] Using EEnum Literals within Xtend expressions
Goto Forum:
  


Current Time: Tue Apr 23 08:33:51 GMT 2024

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

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

Back to the top