Bug 477178 - ResourceDescriptionsProvider given null in the open editor when renaming its file
Summary: ResourceDescriptionsProvider given null in the open editor when renaming its ...
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.8.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-11 07:51 EDT by Christian Dietrich CLA
Modified: 2015-09-23 08:01 EDT (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 Christian Dietrich CLA 2015-09-11 07:51:01 EDT
Assume we have the following grammar:

Model:
	entities+=Entity*;
	
Entity:
	'entity' name=ID ('extends' extends=[Entity])? '{'
		arributes+=Attribute*
'}'
;

Attribute:
	'attr' name=ID
;

And these model files

file1.mydsl

entity file1 {
	attr a1
	attr a2
}

file2.mydsl

entity file2 extends file1 {
	
}

the editor for file2 is open and i do a file rename (F2) on file2.mydsl

now if i (e.g in scoping) am asking the resourceserviceprovider for the resource description of the resource i am working on, then i get null as result.

(we use the index to create some implicit imports)

to reproduce that simply use

public class MyDslImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
	
	 @Inject
	 private ResourceDescriptionsProvider resDescProvider;
	
	@Override
	protected IScope getResourceScope(Resource res, EReference reference) {
		new Exception().printStackTrace();
		URI uri = res.getURI();
		System.err.println(uri);
		 IResourceDescriptions index = resDescProvider
                 .getResourceDescriptions(res);
		 System.err.println(index);
         IResourceDescription resourceDescription = index
                 .getResourceDescription(uri);
         System.err.println(resourceDescription);
         System.err.println("=============");
		return super.getResourceScope(res, reference);
	}

}

	@Override
	public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
		binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(
				MyDslImportedNamespaceAwareLocalScopeProvider.class);
	}
Comment 1 Christian Dietrich CLA 2015-09-11 08:32:25 EDT
Alternatively: is there a way to get this visible containers without having a starting resource description? or could i even create a fake start resource description?
Comment 2 Christian Dietrich CLA 2015-09-11 08:35:02 EDT
(we use the index data to create implicit imports)
Comment 3 Sebastian Zarnekow CLA 2015-09-11 08:54:09 EDT
Wouldn't @Inject IResourceDescription.Manager manager and manager.getResourceDescription() work?
Comment 4 Christian Dietrich CLA 2015-09-11 08:56:37 EDT
ill have a look an that. i just saw global scope provider uses the manager as well? when should the Manager and when the IResourceDescriptions itself be used?
Comment 5 Sebastian Zarnekow CLA 2015-09-23 07:37:50 EDT
(In reply to Christian Dietrich from comment #4)
> ill have a look an that. i just saw global scope provider uses the manager
> as well? when should the Manager and when the IResourceDescriptions itself
> be used?

I assume this question was answered in the meantime? Is this ticket still open?
Comment 6 Christian Dietrich CLA 2015-09-23 08:01:55 EDT
i think we can live with that behavour. although a hint in the javadoc would be nice