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