Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331816 - Find references only consider resource exported elements
Summary: Find references only consider resource exported elements
Status: CLOSED DUPLICATE of bug 301275
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-03 15:28 EST by Samantha Chan CLA
Modified: 2010-12-03 15:40 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samantha Chan CLA 2010-12-03 15:28:09 EST
In my understanding, resource descriptions consists of a list of EObjectDescriptions that are exported from the resource.  i.e. these objects can be referenced from outside of the current resource.

There is also a concept of local scoping where the EObjectDescriptions are constructed on the fly when trying to determine the local scope.

In the FindReferencesHandler, it seems to me that we can only find references that are part of a resource description.  In other words, we can only locate references to objects that are exported, but no to objects that are only visible in the current resource.

I cannot find a way to override this behavior, and I am wondering if EObjectResolver from FindReferencesHandler should be changed to construct a new EObjectDescription if a name attribute is present.  

I changed my local dev environment to this and was able to find references for local elements as well.  Is this the right way of going about it?  Is it expected that FindReferences should only work for exported elements?


Here's the proposed change:

		public IEObjectDescription exec(XtextResource state) throws Exception {
			EObject element = EObjectAtOffsetHelper.resolveElementAt(state, selection.getOffset(), null);
			if (element != null) {
				final URI eObjectURI = EcoreUtil.getURI(element);
				IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(eObjectURI
						.trimFragment());
				if (resourceDescription != null) {
					Iterator<IEObjectDescription> eObjectDescriptions = Iterables.filter(
							resourceDescription.getExportedObjects(), new Predicate<IEObjectDescription>() {
								public boolean apply(IEObjectDescription input) {
									return input.getEObjectURI().equals(eObjectURI);
								}
							}).iterator();
					if (eObjectDescriptions.hasNext()) {
						return eObjectDescriptions.next();
					}
				}
			}
			
			SimpleAttributeResolver<EObject, String> resolver = SimpleAttributeResolver.newResolver(String.class, "name");
			EAttribute attribute = resolver.getAttribute(element);
			String name = attribute.toString();
			if (name != null)
				return new EObjectDescription(name, element, null);
			return null;
		}
Comment 1 Sebastian Zarnekow CLA 2010-12-03 15:40:11 EST
Seems to be a duplicate of bug 301275

*** This bug has been marked as a duplicate of bug 301275 ***