Package lombok.ast.printer

Examples of lombok.ast.printer.StructureFormatter.finish()


      if (!problems.isEmpty()) fail("position error: " + problems.get(0));
    } catch (AssertionError e) {
      System.out.println("-------PARSED-PRINTED:");
      StructureFormatter formatter2 = StructureFormatter.formatterWithPositions();
      node.accept(new SourcePrinter(formatter2));
      System.out.println(formatter2.finish());
      System.out.println("--------------PRINTED:");
      System.out.println(formatter.finish());
      System.out.println("----------------------");
      throw e;
    }
View Full Code Here


    normalizeNumberLiterals(tree);
    StructureFormatter formatter = StructureFormatter.formatterWithoutPositions();
    formatter.skipProperty(CharLiteral.class, "value");
    formatter.skipProperty(StringLiteral.class, "value");
    tree.accept(new SourcePrinter(formatter));
    return formatter.finish();
  }
 
  protected Node parseWithLombok(Source source) {
    List<Node> nodes = source.getNodes();
    assertEquals(1, nodes.size());
View Full Code Here

    deleteComments(tree);
    StructureFormatter formatter = StructureFormatter.formatterWithoutPositions();
    formatter.skipProperty(CharLiteral.class, "value");
    formatter.skipProperty(StringLiteral.class, "value");
    tree.accept(new SourcePrinter(formatter));
    return formatter.finish();
  }
 
  private static void deleteComments(Node tree) {
    tree.accept(new ForwardingAstVisitor() {
      @Override public boolean visitComment(Comment node) {
View Full Code Here

"                PROPERTY: name = bar",
"    [B Block (90-90)]",
"            [B Return (90-90)]",
"                [I IntegralLiteral 5 (90-90)]",
"                    PROPERTY: value = 5"
        ), sf.finish());
  }
 
  @Test
  public void testExpression() {
    Expression expr = Template.parseExpression("5 + (a ? b : 10)");
View Full Code Here

"                PROPERTY: name = a",
"        ifTrue: [I FloatingPointLiteral 0.5 (20-30)]",
"            PROPERTY: value = 0.5",
"        ifFalse: [I IntegralLiteral 10 (30-30)]",
"            PROPERTY: value = 10"
        ), sf.finish());
  }
 
  @Test
  public void testStatements() {
    String expected1 = literal(
View Full Code Here

      template.setStartPosition(20);
      template.replaceStatement("foo", x);
      ClassDeclaration finish = template.finish();
      StructureFormatter sf = StructureFormatter.formatterWithPositions();
      finish.accept(new SourcePrinter(sf));
      assertEquals(expected1, sf.finish());
    }
   
    {
      Template<ClassDeclaration> template = Template.of(classDecl);
      Statement x = new Synchronized().astBody(new Block()).astLock(new This());
View Full Code Here

      template.setStartPosition(20);
      template.replaceStatement("foo", x, new Position(60, 80));
      ClassDeclaration finish = template.finish();
      StructureFormatter sf = StructureFormatter.formatterWithPositions();
      finish.accept(new SourcePrinter(sf));
      assertEquals(expected1, sf.finish());
    }
   
    String expected2 = literal(
"[B ClassDeclaration X (20-200)]",
"    [I Modifiers (20-20)]",
View Full Code Here

      template.setStartPosition(20);
      template.replaceStatement("foo", Arrays.asList(x, y));
      ClassDeclaration finish = template.finish();
      StructureFormatter sf = StructureFormatter.formatterWithPositions();
      finish.accept(new SourcePrinter(sf));
      assertEquals(expected2, sf.finish());
    }
  }
}
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.