Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Sun Jul 06 21:25:23 EDT 2025

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

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

Back to the top