/**
 * generated by Xtext
 */
package xtext.formatting;

import com.google.inject.Inject;
import java.util.List;
import org.eclipse.xtext.Keyword;
import org.eclipse.xtext.ParserRule;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.TerminalRule;
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;
import org.eclipse.xtext.util.Pair;
import org.eclipse.xtext.xbase.lib.Extension;
import xtext.services.XModifGrammarAccess;

/**
 * This class contains custom formatting description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation.html#formatting
 * on how and when to use it
 * 
 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
 */
@SuppressWarnings("all")
public class XModifFormatter extends AbstractDeclarativeFormatter {
  @Inject
  @Extension
  private XModifGrammarAccess _xModifGrammarAccess;
  
  protected void configureFormatting(final FormattingConfig c) {
    c.setAutoLinewrap(120);
    List<Keyword> _findKeywords = this._xModifGrammarAccess.findKeywords("Prefix", "URI", "annotation");
    for (final Keyword kw : _findKeywords) {
      FormattingConfig.LinewrapLocator _setLinewrap = c.setLinewrap();
      _setLinewrap.before(kw);
    }
    List<Keyword> _findKeywords_1 = this._xModifGrammarAccess.findKeywords("root", "package", "class", "dataType", "enumModification");
    for (final Keyword kw_1 : _findKeywords_1) {
      FormattingConfig.LinewrapLocator _setLinewrap_1 = c.setLinewrap(2);
      _setLinewrap_1.before(kw_1);
    }
    ParserRule _addNameClassRule = this._xModifGrammarAccess.getAddNameClassRule();
    ParserRule _addRootClassRule = this._xModifGrammarAccess.getAddRootClassRule();
    ParserRule _modificationsRule = this._xModifGrammarAccess.getModificationsRule();
    ParserRule _addAttributeRule = this._xModifGrammarAccess.getAddAttributeRule();
    ParserRule _addDerivedAttributeRule = this._xModifGrammarAccess.getAddDerivedAttributeRule();
    ParserRule _addDerivedReferenceRule = this._xModifGrammarAccess.getAddDerivedReferenceRule();
    ParserRule _attributeModificationRule = this._xModifGrammarAccess.getAttributeModificationRule();
    ParserRule _referenceModificationRule = this._xModifGrammarAccess.getReferenceModificationRule();
    List<RuleCall> _findRuleCalls = this._xModifGrammarAccess.findRuleCalls(_addNameClassRule, _addRootClassRule, _modificationsRule, _addAttributeRule, _addDerivedAttributeRule, _addDerivedReferenceRule, _attributeModificationRule, _referenceModificationRule);
    for (final RuleCall rule : _findRuleCalls) {
      FormattingConfig.LinewrapLocator _setLinewrap_2 = c.setLinewrap();
      _setLinewrap_2.after(rule);
    }
    List<Keyword> _findKeywords_2 = this._xModifGrammarAccess.findKeywords(";", "removeEAnnotations", "removeAllAnnotations", "removeAllOperations", "removeAllEStringAttributes", "removeAllOpposites", "addAllOpposite");
    for (final Keyword kw_2 : _findKeywords_2) {
      FormattingConfig.LinewrapLocator _setLinewrap_3 = c.setLinewrap();
      _setLinewrap_3.after(kw_2);
    }
    List<Pair<Keyword, Keyword>> _findKeywordPairs = this._xModifGrammarAccess.findKeywordPairs("{", "}");
    for (final Pair<Keyword, Keyword> pair : _findKeywordPairs) {
      {
        Keyword _first = pair.getFirst();
        Keyword _second = pair.getSecond();
        c.setIndentation(_first, _second);
        FormattingConfig.LinewrapLocator _setLinewrap_4 = c.setLinewrap(1);
        Keyword _first_1 = pair.getFirst();
        _setLinewrap_4.after(_first_1);
        FormattingConfig.LinewrapLocator _setLinewrap_5 = c.setLinewrap(1);
        Keyword _second_1 = pair.getSecond();
        _setLinewrap_5.before(_second_1);
      }
    }
    List<Keyword> _findKeywords_3 = this._xModifGrammarAccess.findKeywords("(");
    for (final Keyword parO : _findKeywords_3) {
      FormattingConfig.NoSpaceLocator _setNoSpace = c.setNoSpace();
      _setNoSpace.after(parO);
    }
    List<Keyword> _findKeywords_4 = this._xModifGrammarAccess.findKeywords(",");
    for (final Keyword comma : _findKeywords_4) {
      {
        FormattingConfig.NoSpaceLocator _setNoSpace_1 = c.setNoSpace();
        _setNoSpace_1.before(comma);
        FormattingConfig.NoSpaceLocator _setNoSpace_2 = c.setNoSpace();
        _setNoSpace_2.after(comma);
      }
    }
    List<Keyword> _findKeywords_5 = this._xModifGrammarAccess.findKeywords(")");
    for (final Keyword parF : _findKeywords_5) {
      FormattingConfig.NoSpaceLocator _setNoSpace_1 = c.setNoSpace();
      _setNoSpace_1.before(parF);
    }
    FormattingConfig.LinewrapLocator _setLinewrap_4 = c.setLinewrap(0, 1, 2);
    TerminalRule _sL_COMMENTRule = this._xModifGrammarAccess.getSL_COMMENTRule();
    _setLinewrap_4.before(_sL_COMMENTRule);
    FormattingConfig.LinewrapLocator _setLinewrap_5 = c.setLinewrap(0, 1, 2);
    TerminalRule _mL_COMMENTRule = this._xModifGrammarAccess.getML_COMMENTRule();
    _setLinewrap_5.before(_mL_COMMENTRule);
    FormattingConfig.LinewrapLocator _setLinewrap_6 = c.setLinewrap(0, 1, 1);
    TerminalRule _mL_COMMENTRule_1 = this._xModifGrammarAccess.getML_COMMENTRule();
    _setLinewrap_6.after(_mL_COMMENTRule_1);
  }
}
