Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Another Content Assist doubt
Another Content Assist doubt [message #851071] Fri, 20 April 2012 12:11 Go to next message
Eclipse UserFriend
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 12:19 Go to previous messageGo to next message
Eclipse UserFriend
For custom rules as your data type rule you have to take care about
content assist yourself
Re: Another Content Assist doubt [message #851100 is a reply to message #851080] Fri, 20 April 2012 12:48 Go to previous messageGo to next message
Eclipse UserFriend
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 12:56 Go to previous messageGo to next message
Eclipse UserFriend
http://www.eclipse.org/Xtext/documentation/2_1_0/150-contentassist.php
Re: Another Content Assist doubt [message #851214 is a reply to message #851111] Fri, 20 April 2012 15:17 Go to previous messageGo to next message
Eclipse UserFriend
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 15:57 Go to previous messageGo to next message
Eclipse UserFriend
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);
	}

}
Re: Another Content Assist doubt [message #851248 is a reply to message #851244] Fri, 20 April 2012 16:03 Go to previous message
Eclipse UserFriend
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 16:04] by Moderator

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


Current Time: Sat Jul 05 17:11:37 EDT 2025

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

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

Back to the top