Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Linkage between scope and contentassistant??
Linkage between scope and contentassistant?? [message #1067604] Tue, 09 July 2013 10:33 Go to next message
Sascha Gstir is currently offline Sascha Gstir
Messages: 12
Registered: May 2013
Junior Member
Hey guys,

can anyone tell me how the scope and the ScopeProvider is linked with the contentassistant and the ProposalProvider?
Or are they linked at all?

I want to know it because in my DSL I have some cases where I have to limit the
available proposals of the contentassistant.

For example:
I have C like if-statements in my DSL in which conditions I can make references to
formulate this conditions. This works perfect and the contentassistant shows all
available objects. But in some cases for example if the if-statement is in a "Template" object I want to limit the available proposals to object which are in the same
"template" object.

So how can I change this behaviour? Do I have to write a ScopingProvider or a
ProposalProvider?

I hope was able to make my problem clear so that you can give me some advices.
Re: Linkage between scope and contentassistant?? [message #1067614 is a reply to message #1067604] Tue, 09 July 2013 10:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hi,

the ProprosalProvider calls (with some indirections)
org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.lookupCrossReference(EObject, EReference, ICompletionProposalAcceptor, Predicate<IEObjectDescription>, Function<IEObjectDescription, ICompletionProposal>)

So you can actually pass in a predicate to filter stuff.

Re: Linkage between scope and contentassistant?? [message #1067623 is a reply to message #1067614] Tue, 09 July 2013 12:21 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 65
Registered: December 2012
Location: Belfast
Member
I noticed the (generated) super class of my ProposalProvider assumes it has an XBaseScopeProvider (it casts the result getScopeProvider() to XBaseScopeProvider) when in fact it doesn't. This throws a cast exception when I use content assist.

I did originally have an xbase scope provider so it worked ok, but when I moved to 2.4 I changed it because it is deprecated. Now the scoping works again but I can't see how to change the abstract 'mydsl' proposal provider because it is a generated class.

Is it something in the runtime/mwe modules that determines what the super class of the generated proposal provider is?
Re: Linkage between scope and contentassistant?? [message #1067683 is a reply to message #1067623] Wed, 10 July 2013 02:16 Go to previous messageGo to next message
Sascha Gstir is currently offline Sascha Gstir
Messages: 12
Registered: May 2013
Junior Member
I am still a little bit confused.

Do you maybe have a short example for me how such a predicate or ProposalProvider has to look like?
Re: Linkage between scope and contentassistant?? [message #1067684 is a reply to message #1067683] Wed, 10 July 2013 02:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Simply have a look at completeXXXxxxx_yyyyy in the abstract
superclass of your MyDslProposalProvider

--
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
Re: Linkage between scope and contentassistant?? [message #1067708 is a reply to message #1067623] Wed, 10 July 2013 04:54 Go to previous messageGo to next message
Victor Noël is currently offline Victor Noël
Messages: 112
Registered: June 2010
Senior Member
Your ScopeProvider MUST be extending XbaseScopeProvider if you use xbase.
You can always have a class extending a DeclarativeScopeProvider and delegate to it in the ScopeProvider extending XbaseScopeProvider for your grammar elements while calling super.getScope for the rest of the grammar.

Then, to filter VALID elements you have two choices:
either using only scopes
either using proposal filtering + validation

It will depends on the particular thing that you want to filter I think.
Re: Linkage between scope and contentassistant?? [message #1067740 is a reply to message #1067708] Wed, 10 July 2013 07:49 Go to previous message
Ian McDevitt is currently offline Ian McDevitt
Messages: 65
Registered: December 2012
Location: Belfast
Member
I will move my comment to a new thread. I don't want to redirect the topic of this one too much as it is more about proposals and scope than just scope.
Thanks
Ian
Previous Topic:Xtext and Eclipse e4
Next Topic:Xtend Template Expression Problem
Goto Forum:
  


Current Time: Thu Jul 31 09:35:17 EDT 2014

Powered by FUDForum. Page generated in 0.01956 seconds