source: default/v2/trunk/de.ugoe.cs.swe.bnftools.ebnf/src/de/ugoe/cs/swe/bnftools/formatting/EbnfFormatter.xtend @ 61

Last change on this file since 61 was 61, checked in by hkaulbersch, 11 years ago

initial commit

File size: 1.2 KB
Line 
1/*
2 * generated by Xtext
3 */
4package de.ugoe.cs.swe.bnftools.formatting
5
6import com.google.inject.Inject
7import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess
8import org.eclipse.xtext.Keyword
9import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
10import org.eclipse.xtext.formatting.impl.FormattingConfig
11
12/**
13 * This class contains custom formatting description.
14 *
15 * see : http://www.eclipse.org/Xtext/documentation.html#formatting
16 * on how and when to use it
17 *
18 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
19 */
20class EbnfFormatter extends AbstractDeclarativeFormatter {
21
22        @Inject extension EbnfGrammarAccess
23
24        override protected void configureFormatting(FormattingConfig c) {
25
26                // They will add and preserve newlines around comments
27                c.setLinewrap(0, 1, 2).before(SL_COMMENTRule)
28                c.setLinewrap(0, 1, 2).before(ML_COMMENTRule)
29                c.setLinewrap(0, 1, 1).after(ML_COMMENTRule)
30
31               
32                var EbnfGrammarAccess f = getGrammarAccess as EbnfGrammarAccess;
33                c.setLinewrap.before(f.ruleRule);
34                c.setLinewrap.before(f.importRule);
35//              //c.setLinewrap.after(f.);
36//              for (Keyword bar : f.findKeywords("|")) {
37//                      c.setSpace("\n\t\t").before(bar);
38//              }
39
40        }
41}
Note: See TracBrowser for help on using the repository browser.