|
Re: Integration with Xtext [message #1839613 is a reply to message #1839609] |
Wed, 24 March 2021 15:21 ![Go to previous message Go to previous message](png/up.png) ![Go to next message Go to next message](png/down.png) |
|
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 Go to previous message](png/up.png) |
|
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/
|
|
|
Powered by
FUDForum. Page generated in 0.02000 seconds