Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Restrict Index (EObjectDescriptions)
Restrict Index (EObjectDescriptions) [message #1174768] Thu, 07 November 2013 04:55 Go to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
Hello Guys,

I use Xtext to parse very large projects. Due to possible memory issues I want to limit the EObjectDescriptions to one Project and not as default to the entire Workspace. Could you tell me which class is responsible for that type of scoping?
Thank you...

Re: Restrict Index (EObjectDescriptions) [message #1175100 is a reply to message #1174768] Thu, 07 November 2013 09:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

have a look at DefaultResourceDescriptionStrategy/IDefaultResourceDescriptionStrategy
Re: Restrict Index (EObjectDescriptions) [message #1175101 is a reply to message #1175100] Thu, 07 November 2013 09:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Or for the other side: DefaultGlobalScopeProvider
Re: Restrict Index (EObjectDescriptions) [message #1175449 is a reply to message #1174768] Thu, 07 November 2013 14:23 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
Thanks Guys. I found out that the ... is used in the class DefaultResourceDescriptionManager ...

I cannot find a method in "UiModule" which allows me to populate a custom DefaultResourceDescriptionManager Sad

Could you help me with that?
Re: Restrict Index (EObjectDescriptions) [message #1175462 is a reply to message #1175449] Thu, 07 November 2013 14:31 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
I found the following Method:

	public Class<? extends IResourceDescription.Manager> bindIResourceDescriptionManager() {
		return DerivedStateAwareResourceDescriptionManager.class;
	}


But with this, i get the following exception:

0 [main] ERROR org.eclipse.xtext.ui.editor.CompoundXtextEditorCallback - org.eclipse.xtext.linking.lazy.LazyLinkingResource cannot be cast to org.eclipse.xtext.resource.DerivedStateAwareResource
java.lang.ClassCastException: org.eclipse.xtext.linking.lazy.LazyLinkingResource cannot be cast to org.eclipse.xtext.resource.DerivedStateAwareResource
at org.eclipse.xtext.resource.DerivedStateAwareResourceDescriptionManager.internalGetResourceDescription(DerivedStateAwareResourceDescriptionManager.java:41)
at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager$1.get(DefaultResourceDescriptionManager.java:60)
at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager$1.get(DefaultResourceDescriptionManager.java:1)

....
Re: Restrict Index (EObjectDescriptions) [message #1175468 is a reply to message #1175462] Thu, 07 November 2013 14:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

the hook to customize is the resourcedescriptionstrategy, simply add a new bindXXX method to the runtime/ui module
Re: Restrict Index (EObjectDescriptions) [message #1181386 is a reply to message #1175468] Mon, 11 November 2013 10:16 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
Hi,

i am working on customizing ResourceDescriptionsProvider. I am trying to override the following method:

public IResourceDescriptions getResourceDescriptions(Resource resource) {	
		return getResourceDescriptions(resource.getResourceSet());
	}


by filtering the resourceset from the resource ... is that the correct way to limit the scope to a project?

Thank you!
Re: Restrict Index (EObjectDescriptions) [message #1181394 is a reply to message #1181386] Mon, 11 November 2013 10:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

i dont understand what you are doing:

All Projects that are in the Workspace are Indexed.

you can
- restrict the number of object that are index
- restrict the visibility (dont see other projects- but this will save you zero memory)
Re: Restrict Index (EObjectDescriptions) [message #1181413 is a reply to message #1181394] Mon, 11 November 2013 10:38 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
I want to restrict visibility to only one project at a time and maybe if its possible to exclude special resources from it. How is that possible?

Maybe later it would be nice to reduce the amout of memory ...
Re: Restrict Index (EObjectDescriptions) [message #1181518 is a reply to message #1181413] Mon, 11 November 2013 11:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

in this case have a look at WorkspaceProjectsStateHelper/JavaProjectsStateHelper
they have a look at visible projects (initVisibleHandles(String handle))

or at org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.getVisibleContainers(Resource)
Re: Restrict Index (EObjectDescriptions) [message #1182460 is a reply to message #1181518] Tue, 12 November 2013 02:43 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
Good morning,

i am trying this:
protected List<IContainer> getVisibleContainers(Resource resource) {
		List<IContainer> containers = super.getVisibleContainers(resource);
		
		System.out.println("resource: " + resource.getURI());
		for(IContainer container : containers) {
			System.out.println("\tcontainer: + "+ container);
		}
		
		return containers;
	}


But here, i cannot see a resource which has a foregin container. Where do i need to customize to limit my resource descriptions to project and not to the entire workspace? Thank you Smile
Re: Restrict Index (EObjectDescriptions) [message #1182466 is a reply to message #1182460] Tue, 12 November 2013 02:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi I do not understand what you try to do.
The code is used if you have a reference from one project to another.

If you don't have this so what are you actually doing in your code
that you have a problem at all...

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Restrict Index (EObjectDescriptions) [message #1182477 is a reply to message #1182466] Tue, 12 November 2013 02:58 Go to previous messageGo to next message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
My Problem is the following:

in my ScopeProvider i am trying to scope among multiple files:

	def IScope scope_GoStatement_sub(GoStatement statement, EReference ref) {
		if(resourceDescriptions == null) {
			resourceDescriptions = resourceDescriptionsProvider.createResourceDescriptions();
		}
		
		val allSubStatements = <EObject>newArrayList();
		for(resourceDescription : resourceDescriptions.getAllResourceDescriptions()) {				
			val subStatements = resourceDescription.getExportedObjectsByType(MyDslPackage.eINSTANCE.subroutine);
						
			for(objectDescription : subStatements) {			
				if(objectDescription.EObjectOrProxy.eIsProxy) {
					val object = EcoreUtil.resolve(objectDescription.EObjectOrProxy, statement);		
					println(object);		
					allSubStatements.add(object);
				}
			}	
		}	
		
		return Scopes::scopeFor(allSubStatements);
	}


But i get all resource descriptions with the following line:
resourceDescriptions = resourceDescriptionsProvider.createResourceDescriptions();


even these who are not in my project Sad

There i want to to limit the descriptions project wise.


How can that be done?
Re: Restrict Index (EObjectDescriptions) [message #1182508 is a reply to message #1182477] Tue, 12 November 2013 03:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6145
Registered: July 2009
Senior Member
Hi,

its your code that is buggy.
you have to use the container manager or the globalscopeprovider.

if you simply want to filter what is there put

delegateGetScope(ctx, ref) intro a FilteringScope
Re: Restrict Index (EObjectDescriptions) [message #1182626 is a reply to message #1182508] Tue, 12 November 2013 04:57 Go to previous message
Marc Herrmann is currently offline Marc Herrmann
Messages: 19
Registered: November 2013
Junior Member
Thanks for your help!

This is what i achievied for now in the global scope provider to filter certain files:

@Override	
	protected IScope getScope(IScope parent, final Resource context, boolean ignoreCase, EClass type, Predicate<IEObjectDescription> filter) {
		Predicate<IEObjectDescription> newFilter = new Predicate<IEObjectDescription>() {
			public boolean apply(IEObjectDescription description) {
				if(description.getEObjectURI().lastSegment().endsWith("tvs"))
					return false;
				
				return true;
			}
		};
		
		IScope scope = super.getScope(parent, context, ignoreCase, type, newFilter);
				
	
		
		return scope;
	}


Is that a good idea? Is there an example maybe how to scope between files?

Previous Topic:Validation in xtext
Next Topic:Infinite looping in partial parser
Goto Forum:
  


Current Time: Sat Aug 02 02:37:12 EDT 2014

Powered by FUDForum. Page generated in 0.10970 seconds