Examples of PPGrammarAccess


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

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=340166#c6
    // c.setLinewrap().after(ga.getPuppetManifestAccess().getStatementsAssignment_1());
  }

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

    Keyword lbr = ga.getNodeDefinitionAccess().getLeftCurlyBracketKeyword_4();
    Keyword rbr = ga.getNodeDefinitionAccess().getRightCurlyBracketKeyword_6();
    c.setLinewrap().after(lbr);
    c.setLinewrap().around(rbr);
    c.setIndentation(lbr, rbr);
  }
View Full Code Here

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

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

  protected void parenthisedExpressionConfguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    c.setNoSpace().after(ga.getParenthisedExpressionAccess().getLeftParenthesisKeyword_0());
    c.setNoSpace().before(ga.getParenthisedExpressionAccess().getRightParenthesisKeyword_3());
  }
View Full Code Here

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

   *
   * @param c
   *            - formatter to configure
   */
  protected void resourceExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();

    // + linebreak after «'title' :»
    for(Keyword colon : ga.getResourceBodyAccess().findKeywords(":")) {
      c.setLinewrap().after(colon);
      c.setNoLinewrap().before(colon);
    }
    // + indent the body of the resource expression
    {
      Keyword lbr = ga.getResourceExpressionAccess().getLeftCurlyBracketKeyword_0_1_1();
      Keyword rbr = ga.getResourceExpressionAccess().getRightCurlyBracketKeyword_0_1_3();
      c.setIndentation(lbr, rbr);
      c.setNoLinewrap().before(lbr);
      c.setLinewrap().after(lbr);
      c.setLinewrap().before(rbr);
      c.setLinewrap().after(rbr);
      Keyword endComma = ga.getAttributeOperationsAccess().getCommaKeyword_2();
      c.setLinewrap(1).between(endComma, rbr);
    }
    // repeat for literal class for of the rule
    {
      Keyword lbr = ga.getResourceExpressionAccess().getLeftCurlyBracketKeyword_1_2();
      Keyword rbr = ga.getResourceExpressionAccess().getRightCurlyBracketKeyword_1_4();
      c.setIndentation(lbr, rbr);
      c.setNoLinewrap().before(lbr);
      c.setLinewrap().after(lbr);
      c.setLinewrap().before(rbr);
      c.setLinewrap().after(rbr);
      Keyword endComma = ga.getAttributeOperationsAccess().getCommaKeyword_2();
      c.setLinewrap(1).between(endComma, rbr);
    }

    // + linebreak after «attribute (=>|+>) expr,»
    Keyword comma = ga.getAttributeOperationsAccess().getCommaKeyword_1_0_0();
    c.setNoLinewrap().before(comma);
    c.setLinewrap().after(comma);

    // c.setLinewrap().after(ga.getAttributeOperationsAccess().getCommaKeyword_2());
    // for(Keyword comma : ga.getAttributeOperationsAccess().findKeywords(",")) {
    // if(comma == ga.getAttributeOperationsAccess().get)
    // c.setLinewrap().after(comma);
    // }
    // linebreak after each resource body in a list of resource bodies
    {
      Keyword semi = ga.getResourceExpressionAccess().getSemicolonKeyword_0_1_2_1_0();
      c.setNoLinewrap().before(semi);
      c.setLinewrap(2).after(semi);
      Keyword endSemi = ga.getResourceExpressionAccess().getSemicolonKeyword_0_1_2_2();
      c.setNoLinewrap().before(endSemi);
      c.setLinewrap(1).after(endSemi);
    }
    { // repeat for second group
      Keyword semi = ga.getResourceExpressionAccess().getSemicolonKeyword_1_3_1_0();
      c.setNoLinewrap().before(semi);
      c.setLinewrap(2).after(semi);
      Keyword endSemi = ga.getResourceExpressionAccess().getSemicolonKeyword_1_3_2();
      c.setNoLinewrap().before(endSemi);
      c.setLinewrap(1).after(endSemi);
    }
    // c.setLinewrap(1).between(endSemi, rbr);

    // no wrap when RESOURCE -> RESOURCE is used
    // c.setNoLinewrap().before(ga.getRelationshipExpressionAccess().getOpNameAssignment_1_1());
    c.setNoLinewrap().before(ga.getRelationshipExpressionAccess().getOpNameAssignment_1_1());

    // + indent the list of attribute operations but only when when they have a title
    // TODO: 1.0GA (changing resource expression grammar)
    c.setIndentationIncrement().before(ga.getResourceBodyAccess().getAttributesAssignment_0_2());
    c.setIndentationDecrement().after(ga.getResourceBodyAccess().getAttributesAssignment_0_2());

    // this will always indent even if there is no title
    // c.setIndentationIncrement().before(ga.getAttributeOperationsRule());
    // c.setIndentationDecrement().after(ga.getAttributeOperationsRule());

    // this was workaround for bug in Xtext 1.0
    // for(Assignment theCall : ga.getResourceBodyAccess().findAssignments(ga.getAttributeOperationsRule())) {
    // c.setIndentationIncrement().before(theCall);
    // c.setIndentationDecrement().after(theCall);
    // }

    // No space between the two @@ in a virtual exported resource
    {
      Keyword at1 = ga.getVirtualNameOrReferenceAccess().getCommercialAtKeyword_0();
      RuleCall at2 = ga.getVirtualNameOrReferenceAccess().getExportedATBooleanParserRuleCall_1_0();
      RuleCall value = ga.getVirtualNameOrReferenceAccess().getValueUnionNameOrReferenceParserRuleCall_2_0();

      c.setNoSpace().between(at1, at2);
      c.setNoSpace().between(at1, value);
      c.setNoSpace().between(at2, value);
      // ga.getVirtualNameOrReferenceAccess().getCommercialAtKeyword_0(),
View Full Code Here

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

      // ga.getVirtualNameOrReferenceAccess().getExportedATBooleanParserRuleCall_1_0());
    }
  }

  protected void selectorExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    Keyword lbr = ga.getSelectorExpressionAccess().getLeftCurlyBracketKeyword_1_2_0_0();
    Keyword rbr = ga.getSelectorExpressionAccess().getRightCurlyBracketKeyword_1_2_0_4();
    c.setLinewrap().after(lbr);
    c.setLinewrap().before(rbr);
    c.setIndentation(lbr, rbr);
    Keyword comma = ga.getSelectorExpressionAccess().getCommaKeyword_1_2_0_2_0_0();
    // RuleCall endcomma = ga.getSelectorExpressionAccess().getEndCommaParserRuleCall_1_3_0_4_0();

    c.setLinewrap().after(comma);
    c.setLinewrap(1).between(comma, rbr);
    // c.setLinewrap(1).between(endcomma, rbr);
