Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » can scope provider call sort of super and filter obtained matches?
can scope provider call sort of super and filter obtained matches? [message #630829] Tue, 05 October 2010 08:25 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Hi,

for a given reference the default scope provider returns all elements
matching the reference type. This also includes elements from imported
namespaces.

If I customize my DeclarativeScopeProvider I would like to start from
this complete element list and filter it.

How can I obtain this list from the super class?

I tried as a starting point
IScope scope = delegateGetScope(ar, ref);

But the method is called from the LazyLinking as well as from the
ProposalProvider. In the first case I must not invoke getAllContents()
on the scope. But I can not use getContentByName() either since I don't
have a name given here.
In the second case I could use getAllContents() but I can't distinguish
the two cases.

Any hints welcome.

Thanks,
Henrik
Re: can scope provider call sort of super and filter obtained matches? [message #630843 is a reply to message #630829] Tue, 05 October 2010 09:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

have a look at the simple arithmetics example. there is a sample implementation of a filtering scope.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: can scope provider call sort of super and filter obtained matches? [message #630930 is a reply to message #630843] Tue, 05 October 2010 15:20 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
thanks for the hint! That works fine.

Now I encounter a more semantic problem:
If type A has a reference of type B in general any element of type B is
a valid object.
This is restricted only by my model semantics which is imposed e.g. by a
corresponding validation check.
If now my scope provider filters out invalid references in the semantic
sense I may see an error mark with a message "reference not found".
Strictly speaking this is not true since the reference is found but not
valid.
So what I would like to have is a general scope but a strict validation,
which is quite simple to achieve.

But my proposals on the other hand should contain only valid references.

Can I implement that along the lines of
http://www.eclipse.org/Xtext/documentation/latest/xtext.html #contentAssist
by calling the super class implementation with an acceptor delegating
only if the proposal is valid?

Thanks,
Henrik

Am 05.10.2010 11:28, schrieb Christian Dietrich:
> Hi,
>
> have a look at the simple arithmetics example. there is a sample
> implementation of a filtering scope.
>
> ~Christian
Re: can scope provider call sort of super and filter obtained matches? [message #630956 is a reply to message #630930] Tue, 05 October 2010 15:53 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
I just realized, it is not so easy.

The ICompletionProposal doesn't give me the proposed EObject, only a
String to be inserted...

What is the proper way to treat this issue?

Thanks,
Henrik

Am 05.10.2010 17:20, schrieb Henrik Rentz-Reichert:
> thanks for the hint! That works fine.
>
> Now I encounter a more semantic problem:
> If type A has a reference of type B in general any element of type B is
> a valid object.
> This is restricted only by my model semantics which is imposed e.g. by a
> corresponding validation check.
> If now my scope provider filters out invalid references in the semantic
> sense I may see an error mark with a message "reference not found".
> Strictly speaking this is not true since the reference is found but not
> valid.
> So what I would like to have is a general scope but a strict validation,
> which is quite simple to achieve.
>
> But my proposals on the other hand should contain only valid references.
>
> Can I implement that along the lines of
> http://www.eclipse.org/Xtext/documentation/latest/xtext.html #contentAssist
> by calling the super class implementation with an acceptor delegating
> only if the proposal is valid?
>
> Thanks,
> Henrik
>
> Am 05.10.2010 11:28, schrieb Christian Dietrich:
>> Hi,
>>
>> have a look at the simple arithmetics example. there is a sample
>> implementation of a filtering scope.
>>
>> ~Christian
Re: can scope provider call sort of super and filter obtained matches? [message #630993 is a reply to message #630956] Tue, 05 October 2010 18:57 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

strict validation and loose scoping is a common pattern to improve the
error messages. If you want to filter the proposals for cross references
in a generic way, feel free to override
AbstractJavaBasedContentProposalProvider.getProposalFactory( String,
ContentAssistContext)
and return your own subtype of the DefaultProposalCreator. Please note
that you should try to not resolve any proxies when you filter the
descriptions.

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

Am 05.10.10 17:53, schrieb Henrik Rentz-Reichert:
> I just realized, it is not so easy.
>
> The ICompletionProposal doesn't give me the proposed EObject, only a
> String to be inserted...
>
> What is the proper way to treat this issue?
>
> Thanks,
> Henrik
>
> Am 05.10.2010 17:20, schrieb Henrik Rentz-Reichert:
>> thanks for the hint! That works fine.
>>
>> Now I encounter a more semantic problem:
>> If type A has a reference of type B in general any element of type B is
>> a valid object.
>> This is restricted only by my model semantics which is imposed e.g. by a
>> corresponding validation check.
>> If now my scope provider filters out invalid references in the semantic
>> sense I may see an error mark with a message "reference not found".
>> Strictly speaking this is not true since the reference is found but not
>> valid.
>> So what I would like to have is a general scope but a strict validation,
>> which is quite simple to achieve.
>>
>> But my proposals on the other hand should contain only valid references.
>>
>> Can I implement that along the lines of
>> http://www.eclipse.org/Xtext/documentation/latest/xtext.html #contentAssist
>> by calling the super class implementation with an acceptor delegating
>> only if the proposal is valid?
>>
>> Thanks,
>> Henrik
>>
>> Am 05.10.2010 11:28, schrieb Christian Dietrich:
>>> Hi,
>>>
>>> have a look at the simple arithmetics example. there is a sample
>>> implementation of a filtering scope.
>>>
>>> ~Christian
Previous Topic:loading of imported files
Next Topic:unordered group question
Goto Forum:
  


Current Time: Fri Apr 26 08:10:04 GMT 2024

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

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

Back to the top