src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java

Print this page




 673         // TODO: Create proper argument values; need past round
 674         // information to fill in this constructor.  Note that the 1
 675         // st round of processing could be the last round if there
 676         // were parse errors on the initial source files; however, we
 677         // are not doing processing in that case.
 678 
 679         Set<Element> rootElements = new LinkedHashSet<Element>();
 680         rootElements.addAll(topLevelClasses);
 681         rootElements.addAll(packageInfoFiles);
 682         rootElements = Collections.unmodifiableSet(rootElements);
 683 
 684         RoundEnvironment renv = new JavacRoundEnvironment(false,
 685                                                           false,
 686                                                           rootElements,
 687                                                           JavacProcessingEnvironment.this);
 688 
 689         while(unmatchedAnnotations.size() > 0 && psi.hasNext() ) {
 690             ProcessorState ps = psi.next();
 691             Set<String>  matchedNames = new HashSet<String>();
 692             Set<TypeElement> typeElements = new LinkedHashSet<TypeElement>();
 693             for (String unmatchedAnnotationName : unmatchedAnnotations.keySet()) {


 694                 if (ps.annotationSupported(unmatchedAnnotationName) ) {
 695                     matchedNames.add(unmatchedAnnotationName);
 696                     TypeElement te = unmatchedAnnotations.get(unmatchedAnnotationName);
 697                     if (te != null)
 698                         typeElements.add(te);
 699                 }
 700             }
 701 
 702             if (matchedNames.size() > 0 || ps.contributed) {
 703                 foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor);
 704                 boolean processingResult = callProcessor(ps.processor, typeElements, renv);
 705                 ps.contributed = true;
 706                 ps.removeSupportedOptions(unmatchedProcessorOptions);
 707 
 708                 if (printProcessorInfo || verbose) {
 709                     xout.println(Log.getLocalizedString("x.print.processor.info",
 710                                                         ps.processor.getClass().getName(),
 711                                                         matchedNames.toString(),
 712                                                         processingResult));
 713                 }
 714 
 715                 if (processingResult) {
 716                     unmatchedAnnotations.keySet().removeAll(matchedNames);


1201 
1202         String procPath;
1203         URL[] urls = new URL[1];
1204         for(File pathElement : workingpath) {
1205             try {
1206                 urls[0] = pathElement.toURI().toURL();
1207                 if (ServiceProxy.hasService(Processor.class, urls))
1208                     return true;
1209             } catch (MalformedURLException ex) {
1210                 throw new AssertionError(ex);
1211             }
1212             catch (ServiceProxy.ServiceConfigurationError e) {
1213                 log.error("proc.bad.config.file", e.getLocalizedMessage());
1214                 return true;
1215             }
1216         }
1217 
1218         return false;
1219     }
1220 
1221     private class AnnotationCollector extends TreeScanner {
1222         List<JCTree> path = List.nil();
1223         static final boolean verbose = false;
1224         List<JCAnnotation> annotations = List.nil();
1225 
1226         public List<JCAnnotation> findAnnotations(List<? extends JCTree> nodes) {
1227             annotations = List.nil();
1228             scan(nodes);
1229             List<JCAnnotation> found = annotations;
1230             annotations = List.nil();
1231             return found.reverse();
1232         }
1233 
1234         public void scan(JCTree node) {
1235             if (node == null)
1236                 return;
1237             Symbol sym = TreeInfo.symbolFor(node);
1238             if (sym != null)
1239                 path = path.prepend(node);
1240             super.scan(node);
1241             if (sym != null)




 673         // TODO: Create proper argument values; need past round
 674         // information to fill in this constructor.  Note that the 1
 675         // st round of processing could be the last round if there
 676         // were parse errors on the initial source files; however, we
 677         // are not doing processing in that case.
 678 
 679         Set<Element> rootElements = new LinkedHashSet<Element>();
 680         rootElements.addAll(topLevelClasses);
 681         rootElements.addAll(packageInfoFiles);
 682         rootElements = Collections.unmodifiableSet(rootElements);
 683 
 684         RoundEnvironment renv = new JavacRoundEnvironment(false,
 685                                                           false,
 686                                                           rootElements,
 687                                                           JavacProcessingEnvironment.this);
 688 
 689         while(unmatchedAnnotations.size() > 0 && psi.hasNext() ) {
 690             ProcessorState ps = psi.next();
 691             Set<String>  matchedNames = new HashSet<String>();
 692             Set<TypeElement> typeElements = new LinkedHashSet<TypeElement>();
 693 
 694             for (Map.Entry<String, TypeElement> entry: unmatchedAnnotations.entrySet()) {
 695                 String unmatchedAnnotationName = entry.getKey();
 696                 if (ps.annotationSupported(unmatchedAnnotationName) ) {
 697                     matchedNames.add(unmatchedAnnotationName);
 698                     TypeElement te = entry.getValue();
 699                     if (te != null)
 700                         typeElements.add(te);
 701                 }
 702             }
 703 
 704             if (matchedNames.size() > 0 || ps.contributed) {
 705                 foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor);
 706                 boolean processingResult = callProcessor(ps.processor, typeElements, renv);
 707                 ps.contributed = true;
 708                 ps.removeSupportedOptions(unmatchedProcessorOptions);
 709 
 710                 if (printProcessorInfo || verbose) {
 711                     xout.println(Log.getLocalizedString("x.print.processor.info",
 712                                                         ps.processor.getClass().getName(),
 713                                                         matchedNames.toString(),
 714                                                         processingResult));
 715                 }
 716 
 717                 if (processingResult) {
 718                     unmatchedAnnotations.keySet().removeAll(matchedNames);


1203 
1204         String procPath;
1205         URL[] urls = new URL[1];
1206         for(File pathElement : workingpath) {
1207             try {
1208                 urls[0] = pathElement.toURI().toURL();
1209                 if (ServiceProxy.hasService(Processor.class, urls))
1210                     return true;
1211             } catch (MalformedURLException ex) {
1212                 throw new AssertionError(ex);
1213             }
1214             catch (ServiceProxy.ServiceConfigurationError e) {
1215                 log.error("proc.bad.config.file", e.getLocalizedMessage());
1216                 return true;
1217             }
1218         }
1219 
1220         return false;
1221     }
1222 
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)