Retrieve index without having to load resources in standalone context? [message #1732478] |
Tue, 17 May 2016 10:53  |
Eclipse User |
|
|
|
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!
|
|
|
|
|
Re: Retrieve index without having to load resources in standalone context? [message #1732641 is a reply to message #1732580] |
Wed, 18 May 2016 14:25   |
Eclipse User |
|
|
|
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!
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03215 seconds