Execute code on xtext startup?

150 Views Asked by At

I am working on a project where we use ATL to transform one ECore model instance to another. We have an XText editor set up to work with the target model, and would like to load the transformed model directly into the editor when it is started. Currently we have the instance as an XMI file on disk.

Is this possible? If so, how should we go about this?

1

There are 1 best solutions below

0
On

That is a really nice question. I think there isn't an eclipse plugin existing for this task yet, but one is probably very easy to create. The plugin would have to do these kind of steps:

  • in preferences configure the transformations that are used when opening a file
  • when opening a file load the source model
  • transform it to the target model (see the ATL forum for not quite complete java code)
  • open the editor for the target model
  • when saving the editor you need to transform the target model back to the source model and save that

I don't know if the Eclipse API also supports in-memory resources, so you don't have to store the target model as a file on disk.