langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
changeset 5009 4e3d2ff7d629
parent 5003 fd0b30cdbe5c
child 5520 86e4b9a9da40
equal deleted inserted replaced
5008:3a90203fa91e 5009:4e3d2ff7d629
   797         log = Log.instance(context);
   797         log = Log.instance(context);
   798         // Writer for -XprintRounds and -XprintProcessorInfo data
   798         // Writer for -XprintRounds and -XprintProcessorInfo data
   799         PrintWriter xout = context.get(Log.outKey);
   799         PrintWriter xout = context.get(Log.outKey);
   800         TaskListener taskListener = context.get(TaskListener.class);
   800         TaskListener taskListener = context.get(TaskListener.class);
   801 
   801 
   802 
       
   803         AnnotationCollector collector = new AnnotationCollector();
       
   804 
       
   805         JavaCompiler compiler = JavaCompiler.instance(context);
   802         JavaCompiler compiler = JavaCompiler.instance(context);
   806         compiler.todo.clear(); // free the compiler's resources
   803         compiler.todo.clear(); // free the compiler's resources
   807 
   804 
   808         int round = 0;
   805         int round = 0;
   809 
   806 
  1218         }
  1215         }
  1219 
  1216 
  1220         return false;
  1217         return false;
  1221     }
  1218     }
  1222 
  1219 
  1223     private static class AnnotationCollector extends TreeScanner {
       
  1224         List<JCTree> path = List.nil();
       
  1225         static final boolean verbose = false;
       
  1226         List<JCAnnotation> annotations = List.nil();
       
  1227 
       
  1228         public List<JCAnnotation> findAnnotations(List<? extends JCTree> nodes) {
       
  1229             annotations = List.nil();
       
  1230             scan(nodes);
       
  1231             List<JCAnnotation> found = annotations;
       
  1232             annotations = List.nil();
       
  1233             return found.reverse();
       
  1234         }
       
  1235 
       
  1236         public void scan(JCTree node) {
       
  1237             if (node == null)
       
  1238                 return;
       
  1239             Symbol sym = TreeInfo.symbolFor(node);
       
  1240             if (sym != null)
       
  1241                 path = path.prepend(node);
       
  1242             super.scan(node);
       
  1243             if (sym != null)
       
  1244                 path = path.tail;
       
  1245         }
       
  1246 
       
  1247         public void visitAnnotation(JCAnnotation node) {
       
  1248             annotations = annotations.prepend(node);
       
  1249             if (verbose) {
       
  1250                 StringBuilder sb = new StringBuilder();
       
  1251                 for (JCTree tree : path.reverse()) {
       
  1252                     System.err.print(sb);
       
  1253                     System.err.println(TreeInfo.symbolFor(tree));
       
  1254                     sb.append("  ");
       
  1255                 }
       
  1256                 System.err.print(sb);
       
  1257                 System.err.println(node);
       
  1258             }
       
  1259         }
       
  1260     }
       
  1261 
       
  1262     private static <T extends JCTree> List<T> cleanTrees(List<T> nodes) {
  1220     private static <T extends JCTree> List<T> cleanTrees(List<T> nodes) {
  1263         for (T node : nodes)
  1221         for (T node : nodes)
  1264             treeCleaner.scan(node);
  1222             treeCleaner.scan(node);
  1265         return nodes;
  1223         return nodes;
  1266     }
  1224     }