Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Saving AST of xText runtime model as an ecore model
Saving AST of xText runtime model as an ecore model [message #1808396] Sun, 23 June 2019 17:34 Go to next message
Eclipse UserFriend
I am creating a DSL in xText which I then compile and run in the xText runtime environment. In this runtime environment I can then of course create a new file * file.dslextension * in which I can write a model according the DSL specification (the latter can of course be viewed as the meta-model of the model I am writing in the runtime environment). So far everything is fine.

Now I want to export this model (NOTE: NOT the ecore specification of the meta-model, which is the DSL specification) to an ecore model. A similar question has been asked on StackOverflow, but I don't know how to implement that solution in Eclipse (and hence I don't even know if that solution works). So basically what I want is to export the AST (which is an ecore model itself) of the model I create in the xText runtime environment to an actual ecore file containing the model. I want to use that ecore file afterwards for making transformations with the QVTo language.

I tried to read tutorials on how to adapt the xTend files in the org.xtext.example.generator package, but all these tutorials focus on creating proprietary transformations for very specific cases. I just want xText to automatically generate an ecore file of the models (DSL instances) that I write in the xText runtime environment.

P.S. I also cross-posted this on stackoverflow

[Updated on: Sun, 23 June 2019 17:35] by Moderator

Re: Saving AST of xText runtime model as an ecore model [message #1808398 is a reply to message #1808396] Mon, 24 June 2019 00:27 Go to previous messageGo to next message
Eclipse UserFriend
hi, can you be a bit more specific on what you actual problem is.

EcoreFactory.eINSTANCE.createEPackage creates a package
EcoreFactory.eINSTANCE.createEClass creates a class

do a model 2 model transformation using these
the with-expression and create methods in xtend might come handy for that purpose

you could call this from the generator. or a custom command or ... (insert your requirement here)
Re: Saving AST of xText runtime model as an ecore model [message #1808402 is a reply to message #1808398] Mon, 24 June 2019 01:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi

You terminology seems confused.

If you want to save as an Ecore model then why don't you use Ecore (or Xcore or OCLinEcore) as your DSL?

I presume you actually mean save as XML/XMI in which case you have to do very little. Just move the DSLResource.getContents() to an XMIResourceImpl.getContents(), setURI and save.

Sometimes, but I think it is broken now, you could just ave as *.xml in the DSL editor.

Regards

Ed Willink
Re: Saving AST of xText runtime model as an ecore model [message #1808410 is a reply to message #1808402] Mon, 24 June 2019 04:18 Go to previous message
Eclipse UserFriend
An example implementation on how to achieve that is available under:
https://github.com/franca/franca/blob/master/plugins/org.franca.core.dsl.ui/src/org/franca/core/dsl/ui/handlers/GenerateXMIHandler.java
Previous Topic:Graphical view for Xtext
Next Topic:Scoping with URI
Goto Forum:
  


Current Time: Wed Mar 19 06:32:08 EDT 2025

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

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

Back to the top