Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Difference between References
Difference between References [message #722609] Tue, 06 September 2011 10:32 Go to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Hello guys,

I'm wondering what the internal difference between EReferences generated by Xtext is.
Basically I need to know whether my reference is from this type "system = System" or from this type "variantName = [Variant | QualifiedName]". Both appear in the debugger as EReferenceImpl and I can't spot a difference between them.

Does anyone have an idea related to this?
Thanks a lot Smile

Daniel
Re: Difference between References [message #722612 is a reply to message #722609] Tue, 06 September 2011 10:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the difference is "containment". cross-references not contained.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Difference between References [message #722620 is a reply to message #722612] Tue, 06 September 2011 10:56 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Alright.
But how can I access this in my code? I can't find anything related to containment in the debugger.
Re: Difference between References [message #722622 is a reply to message #722620] Tue, 06 September 2011 11:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

why in the debugger? its static information (see ecore)

in the debugger you see the referenced element not the reference itself.
you can of course get a hint that the econtainer of the child element in the tree is the same as the parent element in the tree.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Difference between References [message #722628 is a reply to message #722622] Tue, 06 September 2011 11:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As an addition,
you may evaluate an expression like ((EReference)context.eContainingFeature()).isContainment()
to find out if it is contained from the debugger as well

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Difference between References [message #722634 is a reply to message #722622] Tue, 06 September 2011 11:34 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Well I need to know those things during runtime.

I solved it with your help this way:

if(eObj.eClass() == ((EObject)obj).eContainer().eClass())
	//containment ref
else
	//other ref

(eObj being the parent eobject, obj being the referenced eobject)

Thanks a lot Christian, as usual Smile

[Updated on: Tue, 06 September 2011 11:35]

Report message to a moderator

Re: Difference between References [message #722635 is a reply to message #722634] Tue, 06 September 2011 11:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

this won't work: use ((EReference)context.eContainingFeature()).isContainment()


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Difference between References [message #722637 is a reply to message #722609] Tue, 06 September 2011 11:34 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
There are plenty of e-prefixed-methods on EMF based objects that give
you access to meta data and allow you to navigate the model.

While debugging I often use the JDisplay view and do things like:

// where is x contained?
x.eContainer();

// what is x to it's container?
x.eContainingFeature()

etc.

Hope that helps.
- henrik

On 9/6/11 12:32 PM, Daniel Trierweiler wrote:
> Hello guys,
>
> I'm wondering what the internal difference between EReferences generated
> by Xtext is.
> Basically I need to know whether my reference is from this type "system
> = System" or from this type "variantName = [Variant | QualifiedName]".
> Both appear in the debugger as EReferenceImpl and I can't spot a
> difference between them.
>
> Does anyone have an idea related to this?
> Thanks a lot :)
>
> Daniel
Re: Difference between References [message #722664 is a reply to message #722635] Tue, 06 September 2011 12:59 Go to previous message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Thanks you two, but actually, it works.
I will test some more and report back Smile
Previous Topic:Dealing with EMF model and parser error
Next Topic:Content assist question
Goto Forum:
  


Current Time: Fri Apr 26 06:13:29 GMT 2024

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

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

Back to the top