Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Correct Indentation
Correct Indentation [message #1060727] Tue, 28 May 2013 09:11 Go to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

Is there a way to provide a service for automatic correction of the indentation like the one provided in the Java editor (i.e. Ctrl+i)?

Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060730 is a reply to message #1060727] Tue, 28 May 2013 09:27 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you can configure a formatter. Shift-Ctrl-f invokes the formatter in the editor.

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: Correct Indentation [message #1060780 is a reply to message #1060730] Tue, 28 May 2013 12:25 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

I have uncommented the three lines suggested in the default implementation of the AbstractDeclarativeFormatter

	c.setLinewrap(0, 1, 2).before(getGrammarAccess().getSL_COMMENTRule());
		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getML_COMMENTRule());
		c.setLinewrap(0, 1, 1).after(getGrammarAccess().getML_COMMENTRule());


but it says the getSL_COMMENTRule and getML_COMMENTRule() methods are undefined

am I missing something?


Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060783 is a reply to message #1060780] Tue, 28 May 2013 12:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi you have to downcast get grammar access to YourDslGrammarAccess

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Correct Indentation [message #1060784 is a reply to message #1060783] Tue, 28 May 2013 12:32 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

Hi Christian,
thank you it works


Follow me on Twitter @andreasindico

Re: Correct Indentation [message #1060786 is a reply to message #1060783] Tue, 28 May 2013 12:37 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
Christian Dietrich wrote on Tue, 28 May 2013 14:28
Hi you have to downcast get grammar access to YourDslGrammarAccess

Makes me wonder - shouldn't that be listed as a bug, i.e. should that example not be working as is?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=329996 - Nevermind me.

[Updated on: Tue, 28 May 2013 12:39]

Report message to a moderator

Re: Correct Indentation [message #1060790 is a reply to message #1060786] Tue, 28 May 2013 12:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Feel free to do so

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Correct Indentation [message #1060960 is a reply to message #1060790] Wed, 29 May 2013 10:15 Go to previous message
Andrea Sindico is currently offline Andrea SindicoFriend
Messages: 266
Registered: November 2010
Senior Member

I have managed to define a set of formatting criteria that fit with my needs. The only exceptions are comments (i.e. SL_COMMENTRule and ML_COMMENTRule) which seem to be not affected by indentation increment/decrement.
Is it possible?


Follow me on Twitter @andreasindico

Previous Topic:How to define a 'synchronized' method using the model inferrer
Next Topic:Automatically adding Xtext nature to project
Goto Forum:
  


Current Time: Sat Apr 20 03:42:39 GMT 2024

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

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

Back to the top