Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » compile operation
compile operation [message #1734387] Tue, 07 June 2016 19:24
Parisa Moosavi is currently offline Parisa MoosaviFriend
Messages: 81
Registered: June 2015

I have developed a method for loading Xcore and create a ecore file. while I needed to generate ecore file from xcore file programatically I have used doGenerate method of a DSL which I developed in Xtext and through saving I can save ecore file. But because in generated ecore file the body of method was not saved I thought to user a xtend class and which simulate the xcore doGenerator to have the body of operation in ecore file. but I see an error.
	public static void Xcore2Ecore(URI sourcename, URI targetname, IFileSystemAccess fsa) {
		try {

			ResourceSet localResourceSet = new ResourceSetImpl();
			if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) {
				Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
			if (!EPackage.Registry.INSTANCE.containsKey(EcorePackage.eNS_URI)){
			if (!EPackage.Registry.INSTANCE.containsKey(XbasePackage .eNS_URI)){
				EPackage.Registry.INSTANCE.put(XbasePackage.eNS_URI,XbasePackage .eINSTANCE);
			if (!EPackage.Registry.INSTANCE.containsKey(XcorePackage  .eNS_URI)){
				EPackage.Registry.INSTANCE.put(XcorePackage.eNS_URI,XcorePackage .eINSTANCE);
			Resource xcoreResource = localResourceSet.getResource(sourcename,true);
			XcoreGeneratorHelper xcoreGeneratorHelper=new XcoreGeneratorHelper();
			xcoreGeneratorHelper.doGenerate(xcoreResource, fsa);
			Resource ecoreOutputResource = new ResourceImpl();
			ecoreOutputResource.getContents().add((EPackage) EcoreUtil.getObjectByType(	xcoreResource.getContents(),EcorePackage.Literals.EPACKAGE));
			Map<String, String> saveOptions = new HashMap<String, String>();
			Resource xmiResource = new XMIResourceImpl(targetname);

			System.out.println(":) Xmi file created for ecore.");
		} catch (IOException e) {

			System.out.println(":( Error during creating Xmi for ecore.");

this method can generate ecore file but the operations are saved without body
    <eOperations name="getVorgaenger" unique="false" eType="//Begriff">
      <eAnnotations source="">
        <details key="body" value=""/>
      <eParameters name="liste" unique="false" upperBound="-1" eType="//Begriff"/>
      <eParameters name="begriff" unique="false" eType="//Begriff"/>

I have attached the MyDSl generator file. Xcore file and XcoreGenerator file.
Previous Topic:Disable terminal rule on selected parser rule?
Next Topic:Maven Layout and Eclipse plugins
Goto Forum:

Current Time: Sat Apr 20 17:01:04 GMT 2024

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

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

Back to the top