Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ContentAssist - CodeCompletion with Templates for Function-Parameters
ContentAssist - CodeCompletion with Templates for Function-Parameters [message #642500] Wed, 01 December 2010 15:41 Go to next message
Julian  is currently offline Julian Friend
Messages: 3
Registered: December 2010
Junior Member
Hello,

I include a model of different functions to my DSL with the import-URI mechanism.

The CodeCompletion works so far. I get a Proposal list with all modelled functions + parameters and additional Information.

I did this in the {DSL}ProposalProvider as mentioned in the xText-Documentation.

If I choose one Proposal from the list, the proposal will be inserted.
Like:
... Testfunction (int para1, int para2) ...

What I want to achieve now is, that there are placeholders for the parameters, so that I can enter one an switch to the other one with a tab. As is known from the JavaIDE when I insert a function.

At which point I have to start??

The get the information for the proposal from a List with all functions. The functions createProposal and createAdditionalInformation just build a String from the information.

part of my ProposalProvider
				

for (int j=0; j < functions.size(); j++) {
			
			String proposal = pu.createProposal(functions.get(j));
			String additionalInformation = pu.createAdditionalInformation(functions.get(j));
			ICompletionProposal prop = createCompletionProposal(proposal, context);
			ConfigurableCompletionProposal confp = (ConfigurableCompletionProposal) prop;		
			confp.setAdditionalProposalInfo(additionalInformation);
			acceptor.accept(prop);

		}



Julian
Re: ContentAssist - CodeCompletion with Templates for Function-Parameters [message #642587 is a reply to message #642500] Wed, 01 December 2010 21:16 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
You'd use Template Proposals (§7.4 in the User Guide) for this, not the content assist.

Re: ContentAssist - CodeCompletion with Templates for Function-Parameters [message #642680 is a reply to message #642500] Thu, 02 December 2010 10:09 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Julian,

Xtext supports somewhat limited placeholders in content proposals out of
the box. Please have a look at
TerminalsProposalProvider#createStringProposal and digg into
ConfigurableCompletionProposal#setSimpleLinkedMode. However, multiple
linked fields in your proposal are not supported out of the box and
you'll have to implement that on your own.

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

Am 01.12.10 16:41, schrieb Julian:
> Hello,
>
> I include a model of different functions to my DSL with the import-URI
> mechanism.
>
> The CodeCompletion works so far. I get a Proposal list with all modelled
> functions + parameters and additional Information.
> I did this in the {DSL}ProposalProvider as mentioned in the
> xText-Documentation.
>
> If I choose one Proposal from the list, the proposal will be inserted.
> Like:
> .. Testfunction (int para1, int para2) ...
>
> What I want to achieve now is, that there are placeholders for the
> parameters, so that I can enter one an switch to the other one with a
> tab. As is known from the JavaIDE when I insert a function.
>
> At which point I have to start??
>
> The get the information for the proposal from a List with all functions.
> The functions createProposal and createAdditionalInformation just build
> a String from the information.
>
> part of my ProposalProvider
>
>
> for (int j=0; j < functions.size(); j++) {
>
> String proposal = pu.createProposal(functions.get(j));
> String additionalInformation =
> pu.createAdditionalInformation(functions.get(j));
> ICompletionProposal prop = createCompletionProposal(proposal, context);
> ConfigurableCompletionProposal confp = (ConfigurableCompletionProposal)
> prop;
> confp.setAdditionalProposalInfo(additionalInformation);
> acceptor.accept(prop);
>
> }
>
>
>
> Julian
Re: ContentAssist - CodeCompletion with Templates for Function-Parameters [message #642899 is a reply to message #642680] Fri, 03 December 2010 09:44 Go to previous messageGo to next message
Julian  is currently offline Julian Friend
Messages: 3
Registered: December 2010
Junior Member
Hey,

so if i get this right. I can only insert one placehoder with the current ConfigurableCompletionProposal from xText.
If I want two or more (like two or more parameters) i have to extend the current ConfigurableCompletionProposal and implement my own apply-Method.

Julian
Re: ContentAssist - CodeCompletion with Templates for Function-Parameters [message #642905 is a reply to message #642899] Fri, 03 December 2010 09:52 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Julian,

you are right. If you want to have more linked fields, you'll have to
extend the ConfigurableCompletionProposal (or implement an
ICompletionProposal on your own) and set up the linked mode for more
than one field.

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

Am 03.12.10 10:44, schrieb Julian:
> Hey,
>
> so if i get this right. I can only insert one placehoder with the
> current ConfigurableCompletionProposal from xText.
> If I want two or more (like two or more parameters) i have to extend the
> current ConfigurableCompletionProposal and implement my own apply-Method.
>
> Julian
Re: ContentAssist - CodeCompletion with Templates for Function-Parameters [message #643860 is a reply to message #642905] Wed, 08 December 2010 14:01 Go to previous message
Julian  is currently offline Julian Friend
Messages: 3
Registered: December 2010
Junior Member
Hey Sebastian,

thanks for the tip. I tried extending the ConfigurableCompletionProposal but this causes a lot of problems.
The createCompletionProposal method doesn't work anymore because it return a ConfigurableCompletionProcessor and not my own.
The Second one is the acceptor.accept which also only expects ConfigurableCompletionProposals.

Do I have to modify all this xText-Classes (e.g. AbstractContentProposalProvider) or is there a easier solution??

Maybe I am not seeing the obvious solution Smile

Julian
Previous Topic:Nexus Repo location for xText 1.0.1
Next Topic:knowing the java package of the model generated classes
Goto Forum:
  


Current Time: Thu Sep 19 01:37:01 GMT 2024

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

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

Back to the top