restriction/clear of index [message #1065938] |
Fri, 28 June 2013 12:21 |
Phil H Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Hi,
in my xtext project I'm using ResourceDescriptions for accesing EObjects. Therefor I implemented a ResourceDesciption where the computeExportedObjects method returns the desired objects. Also I've an according ResourceDescriptionManager and ServiceProvider which works so far.
But I observed the following behaviour. When I've several files, for example:
default1.pld: ObjectA, ObjectB, ObjectC
default2.pld: ObjectD, ObjectE
When I work in the default1.pld file, the computeExportedObjects returns the objetcs A,B,C and default2.pld accordingly D and E which is what I expected.
What I expected is that in default1.pld I can only acces the objects A,B,C and in default2.pld only D and E. But rather it is possible to acces all objects in both files (e.g. default1 can see A,B,C,D,E instead of A,B,C).
I'm not really familiar how this is working in xtext, but I reckon all returns of the computeExportedObjects method will be stored in an index?
So is there a way to clear the index before computeExportedObjects is called or even a better solution?
|
|
|
|
|
|
|
Re: restriction/clear of index [message #1065974 is a reply to message #1065971] |
Fri, 28 June 2013 14:41 |
|
No,
there is one index for the whole workspace. It contains a IResourceDescription for every resource (file). (you can imaging this as map of maps)
the org.eclipse.xtext.resource.IContainer.Manager takes care of visibility.
So here is what happens in default setup
Your Local Scopeprovider (AbstractDeclarativeScopeProvider)
delegates to ImportedNamespaceAwareLocalScopeProvider (AbstractGlobalScopeDelegatingScopeProvider)
delegates to DefaultGlobalScopeProvider (IGlobalScopeProvider)
delegates to visisible Conainers via IContainer.Manager)
so depending on your needs you have multiple places to hook in.
e.g. by saying org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider.getGlobalScope(Resource, EReference, Predicate<IEObjectDescription>)
returns null.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: restriction/clear of index [message #1065995 is a reply to message #1065974] |
Fri, 28 June 2013 17:28 |
Phil H Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Thank you for your explanations. I think that I've understand it now a little bit more (though it's only a little bit I know about xtext). Are there maybe some examples?
But what I quite don't understand is how to hook in. Have I got to define my own implementation somewhere in my xtext project like this:
public class MyAbstractGlobalScopeDelegatingScopeProvider extends AbstractGlobalScopeDelegatingScopeProvider{
@Override
public IScope getScope(EObject context, EReference reference) {
// TODO Auto-generated method stub
return null;
}
}
and bind it to my RuntimeModule?:
public class PldxRuntimeModule extends org.itea2.amalthea.model.variability.xtext.AbstractPldxRuntimeModule {
public Class<? extends AbstractGlobalScopeDelegatingScopeProvider> bindAbstractGlobalScopeDelegatingScopeProvider() {
return MyAbstractGlobalScopeDelegatingScopeProvider.class;
}
}
[Updated on: Fri, 28 June 2013 17:32] Report message to a moderator
|
|
|
Re: restriction/clear of index [message #1065999 is a reply to message #1065995] |
Fri, 28 June 2013 18:08 |
|
No
this is not what i intended. i wanted you to subclass ImportedNamespaceAwareLocalScopeProvider (or whatever is used in your setup) and bind it like ImportedNamespaceAwareLocalScopeProvider is bound
public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.class);
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04026 seconds