Package lombok.ast.printer

Examples of lombok.ast.printer.SourcePrinter


    return position;
  }

  @Override public String toString() {
    TextFormatter formatter = new TextFormatter();
    SourcePrinter printer = new SourcePrinter(formatter);
    accept(printer);
    return formatter.finish();
  }
View Full Code Here


      fail(source.getProblems().get(0).toString());
    }
   
    Node node = source.getNodes().get(0);
    PositionCheckingFormatter formatter = new PositionCheckingFormatter(source);
    node.accept(new SourcePrinter(formatter));
    List<AstException> problems = formatter.getProblems();
    try {
      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

    foldStringConcats(tree);
    normalizeNumberLiterals(tree);
    StructureFormatter formatter = StructureFormatter.formatterWithoutPositions();
    formatter.skipProperty(CharLiteral.class, "value");
    formatter.skipProperty(StringLiteral.class, "value");
    tree.accept(new SourcePrinter(formatter));
    return formatter.finish();
  }
View Full Code Here

      fail(source.getProblems().get(0).toString());
    }
   
    Node node = source.getNodes().get(0);
    TextFormatter formatter = new TextFormatter();
    node.accept(new SourcePrinter(formatter));
    String actual = fixLineEndings(formatter.finish());
    String original = fixLineEndings(source.getRawInput());
    try {
      assertEquals(original, actual);
    } catch (AssertionError e) {
View Full Code Here

    simplifyArrayDecls(tree);
    deleteComments(tree);
    StructureFormatter formatter = StructureFormatter.formatterWithoutPositions();
    formatter.skipProperty(CharLiteral.class, "value");
    formatter.skipProperty(StringLiteral.class, "value");
    tree.accept(new SourcePrinter(formatter));
    return formatter.finish();
  }
View Full Code Here

      fail(actual.getProblems().get(0).toString());
    }
   
    Node node = actual.getNodes().get(0);
    TextFormatter formatter = new TextFormatter();
    node.accept(new SourcePrinter(formatter));
    String actualString = formatter.finish();
   
    assertEquals(fixLineEndings(expected), fixLineEndings(actualString));
  }
View Full Code Here

    template.setStartPosition(10);
    template.replaceIdentifier("testing", "floobargle", new Position(50, 60));
    template.replaceIdentifier("foo", "bar", new Position(80, 90));
    MethodDeclaration finish = template.finish();
    StructureFormatter sf = StructureFormatter.formatterWithPositions();
    finish.accept(new SourcePrinter(sf));
    assertEquals(literal(
"[B MethodDeclaration floobargle (10-90)]",
"    [I Modifiers (10-10)]",
"        [I KeywordModifier public (10-10)]",
"            PROPERTY: modifier = public",
View Full Code Here

    Expression replacement = new FloatingPointLiteral().astDoubleValue(0.5);
    template.setStartPosition(10);
    template.replaceExpression("b", replacement, new Position(20, 30));
    Expression finish = template.finish();
    StructureFormatter sf = StructureFormatter.formatterWithPositions();
    finish.accept(new SourcePrinter(sf));
    assertEquals(literal(
"[I BinaryExpression + (10-30)]",
"    PROPERTY: operator = +",
"    left: [I IntegralLiteral 5 (10-10)]",
"        PROPERTY: value = 5",
View Full Code Here

      Ast.setAllPositions(x, new Position(60, 80));
      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());
      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)]",
"    typeName: [I Identifier X (20-20)]",
"        PROPERTY: name = X",
"    [B NormalTypeBody (20-200)]",
"            [B InstanceInitializer (20-200)]",
"                [B Block (20-200)]",
"                        [B Synchronized (40-50)]",
"                            lock: [I This (40-50)]",
"                            [B Block (40-50)]",
"                        [B While (100-200)]",
"                            condition: [I BooleanLiteral (100-200)]",
"                                PROPERTY: value = true",
"                            [B EmptyStatement (100-200)]");
   
    {
      Template<ClassDeclaration> template = Template.of(classDecl);
      Statement x = new Synchronized().astBody(new Block()).astLock(new This());
      Statement y = new While().astCondition(new BooleanLiteral().astValue(true)).astStatement(new EmptyStatement());
      Ast.setAllPositions(x, new Position(40, 50));
      Ast.setAllPositions(y, new Position(100, 200));
      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

Related Classes of lombok.ast.printer.SourcePrinter

Copyright © 2018 www.massapicom. 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.