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

Last change on this file since 65 was 65, checked in by hkaulbersch, 10 years ago

fixed imports

File size: 1.4 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
11import org.eclipse.emf.ecore.EObject
12import de.ugoe.cs.swe.bnftools.ebnf.Rule
13import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList
14
15/**
16 * This class contains custom formatting description.
17 *
18 * see : http://www.eclipse.org/Xtext/documentation.html#formatting
19 * on how and when to use it
20 *
21 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
22 */
23class EbnfFormatter extends AbstractDeclarativeFormatter {
24
25        @Inject extension EbnfGrammarAccess
26
27        override protected void configureFormatting(FormattingConfig c) {
28
29                // They will add and preserve newlines around comments
30                c.setLinewrap(0, 1, 2).before(SL_COMMENTRule)
31                c.setLinewrap(0, 1, 2).before(ML_COMMENTRule)
32                c.setLinewrap(0, 1, 1).after(ML_COMMENTRule)
33
34                var EbnfGrammarAccess f = getGrammarAccess as EbnfGrammarAccess;
35                c.setLinewrap.before(f.ruleRule);
36                c.setLinewrap.before(f.importRule);
37                c.setNoSpace.after(f.ruleAccess.rulenumberINTTerminalRuleCall_0_0_0)
38
39               
40//              for (Keyword bar : f.findKeywords("|")) {
41//
42//                      c.setSpace("\n\t\t").before(bar);
43//              }
44
45        }
46}
Note: See TracBrowser for help on using the repository browser.