Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Retrieve index without having to load resources in standalone context?
Retrieve index without having to load resources in standalone context? [message #1732478] Tue, 17 May 2016 14:53 Go to next message
Niels Brouwers is currently offline Niels BrouwersFriend
Messages: 79
Registered: July 2009
Member
Hi,

Is there a way to be able to retrieve the index on a XtextResourceSet index in Java stand-alone configuration, without having to explicitly load the resources when adding them to the XtextResourceSet instance?

Example code:

ResourceSet rs = new XtextResourceSet();
Resource r = rs.getResource(ROOT_MODELS_URI.appendSegment("a.hddd"), false);
IResourceDescriptions index = rdp.getResourceDescriptions(rs);
Iterable<IEObjectDescription> exported = index.getExportedObjects();


In my case, the index is an object of type ResourceSetBasedResourceDescriptions. The index object doesn't contain any data. When loading the models when adding them to the resourceset, the index contains the values as expected.

What do I need to do to trigger building the index?

Thanks!


Kind regards,
Niels Brouwers.
Re: Retrieve index without having to load resources in standalone context? [message #1732488 is a reply to message #1732478] Tue, 17 May 2016 15:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
in a standalone app it is your JOB to add all resources to the resourceset.
so please explain what behaviour are you expecting?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Retrieve index without having to load resources in standalone context? [message #1732580 is a reply to message #1732488] Wed, 18 May 2016 11:05 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
In Eclipse, the workspace is the scope for your index. In standalone, you have to define that scope yourself.
Where do you expect the index data to come from?


---
Get professional support from the Xtext committers at www.typefox.io
Re: Retrieve index without having to load resources in standalone context? [message #1732641 is a reply to message #1732580] Wed, 18 May 2016 18:25 Go to previous message
Niels Brouwers is currently offline Niels BrouwersFriend
Messages: 79
Registered: July 2009
Member
Thanks for your replies.

In the context of Eclipse, and please correct me if I am wrong, IResourceDescription objects are created by the Xtext builder. It loads and traverses the models it can find on it's class path to create these objects. In this scenario, the actual loading (and unloading?) of the resources is therefore performed by the builder.

I was wondering if there is an additional helper class that I could invoke that creates the IResourceDescription objects for all the resouces in the XtextResourceSet. If there was, I would expect such helper class to load the resources to create the objects, and unloads the resources when it's done. In this case, I could load only the modes in the XtextResourceSet that are of particular interest, and perform additional queries on the index for performance reasons, i.e. to find all the objects referencing elements within the loaded resources.

If such a additional helper class does not exist, I can only load all the models I can find in my 'scope' in the XtextResourceSet to populate the full index. This would potentially result in lower performance and higher memory usage, as all models need to remain loaded, right?

I realize that you might need some more explanation on the use case I aim to implement. Use case:

  • I have two sets of models; a set of 'essential' models and a set of 'decorator' models. The latter category of models contain elements that 'decorate' an element from an essential model. This is implemented by the decorating element to have a reference to the decorated element. The decorating element contains additional meta-data useful for a particular context.
  • In the entire scope, e.g. the Eclipse workspace, I could have multiple coherent set of essential models. Correspondingly, I could have a coherent set of decorator models for each coherent set of essential models.
  • When processing one coherent set of essential models, I would like to discover the corresponding coherent set of decorator models. These are identified by traversing the reference for each decorating element. If it targets an element from the coherent set of essential models, the decorator model is added to the corresponding coherent set of decorator models.
  • For performance reasons, I would like to prevent loading all the decorator models that can be found in the entire scope to be loaded in a single XtextResourceSet and that they keep being loaded. Instead, I would like these generator models to be loaded and traversed only once to build up the complete index. After building up the index, the models can be unloaded and the set of coherent generator models can be found leveraging the performance optimized Xtext index.


Can you please comment on this use case and provide some guidance how to implement this in stand-alone mode with Xtext?

Thanks!


Kind regards,
Niels Brouwers.
Previous Topic:How to integrate xtext plugin inside custom project
Next Topic:@Check Validator with 2 or more parameters
Goto Forum:
  


Current Time: Sun Nov 17 13:48:28 GMT 2019

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

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

Back to the top