Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 21:34 Go to next message
J Bouwhuis is currently offline J BouwhuisFriend
Messages: 17
Registered: April 2019
Junior Member
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 21:35]

Report message to a moderator

Re: Saving AST of xText runtime model as an ecore model [message #1808398 is a reply to message #1808396] Mon, 24 June 2019 04:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Saving AST of xText runtime model as an ecore model [message #1808402 is a reply to message #1808398] Mon, 24 June 2019 05:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 08:18 Go to previous message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
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 Apr 24 20:09:05 GMT 2024

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

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

Back to the top