Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to customize the content assist in the editor
How to customize the content assist in the editor [message #689208] Mon, 27 June 2011 07:20 Go to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi,

I have the following use case:-

I have written a simple grammar for comparison expression:
"Age < 18"

ComparisonExpression:
(variable=[Variable]) '<' INT | (variable=[Variable]) '<' STRING;

where [Variable] is referred from another ecore model. With a lot of help in earlier thread I was able to get the content assist in my generated editor for instances of [Variable] at runtime.

I have the following query:
The entity [Variable] has an attribute called type which can be "java.lang.Integer" or "java.lang.String". In my editors content assist I want the RHS of the expression to be suggested as "INT" if the type of the [Variable] is "java.lang.Integer" and "STRING" if the type of the [Variable] is "java.lang.String".

Also in one of the previous posts Christian did mention to override the content assist for the editor but there is no content assist for these terminal rules such as INT and STRING.

I wanted some help to figure out how this can be done.

Thanks,
Best Regards,
Nidhi

Re: How to customize the content assist in the editor [message #689222 is a reply to message #689208] Mon, 27 June 2011 07:36 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I'd say you rather want something like

ComparisonExpression:
(variable=[Variable]) '<' value=Value;

Value: IntValue|StringValue;
IntValue:INT;
StringValue:STRING;

Then there is a content assist method for ComparisonExpression_Value that you can adapt depending on the type of 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
Previous Topic:(no subject)
Next Topic:[Xtext 2.0]Cross-References to work with existing EPackages
Goto Forum:
  


Current Time: Sun May 12 22:14:52 GMT 2024

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

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

Back to the top