Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting configuration
Formatting configuration [message #1140199] Wed, 16 October 2013 07:36
Yoav Amit is currently offline Yoav AmitFriend
Messages: 3
Registered: October 2013
Junior Member
Hi,

I'm having some problems when trying to apply specific formatting rules to my DSL.
I've implemented a class IndentFormatter which extends AbstractDeclarativeFormatter and has the following code in the configureFormatting() method:
	@Override
	protected void configureFormatting(FormattingConfig c) {
		grammarAccess = (IndentGrammarAccess) getGrammarAccess();
		
		c.setIndentationIncrement().after(grammarAccess.getGroupAccess().getLeftCurlyBracketKeyword_1());
		c.setIndentationDecrement().before(grammarAccess.getGroupAccess().getRightCurlyBracketKeyword_4());
	}


In order to do so I've modified my DSL's MWE2 workflow file, specifically I changed the following line:
fragment = formatting.FormatterFragment auto-inject {}


to this:
fragment = formatting.FormatterFragment {} // using the old java based formatter


My DSL .xtext file looks like this:
Model:
	procs+=Group;

Group: ID '{' '\n'+ greetings+=Greeting '}' '\n'+;
	
Greeting:
	'Hello' name=Title '.' lastName=ID '!' '\n';

Title: 'Mr' | 'Ms' | 'Mrs';


I run the plugin and wrote the following file:
Itemis {
Hello Mr. Dietrich!
Hello Mr. Stoll!
}


And after trying to format the code (by pressing Ctrl+Shift+F), this is the result I got:
Itemis { Hello Mr . Dietrich ! Hello Mr . Stoll ! }


Is there anything I forgot to do in order for the formatter rules to take affect? Currently it looks like nothing I wrote was ever applied...

EDIT:
Please note that the newline characters are actually a part of the language, and I think that's what causing the problem.
I even tired replacing the formatter configuration to this:
c.setIndentationIncrement().after(grammarAccess.getMainAccess().getLineFeedLfKeyword_3());

And still, I got the same behavior.

I'd appreciate your help!

[Updated on: Wed, 16 October 2013 16:33]

Report message to a moderator

Previous Topic:Terminal
Next Topic:using UUIDs in FragmentProvider
Goto Forum:
  


Current Time: Fri Dec 04 08:57:12 GMT 2020

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

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

Back to the top