Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Include Xtext document formating as model elements
Include Xtext document formating as model elements [message #1730288] Sat, 23 April 2016 15:34 Go to next message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Dear all,

I am looking for a way to store the formating information of an Xtext file as part of the model representation. Thereby, the textual representation could be recreated completely from the XMI serialized model.

What I could think of is either a separate layout model that refers to the model elements or a reference to a layout model element that stores such layout information. The former approach is used by GMF editors, the latter is the approach the guys from EMFText are using (see their manual, section 4.2.14).

Is there any possibility of including this information in an Xtext model as well? If not, what would be a good starting point for integrating such a feature?

Best regards
Stephan
Re: Include Xtext document formating as model elements [message #1730289 is a reply to message #1730288] Sat, 23 April 2016 15:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13181
Registered: July 2009
Senior Member
I dont get the point about this. There is no formatting information. The is the concrete syntax and the ast. For the concrete syntax a so called node model tree is created. Maybe you can use https://github.com/eclipse/xtext/blob/4e5a6842d937c9616dcf920e7b3fee9b8a6e0687/plugins/org.eclipse.xtext/src/org/eclipse/xtext/nodemodel/serialization/SerializationUtil.java to serialize it separately but why not simply keeping the text file if it already has all information needed.

Maybe you can give more insights on your usecase


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Include Xtext document formating as model elements [message #1730310 is a reply to message #1730289] Sun, 24 April 2016 09:44 Go to previous message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Hello Christian,

thanks for your fast response. You are right, my motiviation for including such information did not become clear.

What I would like to realize is storing the Xtext model in a CDO repository, so I can use its abilities such as change notifications. In order to achieve this, it is necessary to store the Xtext model as model and not as text file (which is also supported by CDO). The approach of Stefan Winkler for incremental model upgrades seems promising. Nevertheless, the approach lacks support for restoring the formatting of the document from CDO as this is not part of the model and therefore not stored.

Obviously, I could store the Xtext file as text resource in addition to the model in CDO and apply some synchronization mechanisms but this could become quite hard if the underlying model has been modified in CDO by a mechanism different from the Xtext editor. This is, however, crucial for my use case. Instead, I would like to be able to completely reconstruct the textual representation from the model stored in CDO.

As far as I understand your answer, the data structure containing the information about the textual representation is only available temporarily and not stored in a EMF-like model. I would have to serialize the node model and feed it back to Xtext when the regular model is loaded. I will have a look at this.

Thanks
Stephan
Previous Topic:Index of element in the whole tree
Next Topic:Project Nature in Xtend
Goto Forum:
  


Current Time: Tue Nov 12 10:38:45 GMT 2019

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

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

Back to the top