Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()?
How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897741] Wed, 25 July 2012 07:57 Go to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
I have a language which allows to extend base models:

lib B extends A {}

When I try code completion after "extends", Xtext offers me "B" which doesn't make sense. So I wrote a method in ModelScopeProvider which extends AbstractDeclarativeScopeProvider:

public IScope scope_Lib_baseLib( Lib lib, EReference ref ) {
IScope delegateScope = delegateGetScope( lib, ref );

... remove "lib" from delegateScope ...
return delegateScope;
}

How do remove lib from delegateScope?

Regards,

A. Digulla
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897745 is a reply to message #897741] Wed, 25 July 2012 08:04 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Okay, I'm one step further:

    public IScope scope_Lib_baseLib( Lib lib, EReference ref ) {
        IScope delegateScope = delegateGetScope( lib, ref );

        Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>() {
            @Override
            public boolean apply( IEObjectDescription input ) {
                return !input.getEObjectOrProxy().equals( lib );
            }
        };
        result = new FilteringScope( delegateScope, filter  ); 
        return result;
    }


Is this the correct way to compare an IEObjectDescription and an EObject to see whether they are equal?

Regards,

A. Digulla

[Updated on: Wed, 25 July 2012 08:14]

Report message to a moderator

Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897790 is a reply to message #897745] Wed, 25 July 2012 09:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi for perf reasons: why dont you simply compare the libs qualified
name (I qualified name provider) with the eobjectdesxriptions
qualified name

--
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897858 is a reply to message #897790] Wed, 25 July 2012 10:24 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Christian Dietrich wrote on Wed, 25 July 2012 11:01
for perf reasons: why dont you simply compare the libs qualified
name (I qualified name provider) with the eobjectdesxriptions
qualified name


Two reasons:

1. I'm not sure how Xtext builds qualified names and whether it's guaranteed that the same symbols have the same name (someone said EMF proxies don't have qualified names)

2. Because I don't know how to get a qualified name for an EObject.

Regards,

A. Digulla
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897863 is a reply to message #897858] Wed, 25 July 2012 10:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I said: ask the ieobjectdescription for its qualifiedname and use an
injected Iqualifiednameprovider to obtain the qualifiedname of your
local eobject

--
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897901 is a reply to message #897863] Wed, 25 July 2012 11:56 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Is this code correct, then?

    @Inject
    private IQualifiedNameProvider qualifiedNameProvider;

    public IScope scope_Lib_baseLib( Lib lib, EReference ref ) {
        IScope delegateScope = delegateGetScope( lib, ref );

        final QualifiedName nameFilter = qualifiedNameProvider.getFullyQualifiedName( lib );
        Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>() {
            @Override
            public boolean apply( IEObjectDescription input ) {
                return !nameFilter.equals( input.getQualifiedName() );
            }
        };
        IScope result = new FilteringScope( delegateScope, filter  ); 

        return result;
    }
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897917 is a reply to message #897901] Wed, 25 July 2012 12:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Yes

--
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I filter the result of AbstractDeclarativeScopeProvider.delegateGetScope()? [message #897939 is a reply to message #897917] Wed, 25 July 2012 13:29 Go to previous message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Thanks a lot Smile After my horrible experience earlier this week, I'm overcautious.

Regards,

A. Digulla
Previous Topic:semantic highlighting stopped working for comments ?
Next Topic:.ecore models in linked folders not indexed
Goto Forum:
  


Current Time: Tue Apr 23 13:59:27 GMT 2024

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

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

Back to the top