Search in sources :

Example 11 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project bazel by bazelbuild.

the class TreePrunerTest method constructorChaining.

@Test
public void constructorChaining() {
    String[] lines = { "class Test {", "  Test() {", "    this(42);", "    process();", "  }", "  Test() {", "    this(42);", "  }", "  Test() {", "    super(42);", "  }", "  Test() {}", "}" };
    JCCompilationUnit tree = parseLines(lines);
    TreePruner.prune(context, tree);
    String[] expected = { "class Test {", "    ", "    Test() {", "        this(42);", "    }", "    ", "    Test() {", "        this(42);", "    }", "    ", "    Test() {", "        super(42);", "    }", "    ", "    Test() {", "    }", "}" };
    assertThat(prettyPrint(tree)).isEqualTo(Joiner.on('\n').join(expected));
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) Test(org.junit.Test)

Example 12 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project bazel by bazelbuild.

the class TreePrunerTest method initalizerBlocks.

@Test
public void initalizerBlocks() {
    String[] lines = { "class Test {", "  {", "    System.err.println(\"hello\");", "  }", "  static {", "    System.err.println(\"hello\");", "  }", "}" };
    JCCompilationUnit tree = parseLines(lines);
    TreePruner.prune(context, tree);
    String[] expected = { //
    "class Test {", "    {", "    }", "    static {", "    }", "}" };
    assertThat(prettyPrint(tree)).isEqualTo(Joiner.on('\n').join(expected));
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) Test(org.junit.Test)

Example 13 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method compilationUnit.

@Override
public JCCompilationUnit compilationUnit() {
    JCCompilationUnit result = super.compilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Example 14 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method parseCompilationUnit.

public JCCompilationUnit parseCompilationUnit() {
    JCCompilationUnit result = super.parseCompilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Example 15 with JCCompilationUnit

use of com.sun.tools.javac.tree.JCTree.JCCompilationUnit in project lombok by rzwitserloot.

the class CommentCollectingParser method parseCompilationUnit.

public JCCompilationUnit parseCompilationUnit() {
    JCCompilationUnit result = super.parseCompilationUnit();
    if (lexer instanceof CommentCollectingScanner) {
        List<CommentInfo> comments = ((CommentCollectingScanner) lexer).getComments();
        JCCompilationUnit_comments.set(result, comments);
    }
    return result;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CommentInfo(lombok.javac.CommentInfo)

Aggregations

JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)50 JCTree (com.sun.tools.javac.tree.JCTree)11 JavaFileObject (javax.tools.JavaFileObject)7 Test (org.junit.Test)7 JCClassDecl (com.sun.tools.javac.tree.JCTree.JCClassDecl)6 IOException (java.io.IOException)6 CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)5 TaskEvent (com.sun.source.util.TaskEvent)5 File (java.io.File)5 TaskListener (com.sun.source.util.TaskListener)4 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)4 ArrayList (java.util.ArrayList)4 ImmutableList (com.google.common.collect.ImmutableList)3 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)3 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)3 TreePath (com.sun.source.util.TreePath)3 JavacTool (com.sun.tools.javac.api.JavacTool)3 JCAnnotation (com.sun.tools.javac.tree.JCTree.JCAnnotation)3 JCAssign (com.sun.tools.javac.tree.JCTree.JCAssign)3 Context (com.sun.tools.javac.util.Context)3