/*
 * generated by Xtext
 */
package org.yakindu.sct.generator.genmodel.formatting;

import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;

/**
 * This class contains custom formatting description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
 * on how and when to use it 
 * 
 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
 */
public class SGenFormatter extends AbstractDeclarativeFormatter {
	
	@Override
	protected void configureFormatting(FormattingConfig c) {
// It's usually a good idea to activate the following three statements.
// They will add and preserve newlines around comments
//		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getSL_COMMENTRule());
//		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getML_COMMENTRule());
//		c.setLinewrap(0, 1, 1).after(getGrammarAccess().getML_COMMENTRule());
	}
}

@@ -78,16 +78,82 @@
 tting;%0A%0A
+import org.eclipse.xtext.Group;%0Aimport org.eclipse.xtext.Keyword;%0A
 import o
@@ -273,16 +273,122 @@
 gConfig;
+%0Aimport org.eclipse.xtext.util.Pair;%0Aimport org.yakindu.sct.generator.genmodel.services.SGenGrammarAccess;
 %0A%0A/**%0A *
@@ -552,17 +552,16 @@
 o use it
- 
 %0A * %0A * 
@@ -637,16 +637,19 @@
 r%7D as an
+%0A *
  example
@@ -719,17 +719,16 @@
 atter %7B%0A
-%09
 %0A%09@Overr
@@ -789,16 +789,18 @@
 ig c) %7B%0A
+%09%09
 // It's 
@@ -863,16 +863,18 @@
 ements.%0A
+%09%09
 // They 
@@ -920,20 +920,21 @@
 omments%0A
-//
 %09%09
+// 
 c.setLin
@@ -936,32 +936,37 @@
 etLinewrap(0, 1,
+%0A%09%09//
  2).before(getGr
@@ -993,36 +993,37 @@
 COMMENTRule());%0A
-//
 %09%09
+// 
 c.setLinewrap(0,
@@ -1025,16 +1025,21 @@
 ap(0, 1,
+%0A%09%09//
  2).befo
@@ -1086,12 +1086,13 @@
 ));%0A
-//
 %09%09
+// 
 c.se
@@ -1156,14 +1156,940 @@
 Rule());
+%0A%0A%09%09// Find elements which declare their body in curly brackets.%0A%09%09// - Increment Indentation for the body.%0A%09%09// - Line wrap before opening and after closing element%0A%09%09for (Pair%3CKeyword, Keyword%3E pair : grammar.findKeywordPairs(%22%7B%22, %22%7D%22)) %7B%0A%09%09%09c.setIndentation(pair.getFirst(), pair.getSecond());%0A%09%09%09c.setLinewrap().after(pair.getFirst());%0A%09%09%09c.setLinewrap().around(pair.getSecond());%0A%0A%09%09%09Keyword openingBrace = pair.getFirst();%0A%09%09%09Group containingGroup = (Group) openingBrace.eContainer();%0A%0A%09%09%09// Top-most elements with brackets: Insert blank lines%0A%09%09%09// if (containingGroup.eContainer().eContainer() instanceof Grammar)%0A%09%09%09// %7B%0A%09%09%09c.setLinewrap(1, 2, 2).before(containingGroup);%0A%09%09%09c.setLinewrap(1, 2, 2).after(containingGroup);%0A%09%09%09// %7D%0A%09%09%7D%0A%0A%09%09SGenGrammarAccess g = (SGenGrammarAccess) getGrammarAccess();%0A%09%09c.setLinewrap().around(g.getFeatureConfigurationRule());%0A%09%09c.setLinewrap().around(g.getFeatureParameterValueRule());
 %0A%09%7D%0A%7D%0A

Add formatting to SGen DSL