Examples of PPGrammarAccess


Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

* TODO: Formatting currently plagued by bugs in Xtext 2.0. See JUnit tests.
*/
public class PPFormatter extends AbstractDeclarativeFormatter {

  protected void assignmentExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    c.setLinewrap().after(ga.getAssignmentExpressionAccess().getGroup_1());
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    c.setLinewrap().after(ga.getAssignmentExpressionAccess().getGroup_1());
  }

  protected void atExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    // At expression
    // -- no space between EXPR and [
    // -- no space after opening [
    // -- no space before closing ]
    c.setNoSpace().before(ga.getAtExpressionAccess().getLeftSquareBracketKeyword_1_1());
    c.setNoSpace().after(ga.getAtExpressionAccess().getLeftSquareBracketKeyword_1_1());
    c.setNoSpace().before(ga.getAtExpressionAccess().getRightSquareBracketKeyword_1_3());

  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    c.setNoSpace().before(ga.getAtExpressionAccess().getRightSquareBracketKeyword_1_3());

  }

  protected void caseExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();

    Keyword caseLbr = ga.getCaseAccess().getLeftCurlyBracketKeyword_3();
    Keyword caseRbr = ga.getCaseAccess().getRightCurlyBracketKeyword_5();
    c.setLinewrap().after(caseLbr);
    c.setLinewrap().around(caseRbr);
    c.setIndentation(caseLbr, caseRbr);

    caseLbr = ga.getCaseExpressionAccess().getLeftCurlyBracketKeyword_2();
    caseRbr = ga.getCaseExpressionAccess().getRightCurlyBracketKeyword_4();
    c.setLinewrap().after(caseLbr);
    c.setLinewrap().around(caseRbr);
    c.setIndentation(caseLbr, caseRbr);
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    c.setLinewrap().around(caseRbr);
    c.setIndentation(caseLbr, caseRbr);
  }

  protected void classExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();

    Keyword lbr = ga.getHostClassDefinitionAccess().getLeftCurlyBracketKeyword_4();
    Keyword rbr = ga.getHostClassDefinitionAccess().getRightCurlyBracketKeyword_6();
    c.setLinewrap().after(lbr);
    c.setLinewrap().around(rbr);
    c.setIndentation(lbr, rbr);

    // linewrap statements
    // not a good idea since non-parenthesised function calls are separate expressions,
    // each 'statement' must do its own terminating linewrap
    // c.setLinewrap().after(ga.getHostClassDefinitionAccess().getStatementsAssignment_5());

    // but not between what is a non parenthesized function call
    // TODO: Broken...
    c.setNoLinewrap().between(ga.getLiteralNameOrReferenceRule(), ga.getLiteralNameOrReferenceRule());
    // as per https://bugs.eclipse.org/bugs/show_bug.cgi?id=340166#c5
    // c.setNoLinewrap().between(ga.getLiteralNameOrReferenceRule(), ga.getExpressionListRule());

  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    // c.setNoLinewrap().between(ga.getLiteralNameOrReferenceRule(), ga.getExpressionListRule());

  }

  protected void collectExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    c.setLinewrap().after(ga.getCollectExpressionAccess().getLeftCurlyBracketKeyword_1_2_0());
    c.setIndentation(
      ga.getCollectExpressionAccess().getLeftCurlyBracketKeyword_1_2_0(),
      ga.getCollectExpressionAccess().getRightCurlyBracketKeyword_1_2_2());
    c.setLinewrap().before(ga.getCollectExpressionAccess().getRightCurlyBracketKeyword_1_2_2());
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    c.setLinewrap().before(ga.getCollectExpressionAccess().getRightCurlyBracketKeyword_1_2_2());
  }

  @Override
  protected void configureFormatting(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();

    // not a good idea since non-parenthesised function calls are separate expressions,
    // each 'statement' must do its own terminating linewrap
    // c.setLinewrap().after(ga.getPuppetManifestAccess().getStatementsAssignment_2());

    // Add add and preserve newlines around comments
    c.setLinewrap(0, 1, 2).before(ga.getSL_COMMENTRule());

    // NOTE: default set to 0 to allow "inline" comments like /* this one */ without requiring
    // a linewrap.
    c.setLinewrap(0, 0, 2).before(ga.getML_COMMENTRule());
    c.setLinewrap(0, 0, 1).after(ga.getML_COMMENTRule());

    stringExpressionConfiguration(c);
    ifExpressionConfiguration(c);
    caseExpressionConfiguration(c);
    classExpressionConfiguration(c);
    selectorExpressionConfiguration(c);
    definitionExpressionConfiguration(c);
    assignmentExpressionConfiguration(c);
    importExpressionConfiguration(c);
    literalListAndHashConfiguration(c);
    functionCallConfiguration(c);
    nodeExpressionConfiguration(c);
    // commas
    for(Keyword comma : ga.findKeywords(",")) {
      c.setNoSpace().before(comma);
    }

    // TODO: Old formatter needs this fixed since there is no endComma rule - they are just optional commas in
    // various expressions. They may be ok already with a general rule "no space before a comma keyword".
    // c.setNoSpace().before(ga.getEndCommaRule());

    // no space between unary operators (! -) and the following expression
    c.setNoSpace().after(ga.getNotExpressionAccess().getExclamationMarkKeyword_0());
    c.setNoSpace().after(ga.getUnaryMinusExpressionAccess().getHyphenMinusKeyword_0());

    resourceExpressionConfiguration(c);
    collectExpressionConfiguration(c);
    atExpressionConfiguration(c);
    parenthisedExpressionConfguration(c);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    // Create opportunity to use the TokenStreamWrapper around out... (used for debugging).
    return super.createFormatterStream(indent, out, preserveWhitespaces);
  }

  protected void definitionExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    Keyword lbr = ga.getDefinitionAccess().getLeftCurlyBracketKeyword_3();
    Keyword rbr = ga.getDefinitionAccess().getRightCurlyBracketKeyword_5();
    c.setLinewrap().after(lbr);
    c.setLinewrap().around(rbr);
    c.setIndentation(lbr, rbr);

    List<Pair<Keyword, Keyword>> pairs = ga.getDefinitionArgumentListAccess().findKeywordPairs("(", ")");
    if(pairs.size() == 1) {
      c.setIndentation(pairs.get(0).getFirst(), pairs.get(0).getSecond());
      c.setNoSpace().after(pairs.get(0).getFirst());
      c.setNoSpace().before(pairs.get(0).getSecond());
    }
    List<Keyword> commas = ga.getDefinitionArgumentListAccess().findKeywords(",");
    for(Keyword comma : commas)
      c.setLinewrap().after(comma);
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    // c.setNoSpace().after(ga.getFunctionCallAccess().getLeftParenthesisKeyword_1_1());
    // c.setNoSpace().before(ga.getFunctionCallAccess().getRightParenthesisKeyword_1_3());
  }

  protected void ifExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    Keyword lbr = ga.getIfExpressionAccess().getLeftCurlyBracketKeyword_2();
    Keyword rbr = ga.getIfExpressionAccess().getRightCurlyBracketKeyword_4();
    c.setLinewrap().after(lbr);
    c.setIndentation(lbr, rbr);
    c.setLinewrap().around(rbr);

    lbr = ga.getElseExpressionAccess().getLeftCurlyBracketKeyword_1();
    rbr = ga.getElseExpressionAccess().getRightCurlyBracketKeyword_3();
    c.setLinewrap().after(lbr);
    c.setIndentation(lbr, rbr);
    c.setLinewrap().around(rbr);

    lbr = ga.getElseIfExpressionAccess().getLeftCurlyBracketKeyword_2();
    rbr = ga.getElseIfExpressionAccess().getRightCurlyBracketKeyword_4();
    c.setLinewrap().after(lbr);
    c.setIndentation(lbr, rbr);
    c.setLinewrap().around(rbr);
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    c.setIndentation(lbr, rbr);
    c.setLinewrap().around(rbr);
  }

  protected void importExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    // This does not work - no element of Import makes the linewrap take effect
    c.setLinewrap().after(ga.getImportExpressionAccess().getGroup_2());
  }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.dsl.services.PPGrammarAccess

    // This does not work - no element of Import makes the linewrap take effect
    c.setLinewrap().after(ga.getImportExpressionAccess().getGroup_2());
  }

  protected void literalListAndHashConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    // -- no space after opening [
    // -- no space before closing ]
    c.setNoSpace().after(ga.getLiteralListAccess().getLeftSquareBracketKeyword_1());
    c.setNoSpace().before(ga.getLiteralListAccess().getRightSquareBracketKeyword_3());

    // -- no space after opening {
    // -- no space before closing }
    c.setNoSpace().after(ga.getLiteralHashAccess().getLeftCurlyBracketKeyword_1());
    c.setNoSpace().before(ga.getLiteralHashAccess().getRightCurlyBracketKeyword_4());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.