Split textual models into multiple files [message #1857274] |
Fri, 27 January 2023 15:16 |
Klarise Hund Messages: 25 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 #1857280 is a reply to message #1857276] |
Fri, 27 January 2023 19:44 |
Ed Willink Messages: 7675 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
|
|
|
Powered by
FUDForum. Page generated in 0.18728 seconds