Home » Modeling » VIATRA » M2M using Xtext
| |
Re: M2M using Xtext [message #1770247 is a reply to message #1770232] |
Wed, 09 August 2017 11:03 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
Xtext models can be used as sources or targets of the transformation when opening the model into an EMF Resource, however, the following things are necessary to consider:
* You have to make sure everything is registered as necessary. In Eclipse environments the UI plug-in generated by Xtext should do this automatically; in non-Eclipse environments you can use the standalone setup in the core language project. Make sure you don't mix them - use only the one necessary.
* If your language uses Xbase, you might need some additional registration steps (e.g. specifying the classloader to use) before you can open the model.
* As Ábel mentioned, don't try to react to EMF events on an open Xtext-based editors, as notifications can be missed. By using a DocumentListener you can find out the points when the model is stable, and there you can initialize a throwaway VIATRA Query engine for a batch transformation. If you open the model manually, you can rely on the VIATRA APIs to work as expected.
* If you are generating Xtext models, ensure that the generated model can be serialized at all points.
Best regards,
Zoltán
|
|
| |
Re: M2M using Xtext [message #1771239 is a reply to message #1771237] |
Wed, 23 August 2017 08:36 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
in short, I do not recommend starting an incremental transformation over an Xtext _editor_, as Xtext is known to turn off notifications on model changes (see the previously referred bug [1] for a more detailed, but quite technical discussion about the issue) that causes incorrect results coming out from the query engine.
The only thing that can work is to listen to file changes (e.g. with an Eclipse builder [2]), and then parse the file when it was changed and start a batch transformation (not event-driven) that looks at the output model, and _updates_ it to represent the current state of the model. This is safe, as the Xtext model does not change during the transformation; and when the file changes again, the builder will be notified.
Hope this is helpful,
Zoltán
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=387119
[2] http://www.eclipse.org/articles/Article-Builders/builders.html
|
|
| |
Re: M2M using Xtext [message #1771317 is a reply to message #1771239] |
Thu, 24 August 2017 01:38 |
zhang ph Messages: 43 Registered: March 2017 |
Member |
|
|
Hi Zoltan,
Quote:I do not recommend starting an incremental transformation over an Xtext _editor_
Maybe I don't explain my scenario clearly. Currently, I just use Xtext as source(Only one Xtext model) and target model. And I start an incremental transformation over traceability model(which is XMI format). So I think the bug mentioned by you may not occur in my scenario. Am I right?
Quote:see the previously referred bug [1]
In this bug, "references to external resource" means what ? an Xtext model based on same or different meta-model ?
[Updated on: Thu, 24 August 2017 02:13] Report message to a moderator
|
|
|
Re: M2M using Xtext [message #1771334 is a reply to message #1771317] |
Thu, 24 August 2017 07:41 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
zhang ph wrote on Thu, 24 August 2017 01:38Hi Zoltan,
Quote:I do not recommend starting an incremental transformation over an Xtext _editor_
Maybe I don't explain my scenario clearly. Currently, I just use Xtext as source(Only one Xtext model) and target model. And I start an incremental transformation over traceability model(which is XMI format). So I think the bug mentioned by you may not occur in my scenario. Am I right?
Sadly, the issue is not so simple. I am not exactly sure what happens inside the traceability editor in case the Xtext model is updated outside the editor, but I see two scenarios. (1) The model is either not reloaded at all; in this case, the transformation will trivially not update the target model; or (2) the model is reloaded, and thus reparsed, references on the Xtext model may or may not break (e.g. if you have reordered or inserted something into the Xtext model, there is a fair chance that references from the XMI model will break), and additionally it is possible that you trigger the original, notification-related bug as well (although I am not sure of this).
Basically, there are two required steps to trigger this issue: (1) you have at least a single query, that requires the Xtext resource indexed (e.g. its match set refers to that model), and (2) the textual syntax is reparsed (either because it was modified in the text editor; or it was modified outside the current ResourceSet, and needs to be reloaded); otherwise there is no chance that the index becomes stale.
The fact that I suggested a builder-based approach avoids this issue as there is no reparsing done in an already indexed model.
zhang ph wrote on Thu, 24 August 2017 01:38
Quote:see the previously referred bug [1]
In this bug, "references to external resource" means what ? an Xtext model based on same or different meta-model ?
The original issue report was found where an Xtext resource (e.g. file) referred to model elements in another resource (e.g. file). But there are a lot of occurrences of this pattern throughout Xtext where notifications are turned off, so there might be other issues as well.
Best regards,
Zoltán
|
|
|
Goto Forum:
Current Time: Sat Apr 20 03:13:56 GMT 2024
Powered by FUDForum. Page generated in 0.03803 seconds
|