*
* @param c
* - formatter to configure
*/
protected void resourceExpressionConfiguration(FormattingConfig c) {
PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
// + linebreak after «'title' :»
for(Keyword colon : ga.getResourceBodyAccess().findKeywords(":")) {
c.setLinewrap().after(colon);
c.setNoLinewrap().before(colon);
}
// + indent the body of the resource expression
{
Keyword lbr = ga.getResourceExpressionAccess().getLeftCurlyBracketKeyword_0_1_1();
Keyword rbr = ga.getResourceExpressionAccess().getRightCurlyBracketKeyword_0_1_3();
c.setIndentation(lbr, rbr);
c.setNoLinewrap().before(lbr);
c.setLinewrap().after(lbr);
c.setLinewrap().before(rbr);
c.setLinewrap().after(rbr);
Keyword endComma = ga.getAttributeOperationsAccess().getCommaKeyword_2();
c.setLinewrap(1).between(endComma, rbr);
}
// repeat for literal class for of the rule
{
Keyword lbr = ga.getResourceExpressionAccess().getLeftCurlyBracketKeyword_1_2();
Keyword rbr = ga.getResourceExpressionAccess().getRightCurlyBracketKeyword_1_4();
c.setIndentation(lbr, rbr);
c.setNoLinewrap().before(lbr);
c.setLinewrap().after(lbr);
c.setLinewrap().before(rbr);
c.setLinewrap().after(rbr);
Keyword endComma = ga.getAttributeOperationsAccess().getCommaKeyword_2();
c.setLinewrap(1).between(endComma, rbr);
}
// + linebreak after «attribute (=>|+>) expr,»
Keyword comma = ga.getAttributeOperationsAccess().getCommaKeyword_1_0_0();
c.setNoLinewrap().before(comma);
c.setLinewrap().after(comma);
// c.setLinewrap().after(ga.getAttributeOperationsAccess().getCommaKeyword_2());
// for(Keyword comma : ga.getAttributeOperationsAccess().findKeywords(",")) {
// if(comma == ga.getAttributeOperationsAccess().get)
// c.setLinewrap().after(comma);
// }
// linebreak after each resource body in a list of resource bodies
{
Keyword semi = ga.getResourceExpressionAccess().getSemicolonKeyword_0_1_2_1_0();
c.setNoLinewrap().before(semi);
c.setLinewrap(2).after(semi);
Keyword endSemi = ga.getResourceExpressionAccess().getSemicolonKeyword_0_1_2_2();
c.setNoLinewrap().before(endSemi);
c.setLinewrap(1).after(endSemi);
}
{ // repeat for second group
Keyword semi = ga.getResourceExpressionAccess().getSemicolonKeyword_1_3_1_0();
c.setNoLinewrap().before(semi);
c.setLinewrap(2).after(semi);
Keyword endSemi = ga.getResourceExpressionAccess().getSemicolonKeyword_1_3_2();
c.setNoLinewrap().before(endSemi);
c.setLinewrap(1).after(endSemi);
}
// c.setLinewrap(1).between(endSemi, rbr);
// no wrap when RESOURCE -> RESOURCE is used
// c.setNoLinewrap().before(ga.getRelationshipExpressionAccess().getOpNameAssignment_1_1());
c.setNoLinewrap().before(ga.getRelationshipExpressionAccess().getOpNameAssignment_1_1());
// + indent the list of attribute operations but only when when they have a title
// TODO: 1.0GA (changing resource expression grammar)
c.setIndentationIncrement().before(ga.getResourceBodyAccess().getAttributesAssignment_0_2());
c.setIndentationDecrement().after(ga.getResourceBodyAccess().getAttributesAssignment_0_2());
// this will always indent even if there is no title
// c.setIndentationIncrement().before(ga.getAttributeOperationsRule());
// c.setIndentationDecrement().after(ga.getAttributeOperationsRule());
// this was workaround for bug in Xtext 1.0
// for(Assignment theCall : ga.getResourceBodyAccess().findAssignments(ga.getAttributeOperationsRule())) {
// c.setIndentationIncrement().before(theCall);
// c.setIndentationDecrement().after(theCall);
// }
// No space between the two @@ in a virtual exported resource
{
Keyword at1 = ga.getVirtualNameOrReferenceAccess().getCommercialAtKeyword_0();
RuleCall at2 = ga.getVirtualNameOrReferenceAccess().getExportedATBooleanParserRuleCall_1_0();
RuleCall value = ga.getVirtualNameOrReferenceAccess().getValueUnionNameOrReferenceParserRuleCall_2_0();
c.setNoSpace().between(at1, at2);
c.setNoSpace().between(at1, value);
c.setNoSpace().between(at2, value);
// ga.getVirtualNameOrReferenceAccess().getCommercialAtKeyword_0(),