Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Integrating Xtext and Sirius: Strategies and Pitfalls


Published on

A model can be represented graphically and textually. While text is able to carry more detailed information, a diagram highlights the relationship between elements much better. In the end, a good tool should combine both, and use each notation where it suits best.

Xtext and Sirius are both based on the Eclipse Modeling Framework (EMF) and as such combinable. But once you have the most basic integration running you will stumble across strange issues. Getting rid of these requires a deeper understanding on how both frameworks treat their models and a clear vision on what you want to achieve.

In this talk we will outline several integration scenarios. As a joint talk of Obeo and TypeFox, we will explain the typical issues from the Sirius and the Xtext perspective and show how to tackle them to create great hybrid modelling tools in the end.

Published in: Engineering
  • Be the first to comment

Integrating Xtext and Sirius: Strategies and Pitfalls

  1. 1. Integrating Xtext and Sirius: Strategies and Pitfalls Cédric Brun (Obeo) – Jan Köhnlein (TypeFox)
  2. 2. Agenda ● Three modes of integration ○ Persisting the model using Xtext ○ References between Xtext and Sirius models ○ Embedding an Xtext editor in Sirius ● Conclusion
  3. 3. Persisting the Model Using Xtext
  4. 4. Diagram Model vs Semantic Model Sirius ProjectResourceSet foo.aird diagram model foo.flow semantic model by default persisted as XMIResources foo.xflow semantic model
  5. 5. XtextResource parser serializer text file EObjects getContents() load() save() fragment provider getURIFragment(EObject) getEObject(fragment)
  6. 6. Persist the Semantic Model with Xtext Sync through filesystem
  7. 7. Diagram Refresh Strategy ● Automatic Refresh (default) ○ lead to diagram re-init when the model is un-parseable ○ diagram content gets lost ● Setup a specific strategy to trigger the refresh
  8. 8. Grammar Adaptations ● Avoid errors when the user tries to save ● Not every string is an ID ○ Consider using STRING rule instead of ID in the grammar ● Lose grammar, strict validation ● Tools should create serializable elements by default ● Highlight offending elements in diagram
  9. 9. Concurrent Dirty States Prevent editing in the other syntax when one is dirty
  10. 10. References Between Xtext and Sirius Models
  11. 11. Xtext and Sirius Models Combined Xtext and Sirius are aware of each others models Cross-references between them
  12. 12. EMF Cross-references ResourceSet foo.x XMI model bar.y Xtext model cross references XMI uses URIs: href=”<resource URI>#<fragment>” e.g. href=”bar.y#ab378f1789d1”
  13. 13. Names vs URIs I am giving this talk with Cédric. Name-based linking (Xtext) I am giving this talk with ECF2017#116. URI-based linking (Sirius) Resolution mechanism Coupling of resources Syntax errors Rename Suitability for users Differences
  14. 14. Models And Identities Editor foo.dsl ResourceSet baz.dsl foo.dsl Editor bar.dsl ResourceSet foo.dsl bar.dsl Project ResourceSet baz.dsl foo.dsl bar.dsl *.dsl Xtext Sirius
  15. 15. Make Sirius Refer to Xtext ● Implement an IFragmentProvider ○ make name (and type) part of the XMI-ID ● Implement Xtext support for *.aird files ○ allows Sirius to participate in Xtext rename refactoring ● Navigate to Xtext editor from the diagram ● Define fixed synchronization points ● Compare based on compare & merge instead of plain reload
  16. 16. Make Xtext Refer to Sirius/XMI ● Implement Xtext support for the XMI model ○ make elements referable from Xtext ○ make cross-links openable ○ participate in Xtext refactorings ● Navigate to Sirius editor from Xtext ● Rename on the Sirius side must trigger a rename refactoring in Xtext
  17. 17. Either way ● Cross-referencing will rely on the Xtext index ○ Xtext nature on project + build-automatically must be on ○ check the index with CTRL-SHIFT-F3 ● Dirty-state integration is tricky ○ Refs from Xtext are not updated correctly when Sirius model changes ○ Avoid Xtext rename refactoring when diagram has unsaved changes
  18. 18. Embedding an Xtext Editor into Sirius
  19. 19. Embedding Xtext XtextEmbeddedEditor + Custom properties widget Store Xtext model in a string-valued attribute
  20. 20. Requires Pretty Deep Integration ● Configuring XtextEmbededdEditor widget ● Syncing Transactions ● Using Sirius dirty state instead of the last-saved state ● Rename refactoring will be hard
  21. 21. Conclusion
  22. 22. You can integrate Xtext and Sirius ● Use EMF as the base of any kind of integration ● Basic level of integration is quite easy ● Deep integration can be tricky, keep an eye on ○ Linking cross-references ○ Using resource sets ○ Transactions ○ Consistency ● But in the end you’ll get a great tool mixing textual and graphical representations
  23. 23. Examples are online ● FowlerDSL: ● Farming (Gemoc) : ● Flow: