Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Troubles with content assist
Troubles with content assist [message #699377] Thu, 21 July 2011 13:12 Go to next message
Romain  Aïssat is currently offline Romain AïssatFriend
Messages: 16
Registered: June 2011
Junior Member
Hi all!

Noob question i suppose =)

Here is a simple grammar to illustrate my problem :

Model:
	( elements += Declaration )*;
	
Declaration :
	'exp' name = ID '=' exp = Expression ';';
	
Expression :
	Add;
	
Add returns Expression :
	TerminalExpression 	( '+' {Add.left = current} right = TerminalExpression
				| '-' {Sub.left = current} right = TerminalExpression)*;
						
TerminalExpression returns Expression :
	 (Reference | '(' Expression ')' | {TerminalExpression} INT);
	
Reference :
	referenced = [Declaration];


Now I'd like to customize the content assist : adding proposals is easy and well explained in the doc. or in blogs. But i need to remove some of the default proposals. Here is an example :

exp a = 1;

exp b = 2;

exp c = a + {Hit CTRL + SPACE}


the content assist gives by default '+' and '-' : I'd like to remove these and really don't know how to do it. I've tried to override methods in AbstractJavaBasedContentProposalProvider but couldn't do anything good...

If someone could give me some hints to achieve this, it would be great!

Thanks in advance
Re: Troubles with content assist [message #699382 is a reply to message #699377] Thu, 21 July 2011 13:23 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

do you invoke code completion immediately after '+' (that is without a space)? If so, '+' is a valid prefix of the keyword '+' and thus the proposal is shown.
Set a break point in AbstractJavaBasedContentProposalProvider#completeKeyword and check if its called for the '+'. If so, I guess this is the place to start.

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: Troubles with content assist [message #699391 is a reply to message #699382] Thu, 21 July 2011 13:34 Go to previous messageGo to next message
Romain  Aïssat is currently offline Romain AïssatFriend
Messages: 16
Registered: June 2011
Junior Member
Sorry, my bad, should have write :

exp a = 1;

exp b = 2;

exp c = a {Hit CTRL + SPACE}


I can invoke code completion immediately after 'a' or write any number of whitespaces and '+' and '-' are shown.

Anyway I'll look in those methods and try to apply what you said... Thx!
Re: Troubles with content assist [message #699427 is a reply to message #699391] Thu, 21 July 2011 14:27 Go to previous message
Romain  Aïssat is currently offline Romain AïssatFriend
Messages: 16
Registered: June 2011
Junior Member
You were right : if I do "exp c = a {Hit CTRL + SPACE}", AbstractJavaBasedContentProposalProvider#completeKeyword is called. I have overriden this method in a class extending AbstractJavaBasedContentProposalProvider : but this method isn't called instead of AbstractJavaBasedContentProposalProvider#completeKeyword... So I guess I'm still missing the point :/

EDIT : ok I think I got it now. I've overriden AbstractJavaBasedContentProposalProvider#completeKeyword in [MyDsl]ProposalProvider.java and it works =)

Thx!!

[Updated on: Thu, 21 July 2011 14:34]

Report message to a moderator

Previous Topic:[Xbase] Rewriting an expression to conform to expected type
Next Topic:Is Xtext itself built by Xtext?
Goto Forum:
  


Current Time: Thu Apr 25 01:36:30 GMT 2024

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

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

Back to the top