Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Confusion about completion proposals(suggesting function parameters)
Confusion about completion proposals [message #1036234] Mon, 08 April 2013 05:36 Go to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
In java, when I select a template from the completion proposal list, it shows a little yellow box with a list of local variables that I might want to pass into a given function.

I've customized my ProposalProvider (MyDSL_ProposalProvider extends AbstractMyDSL_ProposalProvider) and I'm getting the right proposals, but they don't appear unless I CTRL+Space to bring it up.

I'm wondering if there's a different proposal provider that I should be working with or if there's a way to automatically bring up the proposal list as I tab through templated parameters similar to what happens with Java in eclipse.
Re: Confusion about completion proposals [message #1036251 is a reply to message #1036234] Mon, 08 April 2013 06:12 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1162
Registered: July 2009
Senior Member
Hi,

have a look at the documentation. There is a section on template proposals and template variable resolution. If you want the proposals for references to be shown automatically you have to use the "Cross Reference Template Variable".

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
Re: Confusion about completion proposals [message #1036279 is a reply to message #1036251] Mon, 08 April 2013 07:12 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
Perfect! I found a couple of relevant web pages - itemis and Karsten's blog that talk about custom template variable resolvers.

For some reason, the cross-reference resolver isn't working the way I had hoped - probably a scoping issue because of the way I have things defined, but rather than chase it down and try to override it, I think it'll be best to build a new resolver and leave the default functionality in place just in case I end up needing it down the road.
Re: Confusion about completion proposals [message #1036801 is a reply to message #1036279] Mon, 08 April 2013 20:49 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
I'm seeing a couple of problems, correct me if I'm wrong:

1) It looks like the first proposal that the variable resolver produces always replaces the text of the variable within the template. (so if your template includes ${MyDescriptiveName:MyTemplateVariable}, MyDescriptiveName disappears before it's displayed to the end user.)

I got around it for now by including the named variable as the first entry in the list, but that doesn't seem ideal to me.

2) Also, the templateVariableResolver.resolveValues() uses a flat arraylist of strings, so if you want your proposals to display one way and produce a formatted result (e.g. surrounded with quotes) that's not a possibility.

and

3) there's no way of associating an icon with a suggestion.

====
I looked around for information that covered these things but came up dry. I can live with things the way they are - none are *really* problems, just nice to haves. I mention them only to double-check that I *once-again* didn't miss something obvious or clearly documented.
Re: Confusion about completion proposals [message #1036819 is a reply to message #1036801] Mon, 08 April 2013 21:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6552
Registered: July 2009
Senior Member
Hi for 2 and 3 you could try to customize templateproposal.apply and
give the positionbasedconpletionporoposal stuff like an image and a
display string

--
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: Confusion about completion proposals [message #1036877 is a reply to message #1036819] Mon, 08 April 2013 23:36 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
Christian - I'm not quite following.

I get the templateproposal.apply, but I don't see where the TemplateVariableResolver actually connects to the TemplateProposal class.

My question is this:

Let's say I want to customize templateproposal.apply - how do I bind that customization so so that it works on the suggestions given by my TemplateVariableResolver?

I tried connecting it to the TemplateProposal by overriding doCreateProposal in my TemplateProposalProvider, but that only gets triggered when the outer template is selected, not on the suggestions from the TemplateVariableResolver.
Re: Confusion about completion proposals [message #1037029 is a reply to message #1036877] Tue, 09 April 2013 05:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6552
Registered: July 2009
Senior Member
Sorry if my answer was missleading- it was just a digging hint - of
course you have to solve these things yourself. When I debug I have a
xtexttemplateproposal in my hand. - you should be able to subclass
it. How to connect the template vars to the metadata - no idea - you
have to digg yourself

--
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: Confusion about completion proposals [message #1037333 is a reply to message #1037029] Tue, 09 April 2013 12:32 Go to previous message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
Thanks again Christian.

I got to digging. This was a difficult task, but in the end I'm happy that I got through it.

JFace's content assist functionality does *NOT* like to be subclassed.

In the end, I decided that it would just be better if the regular content-assist showed up. It wasn't an easy task and I wouldn't recommend it to anyone, but the hooks are in the LinkedModeUI previous and next functions.

Unfortunately getting to those functions is a giant pain and it requires re-building a lot of code from jface because there are a lot of private classes and variables that need to be coordinated.
Previous Topic:The code for the static initializer is exceeding the 65535 bytes limit
Next Topic:Is it possible to view the ".dmodel" file in a graphical view like UML?
Goto Forum:
  


Current Time: Tue Dec 23 01:38:10 GMT 2014

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

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