Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Correct Indentation
Correct Indentation [message #1060727] Tue, 28 May 2013 05:11 Go to next message
Andrea Sindico is currently offline Andrea Sindico
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 05:27 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1151
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 08:25 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea Sindico
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 08:28 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6198
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
Re: Correct Indentation [message #1060784 is a reply to message #1060783] Tue, 28 May 2013 08:32 Go to previous messageGo to next message
Andrea Sindico is currently offline Andrea Sindico
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 08:37 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio Heeg
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 08:39]

Report message to a moderator

Re: Correct Indentation [message #1060790 is a reply to message #1060786] Tue, 28 May 2013 08:41 Go to previous messageGo to next message
Christian Dietrich is currently online Christian Dietrich
Messages: 6198
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
Re: Correct Indentation [message #1060960 is a reply to message #1060790] Wed, 29 May 2013 06:15 Go to previous message
Andrea Sindico is currently offline Andrea Sindico
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: Thu Aug 21 04:31:03 EDT 2014

Powered by FUDForum. Page generated in 0.01872 seconds