Bug 382535 - Let ImportedNamespaceAwareLocalScopeProvider use IDefaultResourceDescriptionStrategy
Summary: Let ImportedNamespaceAwareLocalScopeProvider use IDefaultResourceDescriptionS...
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-13 14:34 EDT by Christian Dietrich CLA
Modified: 2013-04-01 02:30 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2012-06-13 14:34:17 EDT
Build Identifier: 2.3.0

if one customized IDefaultResourceDescriptionStrategy this changes will not be reflected in the local resource since scoping uses 

org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetAllDescriptions(Resource)

which calls Scopes.scopedElementsFor(allContents, qualifiedNameProvider)

=> you have to customize the ImportedNamespaceAwareLocalScopeProvider too
if you e.g. add user data to the index.

it would be nice to have a default/optional shipped implementation that does this out of the box e.g.


@Inject
	private IDefaultResourceDescriptionStrategy rds;
	
	@Override
	protected ISelectable internalGetAllDescriptions(final Resource resource) {
		Iterable<EObject> allContents = new Iterable<EObject>(){
			public Iterator<EObject> iterator() {
				return EcoreUtil.getAllContents(resource, false);
			}
		}; 
		final List<IEObjectDescription> allDescriptions = new ArrayList<IEObjectDescription>();
		IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
			
			@Override
			public void accept(IEObjectDescription t) {
				allDescriptions.add(t);
			}
		};
		for (EObject o : allContents) {
			rds.createEObjectDescriptions(o, acceptor);
		}
		return new MultimapBasedSelectable(allDescriptions);
	}


Reproducible: Always
Comment 1 Jan Koehnlein CLA 2012-06-26 08:14:23 EDT
I agree the user data should be there for local elements, too.
 
OTOH, the IDefaultResourceDescriptionStrategy.createEObjectDescription() also determines which elements should be indexed at all, i.e. referrable from the outside, by retrunning null. Local elements are by default always referrable. So your approach would only make the globally visible elements referrable locally.

Feels like the IDefaultResourceDescriptionStrategy.createEObjectDescription
is a bit overloaded.
Comment 2 Christian Dietrich CLA 2012-06-26 08:18:15 EDT
So maybe we need a generic IEObjectDescriptionUserDataStrategy
Comment 3 Jan Koehnlein CLA 2012-06-26 08:24:35 EDT
I'd prefer a method 
  boolean isIndexed(EObject)
on the IDefaultResourceDescriptionStrategy.