652 |
652 |
653 private void discoverAndRunProcs(Context context, |
653 private void discoverAndRunProcs(Context context, |
654 Set<TypeElement> annotationsPresent, |
654 Set<TypeElement> annotationsPresent, |
655 List<ClassSymbol> topLevelClasses, |
655 List<ClassSymbol> topLevelClasses, |
656 List<PackageSymbol> packageInfoFiles) { |
656 List<PackageSymbol> packageInfoFiles) { |
657 // Writer for -XprintRounds and -XprintProcessorInfo data |
|
658 PrintWriter xout = context.get(Log.outKey); |
|
659 |
|
660 Map<String, TypeElement> unmatchedAnnotations = |
657 Map<String, TypeElement> unmatchedAnnotations = |
661 new HashMap<String, TypeElement>(annotationsPresent.size()); |
658 new HashMap<String, TypeElement>(annotationsPresent.size()); |
662 |
659 |
663 for(TypeElement a : annotationsPresent) { |
660 for(TypeElement a : annotationsPresent) { |
664 unmatchedAnnotations.put(a.getQualifiedName().toString(), |
661 unmatchedAnnotations.put(a.getQualifiedName().toString(), |
706 boolean processingResult = callProcessor(ps.processor, typeElements, renv); |
703 boolean processingResult = callProcessor(ps.processor, typeElements, renv); |
707 ps.contributed = true; |
704 ps.contributed = true; |
708 ps.removeSupportedOptions(unmatchedProcessorOptions); |
705 ps.removeSupportedOptions(unmatchedProcessorOptions); |
709 |
706 |
710 if (printProcessorInfo || verbose) { |
707 if (printProcessorInfo || verbose) { |
711 xout.println(Log.getLocalizedString("x.print.processor.info", |
708 log.printNoteLines("x.print.processor.info", |
712 ps.processor.getClass().getName(), |
709 ps.processor.getClass().getName(), |
713 matchedNames.toString(), |
710 matchedNames.toString(), |
714 processingResult)); |
711 processingResult); |
715 } |
712 } |
716 |
713 |
717 if (processingResult) { |
714 if (processingResult) { |
718 unmatchedAnnotations.keySet().removeAll(matchedNames); |
715 unmatchedAnnotations.keySet().removeAll(matchedNames); |
719 } |
716 } |
793 List<ClassSymbol> classSymbols, |
790 List<ClassSymbol> classSymbols, |
794 Iterable<? extends PackageSymbol> pckSymbols) |
791 Iterable<? extends PackageSymbol> pckSymbols) |
795 throws IOException { |
792 throws IOException { |
796 |
793 |
797 log = Log.instance(context); |
794 log = Log.instance(context); |
798 // Writer for -XprintRounds and -XprintProcessorInfo data |
|
799 PrintWriter xout = context.get(Log.outKey); |
|
800 TaskListener taskListener = context.get(TaskListener.class); |
795 TaskListener taskListener = context.get(TaskListener.class); |
801 |
796 |
802 JavaCompiler compiler = JavaCompiler.instance(context); |
797 JavaCompiler compiler = JavaCompiler.instance(context); |
803 compiler.todo.clear(); // free the compiler's resources |
798 compiler.todo.clear(); // free the compiler's resources |
804 |
799 |
837 break runAround; |
832 break runAround; |
838 } |
833 } |
839 |
834 |
840 this.context = currentContext; |
835 this.context = currentContext; |
841 roundNumber++; |
836 roundNumber++; |
842 printRoundInfo(xout, roundNumber, topLevelClasses, annotationsPresent, false); |
837 printRoundInfo(roundNumber, topLevelClasses, annotationsPresent, false); |
843 |
838 |
844 if (taskListener != null) |
839 if (taskListener != null) |
845 taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
840 taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
846 |
841 |
847 try { |
842 try { |
906 } |
901 } |
907 } else |
902 } else |
908 break runAround; // No new files |
903 break runAround; // No new files |
909 } |
904 } |
910 } |
905 } |
911 roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener); |
906 roots = runLastRound(roundNumber, errorStatus, compiler, roots, taskListener); |
912 // Set error status for any files compiled and generated in |
907 // Set error status for any files compiled and generated in |
913 // the last round |
908 // the last round |
914 if (log.unrecoverableError) |
909 if (log.unrecoverableError) |
915 errorStatus = true; |
910 errorStatus = true; |
916 |
911 |
980 |
975 |
981 return compiler.parseFiles(fileObjects); |
976 return compiler.parseFiles(fileObjects); |
982 } |
977 } |
983 |
978 |
984 // Call the last round of annotation processing |
979 // Call the last round of annotation processing |
985 private List<JCCompilationUnit> runLastRound(PrintWriter xout, |
980 private List<JCCompilationUnit> runLastRound(int roundNumber, |
986 int roundNumber, |
|
987 boolean errorStatus, |
981 boolean errorStatus, |
988 JavaCompiler compiler, |
982 JavaCompiler compiler, |
989 List<JCCompilationUnit> roots, |
983 List<JCCompilationUnit> roots, |
990 TaskListener taskListener) throws IOException { |
984 TaskListener taskListener) throws IOException { |
991 roundNumber++; |
985 roundNumber++; |
992 List<ClassSymbol> noTopLevelClasses = List.nil(); |
986 List<ClassSymbol> noTopLevelClasses = List.nil(); |
993 Set<TypeElement> noAnnotations = Collections.emptySet(); |
987 Set<TypeElement> noAnnotations = Collections.emptySet(); |
994 printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true); |
988 printRoundInfo(roundNumber, noTopLevelClasses, noAnnotations, true); |
995 |
989 |
996 Set<Element> emptyRootElements = Collections.emptySet(); // immutable |
990 Set<Element> emptyRootElements = Collections.emptySet(); // immutable |
997 RoundEnvironment renv = new JavacRoundEnvironment(true, |
991 RoundEnvironment renv = new JavacRoundEnvironment(true, |
998 errorStatus, |
992 errorStatus, |
999 emptyRootElements, |
993 emptyRootElements, |
1030 if (!unmatchedProcessorOptions.isEmpty()) { |
1024 if (!unmatchedProcessorOptions.isEmpty()) { |
1031 log.warning("proc.unmatched.processor.options", unmatchedProcessorOptions.toString()); |
1025 log.warning("proc.unmatched.processor.options", unmatchedProcessorOptions.toString()); |
1032 } |
1026 } |
1033 } |
1027 } |
1034 |
1028 |
1035 private void printRoundInfo(PrintWriter xout, |
1029 private void printRoundInfo(int roundNumber, |
1036 int roundNumber, |
|
1037 List<ClassSymbol> topLevelClasses, |
1030 List<ClassSymbol> topLevelClasses, |
1038 Set<TypeElement> annotationsPresent, |
1031 Set<TypeElement> annotationsPresent, |
1039 boolean lastRound) { |
1032 boolean lastRound) { |
1040 if (printRounds || verbose) { |
1033 if (printRounds || verbose) { |
1041 xout.println(Log.getLocalizedString("x.print.rounds", |
1034 log.printNoteLines("x.print.rounds", |
1042 roundNumber, |
1035 roundNumber, |
1043 "{" + topLevelClasses.toString(", ") + "}", |
1036 "{" + topLevelClasses.toString(", ") + "}", |
1044 annotationsPresent, |
1037 annotationsPresent, |
1045 lastRound)); |
1038 lastRound); |
1046 } |
1039 } |
1047 } |
1040 } |
1048 |
1041 |
1049 private List<ClassSymbol> enterNewClassFiles(Context currentContext) { |
1042 private List<ClassSymbol> enterNewClassFiles(Context currentContext) { |
1050 ClassReader reader = ClassReader.instance(currentContext); |
1043 ClassReader reader = ClassReader.instance(currentContext); |