Detect extern model changes [message #929449] |
Mon, 01 October 2012 09:16  |
Eclipse User |
|
|
|
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 09:51  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.26328 seconds