Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code Formatter and comments.
Code Formatter and comments. [message #1412849] Wed, 27 August 2014 08:17 Go to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
Hey. I have a slight problem with code formatting in my DSL. Assume this file contents:

/**
 * comment
 */
persistent XX {
	/**
	 * asd
	 */
	data-category XX;

			/**
			 * more comment
			 */
	attribute xx : common.BOOLEAN {
		property label "Something";
	}
}


running the code formatter with this config:

	override protected void configureFormatting(FormattingConfig c) {
		c.setAutoLinewrap(120);

		for (pair : ga.findKeywordPairs("{", "}")) {
			c.setNoLinewrap.before(pair.first);
			c.setLinewrap(1, 1, 1).after(pair.first);
			c.setLinewrap(1, 1, 2).before(pair.second);
			c.setLinewrap(1, 1, 2).after(pair.second);

			c.setIndentationIncrement.after(pair.first);
			c.setIndentationDecrement.before(pair.second);
		}

		for (kw : ga.findKeywords(";")) {
			c.setLinewrap(1, 1, 2).after(kw);
			c.setNoSpace.before(kw);
		}
		
		c.setNoLinewrap.before(ga.connectionAccess.toKeyword_4);

		// It's usually a good idea to activate the following three statements.
		// They will add and preserve newlines around comments
		c.setLinewrap(0, 1, 2).before(SL_COMMENTRule)
		c.setLinewrap(0, 1, 2).before(ML_COMMENTRule)
		c.setLinewrap(0, 1, 1).after(ML_COMMENTRule)
	}


yields this weird formatted comments. what am i doing wrong?? xtext version is 2.6.0.

/**
 * comment
 */
persistent XX {
/**
	 * asd
	 */
	data-category XX;

	/**
			 * more comment
			 */
	attribute xx : common.BOOLEAN {
		property label "Something";
	}
}


Any hints? Will I have to write my own formatter without help from the declarative one?

Thanks!
Re: Code Formatter and comments. [message #1412870 is a reply to message #1412849] Wed, 27 August 2014 09:03 Go to previous messageGo to next message
Thomas Fritsch is currently offline Thomas FritschFriend
Messages: 28
Registered: April 2013
Location: Germany
Junior Member
Looks very much like https://bugs.eclipse.org/bugs/show_bug.cgi?id=313133
Re: Code Formatter and comments. [message #1412905 is a reply to message #1412870] Wed, 27 August 2014 10:34 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
Hey, thanks for the pointer, didn't find that one o.O

Will try the workaround, as I really need this working (I'm implementing format on save, so this must work then Wink)
Re: Code Formatter and comments. [message #1412956 is a reply to message #1412905] Wed, 27 August 2014 12:26 Go to previous message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
Sadly this does not help at all... Neutral any hints on what I could try?
Previous Topic:References across files
Next Topic:right place to add save actions?
Goto Forum:
  


Current Time: Thu Apr 18 12:52:17 GMT 2024

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

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

Back to the top