50 @SupportedAnnotationTypes("*")
51 public class TestDeprecation extends AbstractProcessor {
52
53 public boolean process(Set<? extends TypeElement> annotations,
54 RoundEnvironment roundEnv) {
55 boolean failure = false;
56 if (!roundEnv.processingOver()) {
57 DeprecationChecker deprecationChecker = new DeprecationChecker();
58
59 for(Element element: roundEnv.getRootElements() ) {
60 System.out.println("\nRoot Element: " + element.getSimpleName());
61 failure = deprecationChecker.scan(element);
62 }
63
64 if (failure)
65 processingEnv.getMessager().printMessage(ERROR, "Deprecation mismatch found!");
66 }
67 return true;
68 }
69
70 private class DeprecationChecker extends ElementScanner6<Boolean,Void> {
71 private Elements elementUtils;
72 private boolean failure;
73 DeprecationChecker() {
74 super(false);
75 elementUtils = processingEnv.getElementUtils();
76 failure = false;
77 }
78
79 @Override
80 public Boolean scan(Element e, Void p) {
81 boolean expectedDeprecation = false;
82 ExpectedDeprecation tmp = e.getAnnotation(ExpectedDeprecation.class);
83 if (tmp != null)
84 expectedDeprecation = tmp.value();
85 boolean actualDeprecation = elementUtils.isDeprecated(e);
86
87 System.out.printf("\tVisiting %s\t%s%n", e.getKind(), e.getSimpleName());
88
89 if (expectedDeprecation != actualDeprecation) {
90 failure = true;
|
50 @SupportedAnnotationTypes("*")
51 public class TestDeprecation extends AbstractProcessor {
52
53 public boolean process(Set<? extends TypeElement> annotations,
54 RoundEnvironment roundEnv) {
55 boolean failure = false;
56 if (!roundEnv.processingOver()) {
57 DeprecationChecker deprecationChecker = new DeprecationChecker();
58
59 for(Element element: roundEnv.getRootElements() ) {
60 System.out.println("\nRoot Element: " + element.getSimpleName());
61 failure = deprecationChecker.scan(element);
62 }
63
64 if (failure)
65 processingEnv.getMessager().printMessage(ERROR, "Deprecation mismatch found!");
66 }
67 return true;
68 }
69
70 private class DeprecationChecker extends ElementScanner7<Boolean,Void> {
71 private Elements elementUtils;
72 private boolean failure;
73 DeprecationChecker() {
74 super(false);
75 elementUtils = processingEnv.getElementUtils();
76 failure = false;
77 }
78
79 @Override
80 public Boolean scan(Element e, Void p) {
81 boolean expectedDeprecation = false;
82 ExpectedDeprecation tmp = e.getAnnotation(ExpectedDeprecation.class);
83 if (tmp != null)
84 expectedDeprecation = tmp.value();
85 boolean actualDeprecation = elementUtils.isDeprecated(e);
86
87 System.out.printf("\tVisiting %s\t%s%n", e.getKind(), e.getSimpleName());
88
89 if (expectedDeprecation != actualDeprecation) {
90 failure = true;
|