Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Detect extern model changes
Detect extern model changes [message #929449] Mon, 01 October 2012 13:16 Go to next message
Gaspar DinFriend
Messages: 21
Registered: September 2012
Junior Member
Hi all,

imagine the following usecase:
1. editing the model with the xtext editor. Save as text. Save the ast (how?).
2. accessing the ast of the model with a different editor (no xtext editor).
3. make changes to the model (to the ast) with the second editor.
4. recognize there are changes to the ast. Update the xtext textual representation.

And here are some open questions:
a) Is there any direct way to save the abstract syntax tree of the model (as objects, no textual only representation)? Or do I have to do this by myself at compile time or while saving changes?

b) If the ast can be saved somehow: Is there any possibility for xtext to reconstruct its textual representation from a loaded ast?

c) As I don't think it's possible to directly save the ast: is there any other xtext way to solve the described usecase?

Regards
Gaspar
Re: Detect extern model changes [message #930633 is a reply to message #929449] Tue, 02 October 2012 13:51 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-01-10 15:16, Gaspar Din wrote:
> Hi all,
>
> imagine the following usecase:
> 1. editing the model with the xtext editor. Save as text. Save the ast
> (how?).
> 2. accessing the ast of the model with a different editor (no xtext
> editor).
> 3. make changes to the model (to the ast) with the second editor.
> 4. recognize there are changes to the ast. Update the xtext textual
> representation.
>
> And here are some open questions:
> a) Is there any direct way to save the abstract syntax tree of the model
> (as objects, no textual only representation)? Or do I have to do this by
> myself at compile time or while saving changes?
>
The Node model is afaik not suitable for serialization, but you can
certainly save the constructed (semantic) model in xmi form.

> b) If the ast can be saved somehow: Is there any possibility for xtext
> to reconstruct its textual representation from a loaded ast?
>
You can recreate source text from a semantic model using the serializer.

> c) As I don't think it's possible to directly save the ast: is there any
> other xtext way to solve the described usecase?
>
If the "other" editing is done in Eclipse, you can simply use
IUnitOfWork and modify the model. You want to make sure you find the
right document/model (it may be open in an editor tab). This way, you
would not need to save the model in xmi form.

Hope that helps.
Regards
- henrik
Previous Topic:How to avoid format XBlockExpression in my DSL
Next Topic:Concrete syntax vs desired model structure
Goto Forum:
  


Current Time: Thu Mar 28 13:12:11 GMT 2024

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

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

Back to the top