Search in sources :

Example 1 with FormatGrammarAccess

use of com.avaloq.tools.ddk.xtext.format.services.FormatGrammarAccess in project dsl-devkit by dsldevkit.

the class FormatFormatter method configureFormatting.

@Override
protected void configureFormatting(final FormattingConfig config) {
    FormatGrammarAccess grammarAccess = (FormatGrammarAccess) getGrammarAccess();
    config.setAutoLinewrap(LINE_LENGTH);
    config.setLinewrap().before(grammarAccess.getFormatConfigurationAccess().getGroup_4());
    for (Pair<Keyword, Keyword> pair : grammarAccess.findKeywordPairs("{", "}")) {
        config.setIndentationIncrement().after(pair.getFirst());
        config.setLinewrap().after(pair.getFirst());
        config.setIndentationDecrement().before(pair.getSecond());
        config.setLinewrap().after(pair.getSecond());
    }
    for (Pair<Keyword, Keyword> pair : grammarAccess.findKeywordPairs("[", "]")) {
        config.setNoSpace().after(pair.getFirst());
        config.setNoSpace().before(pair.getSecond());
    }
    for (Keyword keyword : grammarAccess.findKeywords(";")) {
        config.setLinewrap().after(keyword);
        config.setNoSpace().before(keyword);
    }
    for (Keyword keyword : grammarAccess.findKeywords(",")) {
        config.setNoSpace().before(keyword);
    }
    for (Keyword keyword : grammarAccess.findKeywords("=", "@")) {
        config.setSpace("").after(keyword);
    }
    configComments(config, grammarAccess.getML_COMMENTRule(), grammarAccess.getSL_COMMENTRule());
    configConstants(config, grammarAccess);
    configGrammarRule(config, grammarAccess.getGrammarRuleAccess());
    configWildcardRule(config, grammarAccess.getWildcardRuleAccess());
    configKeywordPair(config, grammarAccess.getKeywordPairAccess());
}
Also used : Keyword(org.eclipse.xtext.Keyword) FormatGrammarAccess(com.avaloq.tools.ddk.xtext.format.services.FormatGrammarAccess)

Aggregations

FormatGrammarAccess (com.avaloq.tools.ddk.xtext.format.services.FormatGrammarAccess)1 Keyword (org.eclipse.xtext.Keyword)1