Generating multiple objects within one rule [message #1830378] |
Fri, 24 July 2020 12:25 |
Philémon Houdaille Messages: 1 Registered: July 2020 |
Junior Member |
|
|
Hello ! I have encountered a problem with xtext that I'm not sure how to solve, and haven't been able to find a solution to online yet.
I have two classes (Data and DataPurpose) that have a name, a bidirectional reference between them and an enumeration for DataPurpose (ExternalData, InputData, OutputData, MeasuredData); what I would like to do is to write for instance "data1 as ExternalData, InputData;", and that internally the language would create 3 objects : a "Data" type object, which references two "DataPurpose" type objects with respectively the enumeration "ExternalData" and "InputData", and also that the three objects have the same name ("data1").
I thought I could get away with using "tree rewrite actions" (like "{DataPurpose.data = current}" in the Data rule) after reading the Xtext documentation, but Ifound out that they don't allow to change the attributes of the created objects and only seems to work for containments and not references (my two objects are contained by another unique object and not within e ach other).
Has anyone ever encountered a similar situation? I attached screenshots of the metamodel and the grammar rule to the post if it is of any help.
Please note that slight metamodel modifications to solve the problem aren't preferred, but not out of the question either if there is no other solution. Thanks in advance for the help!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02717 seconds