Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to limit content assist according to scoping
How to limit content assist according to scoping [message #1015142] Wed, 27 February 2013 14:58 Go to next message
Marco Naddeo is currently offline Marco Naddeo
Messages: 62
Registered: November 2012
Member
Hi Smile

I have defined MyDSLScopeProvider to suitably restrict the scope of cross-references in my language. Now I correctly obtain an error if I try to cross-reference an element of the right type, but outside of the defined scope.

On the other hand, using the content assist functionality by pressing CTRL+SPACE in my Xtext editor, I still obtain a list of all elements of the type specified in the cross-reference definition in the grammar, that is a list which is still unfiltered by scoping.

Scoping and content assist are independent from each other?

As far as I understand, I have to override in MyDSLProposalProvider the appropriate methods from AbstractMyDSLProposalProvider, but how? Is there an example of that?


Thanks in advance,
Marco
Re: How to limit content assist according to scoping [message #1015159 is a reply to message #1015142] Wed, 27 February 2013 15:36 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 65
Registered: December 2012
Location: Belfast
Member
I've been looking at this too recently and have found myself spending a lot of time between my overridden ScopeProvider and ProposalProvider classes.
I inherited from the XbaseProposalProvider and implemented a few completeXYZ() methods where XYZ is one of my ParserRules that I want completion proposals for.

I had found a few mentions about it to let me know it should be achievable but not enough in the way of examples to let me undestand it and get it working without a lot of trial, error and debugging.

Some attempts give nothing while others include eveything on the planet.

Basically for the Xbase option you choose the completeXYZ method you need and write your custom proposal provider to query your custom scope for the prefix, if any, supplied in the context assist parameter. I expect in your case the default proposal provider would be using the default scope provider and not yours. Even though I had specified my classes in the runtime module, there were still code in the super class that was calling other super class methods and so I had to start overriding more methods to get them to work.

I'd be interested in any other responses with worked examples too.
Re: How to limit content assist according to scoping [message #1015166 is a reply to message #1015159] Wed, 27 February 2013 15:47 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco Naddeo
Messages: 62
Registered: November 2012
Member
I found this topic message where it is said that the proposal function is based, by default, on scoping. Is that true?

If yes, then why I still obtain all possible references, not filtered via scoping? Any suggestions? Confused

[Updated on: Thu, 28 February 2013 14:27]

Report message to a moderator

Re: How to limit content assist according to scoping [message #1015186 is a reply to message #1015166] Wed, 27 February 2013 17:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6290
Registered: July 2009
Senior Member
Hi yes this is true. Can you share sample grammar and scoping

--
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: How to limit content assist according to scoping [message #1015189 is a reply to message #1015166] Wed, 27 February 2013 17:27 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 65
Registered: December 2012
Location: Belfast
Member
Proposals have a dependency on scoping. It may be the proposer isn't calling your scoping function, I found it calling its other member functions which I also had to overide - some debugging or logging may tell.

Or does your custom scope have an outer parent scope which is being included by default. Your scope may need to be an isolated list of items with no outer scope.

I think the reason it includes outer scopes by default is to allow you to show what may be possible under other situations (a bit like showing a greyed out button rather than no button at all). So you may see all methods even private ones which you can't call. If you don't like that then you supply filtering of your choice, but I know what you mean - it seems odd to have only 3 items in your scope and get 30 poposed to you from the outer scope.

I'm planning to rework mine to get the proposals and scoping more closely aligned (i.e. get it to work). Scoping first, then proposals.

Thanks for that link to the other example it looks straight forward.

Re: How to limit content assist according to scoping [message #1015197 is a reply to message #1015189] Wed, 27 February 2013 17:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6290
Registered: July 2009
Senior Member
P.S: i think the problem is often xtexts lazy object creation
(affects you if the cross reference i the first "real" thing (first assignment) in the rule for the object

XXX: "keyword" yyy=[KKK]

then you have 2 possibilities to workaround this
(1) use scope_XXX_yyy(ParentObject ctx, Ereference ref) instead of scope_XXX_yyy(XXX ctx, Ereference ref)
(2) try to use a unassigned action to force xtext to create the object eager
XXX: {XXX}"keyword" yyy=[KKK]
Re: How to limit content assist according to scoping [message #1015411 is a reply to message #1015197] Thu, 28 February 2013 14:03 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco Naddeo
Messages: 62
Registered: November 2012
Member
Thanks for your help, Ian and Christian!

I solved it, I simply scoped only one of two alternatives in the grammar... Shocked

Now I have scoped both of them, and it works. Wink

Another question: if I want to trigger content assist on dot typing, as in Java editor, how can I get this?
Re: How to limit content assist according to scoping [message #1015413 is a reply to message #1015411] Thu, 28 February 2013 14:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6290
Registered: July 2009
Senior Member
Hi do you mean something like
http://christiandietrich.wordpress.com/2011/09/19/xtext-content-assist-
auto-activation/

--
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: How to limit content assist according to scoping [message #1015905 is a reply to message #1015413] Mon, 04 March 2013 08:56 Go to previous messageGo to next message
Marco Naddeo is currently offline Marco Naddeo
Messages: 62
Registered: November 2012
Member
Another question: now I obtain my content proposal correctly scoped and triggered on dot typing, but between the various proposals I also get the dot itself, and I don't understand why: the grammar is not expected that there may be two points below each other, and in fact if I select the dot from the drop-down menu, anything is added to the code, so that I do not understand the usefulness of this proposal. Shocked

How can I remove it from the drop-down menu?


Thanks again Rolling Eyes,
Marco
Re: How to limit content assist according to scoping [message #1053012 is a reply to message #1015411] Wed, 01 May 2013 22:00 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 47
Registered: January 2013
Member
What did you mean by
Quote:
I solved it, I simply scoped only one of two alternatives in the grammar.


I have the same problem, but couldn't understand what your solution is.

Thanks,
Roza
Re: How to limit content assist according to scoping [message #1053016 is a reply to message #1053012] Thu, 02 May 2013 00:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6290
Registered: July 2009
Senior Member
The solution is to define the scope method as follows

scope_Child_ref(Parent ctx, EReference r)
Re: How to limit content assist according to scoping [message #1053066 is a reply to message #1015905] Thu, 02 May 2013 10:15 Go to previous message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Hi,

generally speaking, content assist shows all alternatives possible at the current position, taking into account a potential prefix. The proposal may be identical to the prefix. This will the case for your dot-question.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:UI model validation
Next Topic:creating abstract class in the meta model
Goto Forum:
  


Current Time: Tue Sep 16 00:54:23 GMT 2014

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

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