langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
equal
deleted
inserted
replaced
872 compiler.close(false); |
872 compiler.close(false); |
873 currentContext = contextForNextRound(currentContext, true); |
873 currentContext = contextForNextRound(currentContext, true); |
874 |
874 |
875 JavaFileManager fileManager = currentContext.get(JavaFileManager.class); |
875 JavaFileManager fileManager = currentContext.get(JavaFileManager.class); |
876 |
876 |
877 List<JavaFileObject> fileObjects = List.nil(); |
|
878 for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) { |
|
879 fileObjects = fileObjects.prepend(jfo); |
|
880 } |
|
881 |
|
882 |
|
883 compiler = JavaCompiler.instance(currentContext); |
877 compiler = JavaCompiler.instance(currentContext); |
884 List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects); |
878 List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler); |
885 roots = cleanTrees(roots).reverse(); |
879 roots = cleanTrees(roots).appendList(parsedFiles); |
886 |
|
887 |
|
888 for (JCCompilationUnit unit : parsedFiles) |
|
889 roots = roots.prepend(unit); |
|
890 roots = roots.reverse(); |
|
891 |
880 |
892 // Check for errors after parsing |
881 // Check for errors after parsing |
893 if (compiler.parseErrors()) { |
882 if (compiler.parseErrors()) { |
894 errorStatus = true; |
883 errorStatus = true; |
895 break runAround; |
884 break runAround; |
919 } |
908 } |
920 } else |
909 } else |
921 break runAround; // No new files |
910 break runAround; // No new files |
922 } |
911 } |
923 } |
912 } |
924 runLastRound(xout, roundNumber, errorStatus, taskListener); |
913 roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener); |
|
914 // Set error status for any files compiled and generated in |
|
915 // the last round |
|
916 if (compiler.parseErrors()) |
|
917 errorStatus = true; |
925 |
918 |
926 compiler.close(false); |
919 compiler.close(false); |
927 currentContext = contextForNextRound(currentContext, true); |
920 currentContext = contextForNextRound(currentContext, true); |
928 compiler = JavaCompiler.instance(currentContext); |
921 compiler = JavaCompiler.instance(currentContext); |
|
922 |
929 filer.newRound(currentContext, true); |
923 filer.newRound(currentContext, true); |
930 filer.warnIfUnclosedFiles(); |
924 filer.warnIfUnclosedFiles(); |
931 warnIfUnmatchedOptions(); |
925 warnIfUnmatchedOptions(); |
932 |
926 |
933 /* |
927 /* |
977 } |
971 } |
978 |
972 |
979 return compiler; |
973 return compiler; |
980 } |
974 } |
981 |
975 |
|
976 private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler) |
|
977 throws IOException { |
|
978 List<JavaFileObject> fileObjects = List.nil(); |
|
979 for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) { |
|
980 fileObjects = fileObjects.prepend(jfo); |
|
981 } |
|
982 |
|
983 return compiler.parseFiles(fileObjects); |
|
984 } |
|
985 |
982 // Call the last round of annotation processing |
986 // Call the last round of annotation processing |
983 private void runLastRound(PrintWriter xout, |
987 private List<JCCompilationUnit> runLastRound(PrintWriter xout, |
984 int roundNumber, |
988 int roundNumber, |
985 boolean errorStatus, |
989 boolean errorStatus, |
|
990 JavaCompiler compiler, |
|
991 List<JCCompilationUnit> roots, |
986 TaskListener taskListener) throws IOException { |
992 TaskListener taskListener) throws IOException { |
987 roundNumber++; |
993 roundNumber++; |
988 List<ClassSymbol> noTopLevelClasses = List.nil(); |
994 List<ClassSymbol> noTopLevelClasses = List.nil(); |
989 Set<TypeElement> noAnnotations = Collections.emptySet(); |
995 Set<TypeElement> noAnnotations = Collections.emptySet(); |
990 printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true); |
996 printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true); |
1001 discoveredProcs.iterator().runContributingProcs(renv); |
1007 discoveredProcs.iterator().runContributingProcs(renv); |
1002 } finally { |
1008 } finally { |
1003 if (taskListener != null) |
1009 if (taskListener != null) |
1004 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
1010 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
1005 } |
1011 } |
|
1012 |
|
1013 // Add any sources generated during the last round to the set |
|
1014 // of files to be compiled. |
|
1015 if (moreToDo()) { |
|
1016 List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler); |
|
1017 roots = cleanTrees(roots).appendList(parsedFiles); |
|
1018 } |
|
1019 |
|
1020 return roots; |
1006 } |
1021 } |
1007 |
1022 |
1008 private void updateProcessingState(Context currentContext, boolean lastRound) { |
1023 private void updateProcessingState(Context currentContext, boolean lastRound) { |
1009 filer.newRound(currentContext, lastRound); |
1024 filer.newRound(currentContext, lastRound); |
1010 messager.newRound(currentContext); |
1025 messager.newRound(currentContext); |