Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ReferenceFinder returns unwanted references
ReferenceFinder returns unwanted references [message #1598937] Tue, 03 February 2015 09:04 Go to next message
Stefan Scheiber is currently offline Stefan ScheiberFriend
Messages: 18
Registered: February 2015
Junior Member
i'm having the following xcore model
class Library {
	contains Class[] classes opposite library
}

interface Type {}
class PrimitiveType extends Type {}

class Class extends Type {
	container Library library opposite classes
	contains Group[] groups opposite clazz
	String name
}

class Group {
	container Class clazz opposite groups
	contains Variable[] vars opposite group
}

class Variable {
	container Group group opposite vars
	String name
	refers Type ^type
	refers derived Class clazz get { group.clazz }
}


we have a grammar from this model and below is a sample
class A {
   group {
       b: B;
   }
}

class B {
  group {
       i : INT;
       j: INT;
  }
}


if B is selected and 'find references' is called
expected is
b: B
but the result is
b:B
i:INT
j:INT

The reason for this behaviour is the derived reference clazz in the Variable class.
Of course, the derived reference could be changed to an operation, but IMO the referencefinder should either discard non-indexable references (i.e. derived, transient refs) or at least all references to container objects, be it direct parent (this is already handled - container refs are ignored) or some grand-grand-parent.
How do you see this? Is this a bug or a feature? Or what solutions are there besides changing the derived ref to an operation or using a custom referencefinder?
Re: ReferenceFinder returns unwanted references [message #1600392 is a reply to message #1598937] Wed, 04 February 2015 07:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i dont know anything about the "should" - but you can have a look at org.eclipse.xtext.findReferences.ReferenceFinder.doProcess(EReference, TargetURIs)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ReferenceFinder returns unwanted references [message #1600505 is a reply to message #1600392] Wed, 04 February 2015 09:33 Go to previous messageGo to next message
Stefan Scheiber is currently offline Stefan ScheiberFriend
Messages: 18
Registered: February 2015
Junior Member
Thank you for your swift reply!
That is the class where I debugged to see why I get the references that I do instead of the ones that I expect.
The reason is the derived reference to the Class in Variable. If the variable would be a direct child of Class then this reference would be discarded as it is a container reference. However, in my case the variable is not a direct child but a grandchild (there is a Group in between). The reference to Class is not a containment reference it is a derived reference that refers to a grandparent. However, based on the same rationale that container references (i.e. references to parent) are ignored by ReferenceFinder, shouldn't any references to grand-parents be ignored as well?

with such a model
class Class extends Type {
	container Library library opposite classes
	contains Variable[] vars opposite clazz
	 String name
}

class Variable {
	container Class clazz opposite vars
	String name
	refers Type ^type
}

and such a DSL
class A {
   b: B;
}
class B {
   i: INT;
   j: INT;
}

the result of find references of B would be as expected
b: B
and not
b: B
i: INT
j: INT
I hope that my question/problem is clearer now.

[Updated on: Wed, 04 February 2015 09:41]

Report message to a moderator

Re: ReferenceFinder returns unwanted references [message #1600516 is a reply to message #1600505] Wed, 04 February 2015 09:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
the problem is clear. the question is: why dont you adapt that method

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ReferenceFinder returns unwanted references [message #1600553 is a reply to message #1600505] Wed, 04 February 2015 10:12 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stefan,

your derived grand-grand-parent reference encapsulates the logic. There
is no way to detect that this reference is just an invocation of
eContainer.eContainer. Filtering all references that point to some
container instance would be wrong since it may be a valid and useful
reference indeed.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: ReferenceFinder returns unwanted references [message #1600584 is a reply to message #1600553] Wed, 04 February 2015 10:37 Go to previous message
Stefan Scheiber is currently offline Stefan ScheiberFriend
Messages: 18
Registered: February 2015
Junior Member
Thank you both for your answers!
I will adapt the ReferenceFinder to match my needs.
Previous Topic:BasicEListOutOfBoundsException while working with modified files
Next Topic:XtextCON 2015 - Call For Submissions
Goto Forum:
  


Current Time: Fri Apr 26 06:54:04 GMT 2024

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

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

Back to the top