Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatter problem
Formatter problem [message #997111] Thu, 03 January 2013 18:29 Go to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
using this minimalistic grammar
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl ""

Model:
	(includes+=Include)*
	(greetings+=Element)+;
	
Element:
	Greeting | Farewell
;

Greeting:
	'Hello' name=ID '!';

Farewell:
	'Bye' name=ID '!'
;

Include:
	"include" name=ID";"
;


and this formatter
public class MyDslFormatter extends AbstractDeclarativeFormatter {
	
	protected void configureFormatting(FormattingConfig c) {
		MyDslGrammarAccess f = (MyDslGrammarAccess) getGrammarAccess();
		c.setLinewrap(2).around(f.getElementRule());
	}
}


the formatter works only correctly if at least one include is defined. I don't understand why. Can somebody shed some light on this?

The results after formatting are:
include Name ;

Hello rob !

Hello Name !

Bye rob !

and
Hello rob ! Hello Name ! Bye rob !

Re: Formatter problem [message #997114 is a reply to message #997111] Thu, 03 January 2013 18:41 Go to previous message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
if I remove Include from the grammar the formatting won't work at all. Is this a bug or do I just not understand what's going on?
Previous Topic:Xtext grammar for real literals and filenames with a . dot extension
Next Topic:junit test formatting removes hidden tokens (i.e. comments)
Goto Forum:
  


Current Time: Fri Apr 26 20:47:53 GMT 2024

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

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

Back to the top