Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Bi-directional reference
Bi-directional reference [message #1851123] Mon, 28 March 2022 12:01 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi all,

I was wondering how I can write the grammar for bi directional references where one side is a containment.
If we take the following example:


The only way I can think of writing this is the following:

Test returns Test:
test = [Test | FQN]
 ('{' testeOpposite +=Test ( "," testeOpposite +=Test)* '}' )

However, this is not the same because in this case I get:

Is there any way around this?

Thank you!
Re: Bi-directional reference [message #1851128 is a reply to message #1851123] Mon, 28 March 2022 13:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14588
Registered: July 2009
Senior Member
maybe you can simply use a containment ref and do the opposite e.g. via giving
the generic eContainer a different name via eoperation

or you simply just use eContainer and live with it.

Twitter : @chrdietrich
Blog :
Re: Bi-directional reference [message #1851135 is a reply to message #1851128] Mon, 28 March 2022 15:38 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7635
Registered: July 2009
Senior Member

Xtext is a powerful grammar tool that often produces a useful Ecore metamodel as a side effect.

However if you want to control your metamodel explicitly rather than accidentally you should treat your *.ecore development as your primary activity and then use it with rather than generate it from Xtext.


Ed Willink
Previous Topic:xtend src-gen folder relative to dsl file
Next Topic:Xtext maven plugin language order
Goto Forum:

Current Time: Sat Dec 02 01:43:56 GMT 2023

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

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

Back to the top