test/langtools/tools/javac/processing/6994946/TestProcessor.java
changeset 53773 454d54d8af1c
parent 47216 71c04702a3d5
equal deleted inserted replaced
53772:0eca4e6a0037 53773:454d54d8af1c
    25 import javax.annotation.processing.*;
    25 import javax.annotation.processing.*;
    26 import javax.lang.model.*;
    26 import javax.lang.model.*;
    27 import javax.lang.model.element.*;
    27 import javax.lang.model.element.*;
    28 import static javax.tools.Diagnostic.Kind.*;
    28 import static javax.tools.Diagnostic.Kind.*;
    29 
    29 
       
    30 import com.sun.source.util.TreePath;
       
    31 import com.sun.source.util.Trees;
       
    32 
    30 public class TestProcessor extends JavacTestingAbstractProcessor {
    33 public class TestProcessor extends JavacTestingAbstractProcessor {
    31    private int round = 0;
    34    private int round = 0;
    32 
    35 
    33    public boolean process(Set<? extends TypeElement> annotations,
    36    public boolean process(Set<? extends TypeElement> annotations,
    34                   RoundEnvironment roundEnv) {
    37                   RoundEnvironment roundEnv) {
    35         if (++round == 1)
    38         if (++round == 1) {
    36             messager.printMessage(ERROR, "Deliberate Error");
    39             messager.printMessage(ERROR, "Deliberate Error");
       
    40             Trees trees = Trees.instance(processingEnv);
       
    41             TreePath elPath = trees.getPath(roundEnv.getRootElements().iterator().next());
       
    42             trees.printMessage(ERROR, "Deliberate Error on Trees",
       
    43                                elPath.getLeaf(), elPath.getCompilationUnit());
       
    44         }
    37         return false;
    45         return false;
    38    }
    46    }
    39 }
    47 }
    40 
    48