Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » restriction/clear of index
restriction/clear of index [message #1065938] Fri, 28 June 2013 12:21 Go to next message
Phil H is currently offline Phil HFriend
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 #1065944 is a reply to message #1065938] Fri, 28 June 2013 12:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

the restriction is ususally done by scoping. (have a look at org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider and subclasses)

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: restriction/clear of index [message #1065957 is a reply to message #1065944] Fri, 28 June 2013 13:24 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Hi,

I'm already using scoping in another context which works great so far...

But for this context, scoping isn't possible because I'm using Xtext in GMF..maybe restriction isn't the right word to describe what I'm meaning..

What I want is simply an index for every file and not an index for all files..is this possible? Or how can I access the index?
Re: restriction/clear of index [message #1065959 is a reply to message #1065957] Fri, 28 June 2013 13:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

the index gives you a complete overview.
what you get depends on how you ask it.
if you want to see what a specific resource has to offer you have
to ask for it. org.eclipse.xtext.resource.IResourceDescriptions.getResourceDescription(URI)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: restriction/clear of index [message #1065971 is a reply to message #1065959] Fri, 28 June 2013 14:20 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Christian Dietrich wrote on Fri, 28 June 2013 15:27
Hi,

the index gives you a complete overview.
what you get depends on how you ask it.


So there is an index for every project? And every object in every file in one project is in the same index?

But where will the index be asked? For example I'm using the content assistant, it shows me all objects. Have I to customize this?
Re: restriction/clear of index [message #1065974 is a reply to message #1065971] Fri, 28 June 2013 14:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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
Re: restriction/clear of index [message #1066171 is a reply to message #1065999] Mon, 01 July 2013 11:14 Go to previous messageGo to next message
Phil H is currently offline Phil HFriend
Messages: 267
Registered: November 2012
Senior Member
Thx Christian,

I've bound it now in this way, but couldn't notice any effects. I've set a breaking point to the getGlobalScope method, but it's never used. Am I'm missing something?

public class PldxRuntimeModule extends
		org.itea2.amalthea.model.variability.xtext.AbstractPldxRuntimeModule {

	public void configureIScopeProviderDelegate(Binder binder) {
		binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class)
				.annotatedWith(
						Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
				.to(MyImportedNamespaceAwareLocalScopeProvider.class);
	}


public class MyImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
	
	protected IScope getGlobalScope(Resource context, EReference reference){
		System.out.println("Resources: " + context);
		return null;
	}

}
Re: restriction/clear of index [message #1066179 is a reply to message #1066171] Mon, 01 July 2013 12:33 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi sorry don't know. Debug the chain I mentioned

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:ignoreCase for Serializer 2.0
Next Topic:Duplicate methodes in generated SemanticSequencer
Goto Forum:
  


Current Time: Thu Mar 28 12:44:31 GMT 2024

Powered by FUDForum. Page generated in 0.02424 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top