Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ResourceSet containing single Resource or all Resources
ResourceSet containing single Resource or all Resources [message #650597] Tue, 25 January 2011 16:33 Go to next message
Nicolas Cabanis is currently offline Nicolas CabanisFriend
Messages: 15
Registered: July 2009
Junior Member
Hello together,

I want to implement my own LinkingService as it seems to me to be the easiest way for me (functionality and performance).

There are about 3200 resources with 15000 first class objects. I want to create a map with FQN -> object.

I assume during linking are all contained objects available as the linking process is about resolving referenced objects.

During a clean build, all resources are available in the ResourceSet of the given context object (it's a XtextResourceSet).

But afterwards if a resource is modified in the editor, the ResourceSet contains only the single resource currently modified (SynchronizedXtextResourceSet). And then, I cannot resolve the links.

Is there a way to have a completely filled ResourceSet? Or is there another way of getting all objects?

Regards,
Nicolas
Re: ResourceSet containing single Resource or all Resources [message #650732 is a reply to message #650597] Wed, 26 January 2011 10:05 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Why not use the default linking based on the index? The index is
automtically populated by a builder and contains all necessary
information to establish the cross links without having to load
everything into memory. It is described in the docs (section on scoping).

Am 25.01.11 17:33, schrieb Nicolas Cabanis:
> Hello together,
>
> I want to implement my own LinkingService as it seems to me to be the
> easiest way for me (functionality and performance).
>
> There are about 3200 resources with 15000 first class objects. I want to
> create a map with FQN -> object.
>
> I assume during linking are all contained objects available as the
> linking process is about resolving referenced objects.
>
> During a clean build, all resources are available in the ResourceSet of
> the given context object (it's a XtextResourceSet).
> But afterwards if a resource is modified in the editor, the ResourceSet
> contains only the single resource currently modified
> (SynchronizedXtextResourceSet). And then, I cannot resolve the links.
>
> Is there a way to have a completely filled ResourceSet? Or is there
> another way of getting all objects?
>
> Regards,
> Nicolas


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: ResourceSet containing single Resource or all Resources [message #650772 is a reply to message #650732] Wed, 26 January 2011 13:34 Go to previous messageGo to next message
Nicolas Cabanis is currently offline Nicolas CabanisFriend
Messages: 15
Registered: July 2009
Junior Member
The index seems not to contain the required objects either. The 'LocalScope' delegates to the 'GlobalScope'. In the 'GlobalScope' the 'findAllEObjects' methods does not find all objects. Now it's the complete opposite - the clean build does not work (or only partly) but the build seems to work if a resource is modified in the editor.

    private IScope getScopeFor_XXX (EObject context)
    {
        EClass type =  XXX
        Resource resource = context.eResource ();
        IResourceDescription description = getDescription (resource);

        IContainer.Manager manager = getResourceServiceProvider (resource).getContainerManager ();
        IContainer container = manager.getContainer (description, index);
        IScope globalScope = new GlobalScope (container, type);
        return new LocalScope (nameProvider, description, type, context, globalScope);
    }

    private class GlobalScope implements IScope
    {
        private final IContainer container;
        private final EClass     type;

        public GlobalScope (IContainer container, EClass type)
        {
            this.container = container;
            this.type = type;
        }

        @Override
        public IEObjectDescription getContentByName (String name)
        {
            Iterable<IEObjectDescription> found = container.findAllEObjects (type, name);
            Iterator<IEObjectDescription> it = found.iterator ();
            if (it.hasNext ()) return it.next ();
            return null;
        }

        ...
}
Re: ResourceSet containing single Resource or all Resources [message #650786 is a reply to message #650772] Wed, 26 January 2011 14:19 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Nicolas,

where does 'index' come from? Please note that the builder cannot use
the injected IResourceDescriptions but uses something that should be
grabbed from the resource set. See getResourceDescriptions(..) in the
AbstractGlobalScopeProvider.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.01.11 14:35, schrieb Nicolas Cabanis:
> The index seems not to contain the required objects either. The
> 'LocalScope' delegates to the 'GlobalScope'. In the 'GlobalScope' the
> 'findAllEObjects' methods does not find all objects. Now it's the
> complete opposite - the clean build does not work (or only partly) but
> the build seems to work if a resource is modified in the editor.
>
>
> private IScope getScopeFor_XXX (EObject context)
> {
> EClass type = XXX
> Resource resource = context.eResource ();
> IResourceDescription description = getDescription (resource);
>
> IContainer.Manager manager = getResourceServiceProvider
> (resource).getContainerManager ();
> IContainer container = manager.getContainer (description, index);
> IScope globalScope = new GlobalScope (container, type);
> return new LocalScope (nameProvider, description, type, context,
> globalScope);
> }
>
> private class GlobalScope implements IScope
> {
> private final IContainer container;
> private final EClass type;
>
> public GlobalScope (IContainer container, EClass type)
> {
> this.container = container;
> this.type = type;
> }
>
> @Override
> public IEObjectDescription getContentByName (String name)
> {
> Iterable<IEObjectDescription> found = container.findAllEObjects (type,
> name);
> Iterator<IEObjectDescription> it = found.iterator ();
> if (it.hasNext ()) return it.next ();
> return null;
> }
>
> ...
> }
>
Re: ResourceSet containing single Resource or all Resources [message #650788 is a reply to message #650786] Wed, 26 January 2011 14:46 Go to previous message
Nicolas Cabanis is currently offline Nicolas CabanisFriend
Messages: 15
Registered: July 2009
Junior Member
Hi Sebastian,

thanks, that solved my problem. I was using the injected index.

Regards
Nicolas
Previous Topic:mwe2 errors trying to build DSL
Next Topic:Converting someone else's grammar style
Goto Forum:
  


Current Time: Tue Sep 24 05:25:56 GMT 2024

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

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

Back to the top