Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Split textual models into multiple files
Split textual models into multiple files [message #1857274] Fri, 27 January 2023 15:16 Go to next message
Klarise Hund is currently offline Klarise HundFriend
Messages: 22
Registered: October 2022
Junior Member
Hi,

Is it possible to split a textual model conforming to an XText grammar, into multiple files? The user should be able to decide how.
Are there approaches currently doing it? If not, do you foresee any challenges with doing that?
For instance, a textual model conforming to an Text grammar has some required elements cardinality 1..1). Let's say that element A,B,C all have this cardinality. Is it possible to split them, so that in one file we have element A , in the other element B, and in a third one element C? Would that produce invalid files?
Re: Split textual models into multiple files [message #1857276 is a reply to message #1857274] Fri, 27 January 2023 15:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i am not sure if understand the usecase but give e.g. the domain model example grammar from the tutorial
you can split the entities over multiple files and still reference entities from others files.

of course this means:
split the code over multiple files as you would do it in java and not <insert model here>
you can just do a <refer to element in other file here>


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Split textual models into multiple files [message #1857280 is a reply to message #1857276] Fri, 27 January 2023 19:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
In principle, yes. EMF supports the use of containment proxies, so the container of A, B, C can specify different files for each.

Xtext-based / EMF-based tooling should have no trouble reading the composition.

I'm not sure quite how you would ensure that they are written as you require. You probably need to ensure that your custom XXXResource has save functionality that detects, perhaps heuristically, perhaps via a keyword-controlled attribute in your language, that some element is to be the root of a nested Resource.

e.g. if there is an AorBorC::new-file String attribute, a non-null String could specify the relative name of the composed child. This should work as is with Xtext, but you will always be editing the whole 'file'. You might be able to edit just a sub-file, but you are liable to get caught out by an EcoreUtil.resolveAll loading everything.

To get proper multiple document editing may require some work to ensure that Xtext is lazy about loading and that there is an appropriate inter-document navigation menu action.

[Updated on: Fri, 27 January 2023 20:00]

Report message to a moderator

Previous Topic:Import a dsl language which is not present in the same workspace
Next Topic:Downloading XText, sdk not found
Goto Forum:
  


Current Time: Tue Apr 23 12:23:07 GMT 2024

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

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

Back to the top