Adding generated objects to the index [message #1833861] |
Mon, 26 October 2020 10:11  |
Eclipse User |
|
|
|
Hello,
I'm trying to achieve a complex scenario with my Xtext language and couldn't find the info I was looking for in existing posts. So I'm creating a new post but feel free to point me to existing answers if I missed them.
I'm compiling my Xtext language in the following way:
1. Source files are parsed into an EMF object tree as usual
2. My Xtext generator compiles each object tree into a tree of simpler objects within the same language/metamodel
3. The generated object tree of each source file is serialized as XMI and an XMI traceability file is also serialized to link input objects to their corresponding output object(s).
4. A final resolution stage is run (I provided an additional BuilderParticipant). It loads each generated XMI file and converts references to the input object tree into references to the corresponding generated objects thanks to the traceability files.
I'm using this workflow to solve the typical problem of generating references in the output of a model transformation based on objects in the input.
Here are my questions:
a. Is this a good workflow? Is there a better way to do this with Xtext?
b. The serializations at step 3 are not strictly necessary, i.e. I don't need the files on disk. Would it be okay to generate resources in the same ResourceSet as the input sources, and have step 4 look them up in there without going through serialization to disk?
c. Is there a way to make objects generated by step 2 visible in the Xtext index and referenceable via qualified names in the input language? I feel this is similar to what Xbase does when the JVM model inferrer generates objects that are then referenceable from the input language. Digging a bit further it seems that the process is based on IDerivedStateComputer which gets called before indexing. Am I on the right track? How would I contribute generated objects to the index to make them referenceable? Would I associate the generated IEObjectDescriptions to the same IResourceDescription as the input file?
d. Since the objects generated at step 2 are within the same language, in theory I could serialize into the same Xtext concrete syntax. Would that help in making them visible in the index?
Thanks!
Elie
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07686 seconds