1 | /* |
---|
2 | * generated by Xtext |
---|
3 | */
|
---|
4 | package de.ugoe.cs.swe.bnftools.formatting
|
---|
5 |
|
---|
6 | import com.google.inject.Inject
|
---|
7 | import de.ugoe.cs.swe.bnftools.services.EbnfGrammarAccess
|
---|
8 | import org.eclipse.xtext.Keyword
|
---|
9 | import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
|
---|
10 | import 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 | */
|
---|
20 | class 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 | }
|
---|