Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Synchronizing Sirius with Xtext
Synchronizing Sirius with Xtext [message #1829054] Wed, 24 June 2020 11:43 Go to next message
Albert Johnson is currently offline Albert JohnsonFriend
Messages: 6
Registered: June 2020
Junior Member
Hello,

My goal is to be able to modify graphically my DSL samples, and save them in the Xtext format so that Xtext can do the code generation.
My problem is I do not know how to link Xtext and Sirius.

I have a DSL created with Sirius that I can use in a runtime Eclipse, creating samples in a graphical way thanks to the design created in a .odesign file.

I created an Xtext project from my existing Ecore model, generated it with the .mw2 file, and when I start my runtime Eclipse I can create Xtext file from the generated Xtext DSL.

However, my files that I can modify graphically (Sirius side) look like XML file, and the Xtext files look like something like this:
Package first {
	name aPackage
}


Consequently, I cannot generate code from the file I create graphically since there are not in the format Xtext want.

I would like to have something like this:
https://www.eclipse.org/forums/index.php?t=getfile&id=35113&
Found here: https://www.eclipse.org/forums/index.php/t/1098158/
Where I can synchronize the graphical model with the Xtext model.

Anyone knows how to do that?

Thank you.

Albert
Re: Synchronizing Sirius with Xtext [message #1829063 is a reply to message #1829054] Wed, 24 June 2020 13:25 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi,

There are different ways in which Sirius and Xtext can be intergrated, but from what I understand you want to use Sirius to display and edit Xtext-based models.

The basic idea is simply to use Sirius "normally", and define your diagrams on the Xtext-based models as if they were classical EMF models (which they mostly are).
You will have to know the names of the element types that you want to manipulate (from the Xtext grammar), but mostly, to Sirius, Xtext models are just EMF models which have a specific serialization.

Make sure you have the optional "Sirius Integration with Xtext" feature (id org.eclipse.sirius.runtime.ide.xtext) installed, which ensures Sirius does not mess with the Xtext serialization and formatting.

There *are* some subtelties when you go beyond the basics, and you may be interested in the whitepaper we published a few years ago (but which should still be valid) at https://www.obeodesigner.com/en/white-paper-xtext-sirius if you want to go further.

Regards,
Pierre-Charles


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Synchronizing Sirius with Xtext [message #1829068 is a reply to message #1829063] Wed, 24 June 2020 14:46 Go to previous messageGo to next message
Albert Johnson is currently offline Albert JohnsonFriend
Messages: 6
Registered: June 2020
Junior Member
Hi Pierre-Charles,

Thank you for your quick reply!

Just a detail I am not sure to understand clearly (I am quite new in Sirius). When you say define your diagrams on the Xtext-based models, do you mean in the odesign file? If yes I cannot find the metamodel to link from Xtext since I have an ecore file only in the Sirius DSL, not in the one generated by Xtext.
When I am creating a new file from my DSL (file->new->other->myDSL), it is asking me the root of my model, and then directly generating a kind of XML file (working with my diagrams). Otherwise, if I do file->new->file and give as extension the name of the DSL, it is asking me if I want to convert into the Xtext format, if I say yes it is ok in this case for Xtext but not anymore for Sirius.
Re: Synchronizing Sirius with Xtext [message #1829084 is a reply to message #1829068] Thu, 25 June 2020 00:45 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
> If yes I cannot find the metamodel to link from Xtext since I have an ecore file only in the Sirius DSL, not in the one generated by Xtext.

I think you will want to use the same ecore model between Sirius and your Xtext.

You can create a Xtext project from an existing ecore model and have the ecore model be external to main xtext DSL project. That way Sirus and Xtext are working on the same ecore model.

When you create an Xtext project from an existing ecore model, it will suggest a grammar for you (it'll be very generic). You can change that grammar to fit your desired Xtext grammar.

If you've already done work in an existing Xtext project, this link mentions how to import and external ecore model:

http://blog.efftinge.de/2009/11/xtext-using-existing-ecore-models.html

[Updated on: Thu, 25 June 2020 00:58]

Report message to a moderator

Previous Topic:How can I add IDoubleClickListener for edition table?
Next Topic:How to accelerate opening editors using DialectUIManager?
Goto Forum:
  


Current Time: Thu Apr 25 19:32:20 GMT 2024

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

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

Back to the top