Bi-direction (EOpposite) in Xtext [message #1769552] |
Tue, 01 August 2017 10:25  |
Eclipse User |
|
|
|
To Whom It May Concern,
I have one meta-model project, which have bi-direction reference in it. Base on this meta-model, I also have some generated instance model (XMI Schema).
Now, I want to transfer these XMI model into Xtext DSL. But as I know, Xtext support bi-direction not well. So how should I do?
|
|
|
|
|
Re: Bi-direction (EOpposite) in Xtext [message #1769743 is a reply to message #1769739] |
Thu, 03 August 2017 02:43   |
Eclipse User |
|
|
|
Thanks for your replay. Christian.
Sorry for my description not clearly.
I have attache the meta-model.

1,I want to use Xtext in this meta-model. But after I generate the DSL I find it has a bidirectional reference. These two reference must be appeared and serialized. So what should I do? Remove the EOpposite attribute from this Reference? or ?:
Switch returns Switch:
'Switch'
'{'
('id' id=EInt)?
'currentPosition' currentPosition=Position
('connectsTo' '(' connectsTo+=[TrackElement|STRING] ("," connectsTo+=[TrackElement|STRING])* ')')?
[b] ('positions' '(' positions+=[SwitchPosition|STRING] ("," positions+=[SwitchPosition|STRING])* ')')?[/b]
'}';
SwitchPosition returns SwitchPosition:
'SwitchPosition'
'{'
('id' id=EInt)?
'position' position=Position
[b] 'switch' switch=[Switch|STRING][/b]
'}';
2,Each of this model Element only has id, dosen't have name. I can create the model element, but when I create reference between two element. Xtext alert that "Couldn't resolve reference to Semaphore '0'."
Sample Model:
RailwayContainer {
semaphores{
Semaphore{
id 0
signal GO
}
}
routes{
Route {
id 1
entry '0'
exit '0'
definedBy{
Sensor{
id 9
},
Sensor{
id 8
}
}
}
}
}
Attachment: 1.png
(Size: 76.40KB, Downloaded 708 times)
Attachment: railway.ecore
(Size: 4.05KB, Downloaded 113 times)
Attachment: Railway.xtext
(Size: 2.13KB, Downloaded 82 times)
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03908 seconds