A couple of questions about Scope [message #1044398] |
Thu, 18 April 2013 21:39 |
Steve Kallestad Messages: 62 Registered: March 2013 |
Member |
|
|
I have a couple of questions about scope. Hopefully they are easy.
The first has to do with getting elements within a given parent.
I'm calling
ScopeProvider.getScope(parentEObject, MyDSLPackage.eInstance.getChildElements());
I notice that my result set of Child Elements is not limited to those declared under the parentEObject, but in fact are all of the Child Elements contained within the script. They have qualified names, and I can filter them so it's not a huge problem, but I expected the ScopeProvider to return a limited result set, so I'm wondering if I didn't do something wrong.
===============
My next question is about filtering scope for a unique result. I'm looking for a particular eObject by ID or Name.
IScope scope = sp.getScope(model, MyDSLPackage.eINSTANCE.getMy_Elements());
Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>(){
public boolean apply(IEObjectDescription input) {
if (input.getUserData("name").equals(myString) ||
input.getUserData("id").equals(form))){
return true;
} else {
return false;
}
};
};
IScope filtered = new FilteringScope( scope, filter );
If there are 1000 IEObjectDescriptions to search and the one I'm looking for is the first one, the apply function still continues to process the remaining 999 IEObjectDescriptions. I'm wondering if there is a way to execute an early exit once I find what I'm looking for.
===========
My third question is about indexing/caching of IEObjectDescriptions. I have an expectation of a potentially large amount of imports. I haven't tested a large set just yet, but I'm concerned that if things grow too much the IDE will experience performance problems.
I remember seeing a blog post a while back about implementing an index, but I somehow got the impression that was out-of-the-box now.
Is there a cached index? Or should I look to implement one in my ResourceDescriptionStrategy should the need arise?
|
|
|
Re: A couple of questions about Scope [message #1044613 is a reply to message #1044398] |
Fri, 19 April 2013 05:59 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi,
what do you mean by 'all elements are processed'. When does that happen?
Does it happen if you return 'true' from your filter predicate?
Caching / indexing works behind the scenes but it's possible to screw
that due to wrong assumptions and 'optimizations' in the client code.
As always I suggest to use a profiler before thinking about potential
problems.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 18.04.13 23:39, schrieb Steve Kallestad:
> I have a couple of questions about scope. Hopefully they are easy.
>
> The first has to do with getting elements within a given parent.
>
> I'm calling
>
> ScopeProvider.getScope(parentEObject,
> MyDSLPackage.eInstance.getChildElements());
>
>
> I notice that my result set of Child Elements is not limited to those
> declared under the parentEObject, but in fact are all of the Child
> Elements contained within the script. They have qualified names, and I
> can filter them so it's not a huge problem, but I expected the
> ScopeProvider to return a limited result set, so I'm wondering if I
> didn't do something wrong.
>
> ===============
> My next question is about filtering scope for a unique result. I'm
> looking for a particular eObject by ID or Name.
>
> IScope scope = sp.getScope(model,
> MyDSLPackage.eINSTANCE.getMy_Elements());
> Predicate<IEObjectDescription> filter = new
> Predicate<IEObjectDescription>(){
> public boolean apply(IEObjectDescription input) {
> if (input.getUserData("name").equals(myString) ||
> input.getUserData("id").equals(form))){
> return true;
> } else {
> return false;
> }
> };
>
> };
> IScope filtered = new FilteringScope( scope, filter );
>
>
> If there are 1000 IEObjectDescriptions to search and the one I'm looking
> for is the first one, the apply function still continues to process the
> remaining 999 IEObjectDescriptions. I'm wondering if there is a way to
> execute an early exit once I find what I'm looking for.
>
> ===========
>
> My third question is about indexing/caching of IEObjectDescriptions. I
> have an expectation of a potentially large amount of imports. I haven't
> tested a large set just yet, but I'm concerned that if things grow too
> much the IDE will experience performance problems.
>
> I remember seeing a blog post a while back about implementing an index,
> but I somehow got the impression that was out-of-the-box now.
>
> Is there a cached index? Or should I look to implement one in my
> ResourceDescriptionStrategy should the need arise?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03307 seconds