Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353536 - [xtext][findrefs] FindRefs broken for local references with simple grammar
Summary: [xtext][findrefs] FindRefs broken for local references with simple grammar
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: SR2   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 02:17 EDT by Sebastian Zarnekow CLA
Modified: 2017-09-19 17:42 EDT (History)
2 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Zarnekow CLA 2011-08-02 02:17:14 EDT
Grammar (important: use Xbase):


grammar org.xtext.example.mydsl6.MyDsl with org.eclipse.xtext.xbase.Xbase

generate myDsl "http://www.xtext.org/example/mydsl6/MyDsl"

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=ID ('by' other=[Greeting]) '!';

===

Sample model:

Hello Foo by Foo !

===

Find References does not report any results for 'Foo'.

===

Note: It works fine for this grammar (which does not use Xbase):

grammar org.xtext.example.mydsl6.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl6/MyDsl"

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=ID ('by' other=[Greeting]) '!';
Comment 1 Sebastian Zarnekow CLA 2011-08-02 04:56:51 EDT
There is a filter installed that I don't really understand: As soon as you use Xbase, all references will be filtered that point to the instance itself. The sample has a Greeting 'foo' that has a cross ref to itself. This reference will not be reported. The responsable code is here:

org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.JvmModelFindRefsQueryDataFactory

and here

org.eclipse.xtext.xbase.ui.jvmmodel.findrefs.JvmModelReferenceFilter

which does not look like this was written 'by accident'. I can only assume that it's there to filter the reference 'this' on the enclosing type in Xbase expressions but I did not dig deeper into the code to verify this assumption. Long story short: The current abstraction don't provide a way to decide reliably whether references to self shouls be filtered or not and I leave the code as is for 2.0.1.

This is definitly something that we should have a second look at for 2.1
Comment 2 Jan Koehnlein CLA 2011-09-13 07:37:12 EDT
The suspicious filter is a remnant of the old times when we had a direct reference from the source element to its inferred JVM element. No longer necessary, since we have the IJvmAssociations instead.

Removed it and pushed it to master.
Comment 3 Karsten Thoms CLA 2017-09-19 17:31:30 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:42:41 EDT
Closing all bugs that were set to RESOLVED before Neon.0