langtools/test/tools/javac/api/TestOperators.java
changeset 10192 378321489bea
parent 7681 1f0819a3341f
child 30730 d3ce7619db2c
equal deleted inserted replaced
10191:9e93a8e0a880 10192:378321489bea
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug     6338064 6346249 6340951 6392177
    26  * @bug     6338064 6346249 6340951 6392177
    27  * @summary Tree API: can't determine kind of operator
    27  * @summary Tree API: can't determine kind of operator
    28  * @author  Peter von der Ah\u00e9
    28  * @author  Peter von der Ah\u00e9
    29  * @compile TestOperators.java
    29  * @library ../lib
       
    30  * @build JavacTestingAbstractProcessor TestOperators
    30  * @compile -processor TestOperators -proc:only TestOperators.java
    31  * @compile -processor TestOperators -proc:only TestOperators.java
    31  */
    32  */
    32 
    33 
    33 import java.util.Set;
    34 import java.util.Set;
    34 import javax.annotation.processing.*;
    35 import javax.annotation.processing.*;
    44 @interface TestMe {
    45 @interface TestMe {
    45     Tree.Kind value();
    46     Tree.Kind value();
    46 }
    47 }
    47 
    48 
    48 @SupportedAnnotationTypes("TestMe")
    49 @SupportedAnnotationTypes("TestMe")
    49 public class TestOperators extends AbstractProcessor {
    50 public class TestOperators extends JavacTestingAbstractProcessor {
    50 
    51 
    51     @TestMe(POSTFIX_INCREMENT)
    52     @TestMe(POSTFIX_INCREMENT)
    52     public int test_POSTFIX_INCREMENT(int i) {
    53     public int test_POSTFIX_INCREMENT(int i) {
    53         return i++;
    54         return i++;
    54     }
    55     }
   297                            RoundEnvironment roundEnvironment)
   298                            RoundEnvironment roundEnvironment)
   298     {
   299     {
   299         final Trees trees = Trees.instance(processingEnv);
   300         final Trees trees = Trees.instance(processingEnv);
   300         final Messager log = processingEnv.getMessager();
   301         final Messager log = processingEnv.getMessager();
   301         final Elements elements = processingEnv.getElementUtils();
   302         final Elements elements = processingEnv.getElementUtils();
   302         class Scan extends ElementScanner7<Void,Void> {
   303         class Scan extends ElementScanner<Void,Void> {
   303             @Override
   304             @Override
   304             public Void visitExecutable(ExecutableElement e, Void p) {
   305             public Void visitExecutable(ExecutableElement e, Void p) {
   305                 Object debug = e; // info for exception handler
   306                 Object debug = e; // info for exception handler
   306                 try {
   307                 try {
   307                     TestMe info = e.getAnnotation(TestMe.class);
   308                     TestMe info = e.getAnnotation(TestMe.class);
   341         for (Element e : roundEnvironment.getRootElements()) {
   342         for (Element e : roundEnvironment.getRootElements()) {
   342             scan.scan(e);
   343             scan.scan(e);
   343         }
   344         }
   344         return true;
   345         return true;
   345     }
   346     }
   346 
       
   347 }
   347 }