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 16:59 Go to next message
Edwin Park is currently offline Edwin Park
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 04:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6128
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
Re: Referencing ecore primitive types in Xtend [message #546054 is a reply to message #546038] Sat, 10 July 2010 08:35 Go to previous message
Edwin Park is currently offline Edwin Park
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: Thu Jul 24 11:31:07 EDT 2014

Powered by FUDForum. Page generated in 0.01794 seconds