Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse GLSP » Integration with Xtext(Integration of Xtext with the GLSP )
Integration with Xtext [message #1839609] Wed, 24 March 2021 15:10 Go to next message
Robert Richter is currently offline Robert RichterFriend
Messages: 4
Registered: March 2021
Junior Member
I am currently working on an approach of using a synchronized textual and graphical editor in parallel. I am aware of other approaches and the discussion if this is even meaningful.
However I want to use the GLSP for graphical and Xtext for textual purposes. So I need to synchronize them in some way.

Since both are based on the EMF, I hope that I simply can take the current EMF-instance saved in Xtext and update the GLSP with it (and vice versa).

Is this possible? Does anyone have some papers I can read / projects I can review for that purpose?
Re: Integration with Xtext [message #1839613 is a reply to message #1839609] Wed, 24 March 2021 15:21 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

Yes, that's possible. There are some considerations though.

First of all, GLSP just takes any model source (such as an EMF model coming from a file or an Xtext AST) and translates that into the graphical model (GModel, model factory), which is then sent to the client for rendering.
Any editing operations are then sent from the client to the server, which again applies those operations to the original model source (operation handlers) and retriggers the generation of the GModel to update the client.

Thus, GLSP can easily show Xtext EMF models graphically and process editing operations by manipulating the AST of an Xtext model.

However, there are a few conceptual caveats:
1. white space changes: whenever the AST is modified, you may loose white space in the textual file.
2. mapping: if there are parallel changes to the textual file, this typically results in reparsing the entire or parts of the file, which in turn replaces parts of the model with new objects. You need to add a hook (such as an Xtext build participant or similar) to react to such events in order to retrigger the generation of the GModel for the diagram update. An issue is in some scenarios that the Xtext-based AST is replaced, so it's usually not possible to know which parts have actually changed, you just get a new snapshot of the AST. For GLSP (and Sprotty) it is important though that when updating the diagram, the IDs that are assigned to the graphical nodes and edges are stable, otherwise an update won't result in a nice animation but in a complete redraw. Keeping these IDs stable is however difficult when the AST model is replaced, because you get new EObjects instead of the same EObjects with changed data. This may or may not be a problem, depending on the use case.

I'm not really aware of any papers about that, unfortunately.


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Integration with Xtext [message #1839616 is a reply to message #1839613] Wed, 24 March 2021 15:25 Go to previous message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

oh, and one thing I forgot:
3. If you don't fully rely on auto-layouting, you need to find a way how to persist graphical layout information (coordinates, sizes, etc.). You can make that a part of the Xtext model (which is rather atypical), or have a separate resource where you store that. As new elements may have been added or removed via the textual file, you need to handle cases where the layout information is incomplete or outdated.


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Goto Forum:
  


Current Time: Fri Apr 26 23:49:49 GMT 2024

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

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

Back to the top