Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Another Content Assist doubt
Another Content Assist doubt [message #851071] Fri, 20 April 2012 16:11 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi,

I've created a dsl project based on existent ecore model.

xtext have created this:
UnitType returns UnitType:
	{UnitType}
	'UnitType:'
	name=EString
;

EString returns ecore::EString:
	STRING | ID;

OrganizationUnit returns OrganizationUnit:
	{OrganizationUnit}
	'OrganizationUnit:'
	name=EString
	'{'
		('unitType:' unitType=[UnitType|EString])?
    '}';


When I create a OrganizationUnit in a running the eclipse runtime, if I type ctrl-space after OrganizationUnit:, the content assist don't show the option "Name"... but appears OrganizationUnit: again...

Well, if I change the type of feature name to the terminal STRING or ID, content assist starts to show the name option properly...

Please, could someone explain me this behavior ?

regards,

Cristiano
Re: Another Content Assist doubt [message #851080 is a reply to message #851071] Fri, 20 April 2012 16:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13488
Registered: July 2009
Senior Member
For custom rules as your data type rule you have to take care about
content assist yourself


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Another Content Assist doubt [message #851100 is a reply to message #851080] Fri, 20 April 2012 16:48 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Well, I always thought that when I get something auto-generated by a tool it would be considered standard not a customization.. So, being EString created by Xtext it should be treated properly as well...

Anyway, could you please point me to any doc about what you have suggest me ?
Re: Another Content Assist doubt [message #851111 is a reply to message #851100] Fri, 20 April 2012 16:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13488
Registered: July 2009
Senior Member
http://www.eclipse.org/Xtext/documentation/2_1_0/150-contentassist.php

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Another Content Assist doubt [message #851214 is a reply to message #851111] Fri, 20 April 2012 19:17 Go to previous messageGo to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Well, I have read this doc before but unfortunately (for my two neurons doesn't help much) it just shows what method should I override but there is no info about what should I do inside those methods.

The easier workaround was to remove the generated EString datatype and modify the generated xtext file to use the STRING or ID terminals instead it.

thanks anyway.

cheers,

Cristiano
Re: Another Content Assist doubt [message #851244 is a reply to message #851214] Fri, 20 April 2012 19:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13488
Registered: July 2009
Senior Member
public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	@Override
	public void completeUnitType_Name(EObject model, Assignment assignment,
			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		acceptor.accept(createCompletionProposal("YouAreTheGuiWhoKnowsWhatAUnitTypeNameIs", context));
		super.completeUnitType_Name(model, assignment, context, acceptor);
	}
	
	@Override
	public void complete_EString(EObject model, RuleCall ruleCall,
			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		acceptor.accept(createCompletionProposal("ThisIsAnEString", context));
		acceptor.accept(createCompletionProposal("\"ThisIsAnEStringToo\"", context));
		super.complete_EString(model, ruleCall, context, acceptor);
	}

}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Another Content Assist doubt [message #851248 is a reply to message #851244] Fri, 20 April 2012 20:03 Go to previous message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Humm, I thing that I'm getting the idea now... Smile

btw, I've found this post that show an interesting example of what could be done in those custom methods:

http://www.peterfriese.de/xtext-tricks-1-enhancing-completion-proposals/

thanks again,

Cristiano

[Updated on: Fri, 20 April 2012 20:04]

Report message to a moderator

Previous Topic:Content Assist don't work in first column of second line...
Next Topic:Why such warnings occur
Goto Forum:
  


Current Time: Mon Jul 06 05:49:11 GMT 2020

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

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

Back to the top