View Full Code Here

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

    c.setLinewrap(1).between(comma, rbr);
    // c.setLinewrap(1).between(endcomma, rbr);
  }

  protected void stringExpressionConfiguration(FormattingConfig c) {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    c.setNoSpace().after(ga.getUnquotedStringAccess().getDollarSignLeftCurlyBracketKeyword_1());
    c.setNoSpace().before(ga.getUnquotedStringAccess().getRightCurlyBracketKeyword_3());
  }
View Full Code Here

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

    // to parse. (Note that some rules are tricky to call from the outside
    // as the "hidden" configuration may have to be a certain way). Parsing
    // PuppetManifest, or the high level Expression, or ExprList, should be
    // fine.
    //
    PPGrammarAccess ga = runner.get(PPGrammarAccess.class);

    // Parse a string using the root rule "PuppetManifest"
    // throws an exception with the IParseResult if there are syntax errors
    // (test just fails if that is the case).
    IParseResult parseResult = runner.parseString(ga.getPuppetManifestRule(), "'I am often quoted'");

    // The RootASTElement is an instance of what the grammar rule specified
    // as return
    // (In this case a PuppetManifest).
    EObject result = parseResult.getRootASTElement();
View Full Code Here

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

  // return '"' + s + '"';
  // }

  @Test
  public void test_Parse_LiteralNameOrReference_NotOk() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();
    for(String s : invalidNames) {
      IParseResult result = parser.parse(ga.getUnionNameOrReferenceRule(), new StringReader(s));
      assertTrue("Should have errors for: " + s, result.hasSyntaxErrors());
    }

  }
View Full Code Here

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

  }

  @Test
  public void test_Parse_LiteralNameOrReference_Ok() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();
    for(String s : validNames) {
      IParseResult result = parser.parse(ga.getUnionNameOrReferenceRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
    }
    for(String s : validNames) {
      if("class".equals(s))
        continue; // 'class' alone is not a valid value expression
      IParseResult result = parser.parse(ga.getExpressionRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
      EObject root = result.getRootASTElement();
      // if("class".equals(s)) {
      // assertTrue("Should be ResourceExpression", root instanceof ResourceExpression);
      // }
      // else {
      assertTrue("Should be LiteralNameOrReference", root instanceof LiteralNameOrReference);
      assertEquals("Literal should be same as input", s, ((LiteralNameOrReference) root).getValue());
      // }
    }
    for(String s : validNames) {
      if("class".equals(s))
        continue; // 'class' alone is not a balid value expression
      IParseResult result = parser.parse(ga.getPuppetManifestRule(), new StringReader(s));
      assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
      assertEquals("parsed should be same as input", s, result.getRootNode().getText());
      EObject root = result.getRootASTElement();
      assertTrue("Should be PuppetManifest", root instanceof PuppetManifest);
      PuppetManifest pm = (PuppetManifest) root;
View Full Code Here

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

  }

  @Test
  public void test_Parse_LiteralsInResource_Smoketest() {
    PPGrammarAccess ga = (PPGrammarAccess) getGrammarAccess();
    PPParser parser = (PPParser) getParser();

    String s = "File { mode => 666 }";
    IParseResult result = parser.parse(ga.getPuppetManifestRule(), new StringReader(s));
    assertFalse("Should not have errors for: " + s, result.hasSyntaxErrors());
    assertEquals("parsed should be same as input", s, result.getRootNode().getText());
    EObject root = result.getRootASTElement();
    assertTrue("Should be PuppetManifest", root instanceof PuppetManifest);
    PuppetManifest pm = (PuppetManifest) root;
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.