Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Automatic Code completion & automatic indents(I want "if" and "endif" behave similar to "{" and "}" in the editor)
Automatic Code completion & automatic indents [message #698367] Tue, 19 July 2011 10:52 Go to next message
Peter Mising nameFriend
Messages: 5
Registered: May 2011
Junior Member
Hi,

recently I changed my grammar to use a code style with "if" and "endif" instead of the curly braces. I also adjusted the auto formatting to get the indent correctly if I press ctrl+shift+f.

But if I am in the editor and press enter after writing "if ..." the editor does not automatically increase the indentation as it did when I used the curly braces. How can I add this behavior again?

I also would like the editor to insert the "endif" automatically after writing the "if" line. Can this be done?
Re: Automatic Code completion & automatic indents [message #698373 is a reply to message #698367] Tue, 19 July 2011 11:03 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you have to adapt the auto-edit-strategy-part of the editor. Start digging at DefaultAutoEditStrategy.

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: Automatic Code completion & automatic indents [message #698951 is a reply to message #698373] Wed, 20 July 2011 14:39 Go to previous message
Peter Mising nameFriend
Messages: 5
Registered: May 2011
Junior Member
Thank you, I have implemented my own subclass of DefaultAutoEditStrategyProvider now.
Unfortunately the CompoundMultiLineTerminalsEditStrategy does not simply work for "if" and "endif" as the first is a substring of the latter, so I had to make some adjustments.

If there is a simpler way of doing this please let me know. It would be nice if those autoedit rules could be based on the grammar rules or at least on the tokens of the grammar. But I guess it is only possible to work on the character level here?
Previous Topic:Beginner problem using EOF token
Next Topic:[Xbase] FeatureCall Scoping problems with DomainModelExample
Goto Forum:
  


Current Time: Wed Sep 30 22:58:04 GMT 2020

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

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

Back to the top