33 import java.net.MalformedURLException; |
33 import java.net.MalformedURLException; |
34 import java.net.URL; |
34 import java.net.URL; |
35 import java.nio.file.Path; |
35 import java.nio.file.Path; |
36 import java.util.*; |
36 import java.util.*; |
37 import java.util.Map.Entry; |
37 import java.util.Map.Entry; |
|
38 import java.util.function.Predicate; |
38 import java.util.regex.*; |
39 import java.util.regex.*; |
39 import java.util.stream.Collectors; |
40 import java.util.stream.Collectors; |
40 |
41 |
41 import javax.annotation.processing.*; |
42 import javax.annotation.processing.*; |
42 import javax.lang.model.SourceVersion; |
43 import javax.lang.model.SourceVersion; |
81 import com.sun.tools.javac.util.Convert; |
82 import com.sun.tools.javac.util.Convert; |
82 import com.sun.tools.javac.util.DefinedBy; |
83 import com.sun.tools.javac.util.DefinedBy; |
83 import com.sun.tools.javac.util.DefinedBy.Api; |
84 import com.sun.tools.javac.util.DefinedBy.Api; |
84 import com.sun.tools.javac.util.Iterators; |
85 import com.sun.tools.javac.util.Iterators; |
85 import com.sun.tools.javac.util.JCDiagnostic; |
86 import com.sun.tools.javac.util.JCDiagnostic; |
|
87 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; |
86 import com.sun.tools.javac.util.JavacMessages; |
88 import com.sun.tools.javac.util.JavacMessages; |
87 import com.sun.tools.javac.util.List; |
89 import com.sun.tools.javac.util.List; |
88 import com.sun.tools.javac.util.Log; |
90 import com.sun.tools.javac.util.Log; |
89 import com.sun.tools.javac.util.MatchingUtils; |
91 import com.sun.tools.javac.util.MatchingUtils; |
90 import com.sun.tools.javac.util.ModuleHelper; |
92 import com.sun.tools.javac.util.ModuleHelper; |
1064 Set<JavaFileObject> newSourceFiles, Map<ModuleSymbol, Map<String,JavaFileObject>> newClassFiles) { |
1066 Set<JavaFileObject> newSourceFiles, Map<ModuleSymbol, Map<String,JavaFileObject>> newClassFiles) { |
1065 this(prev.number+1, prev.treesToClean, null); |
1067 this(prev.number+1, prev.treesToClean, null); |
1066 prev.newRound(); |
1068 prev.newRound(); |
1067 this.genClassFiles = prev.genClassFiles; |
1069 this.genClassFiles = prev.genClassFiles; |
1068 |
1070 |
1069 List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles); |
1071 //parse the generated files even despite errors reported so far, to eliminate |
|
1072 //recoverable errors related to the type declared in the generated files: |
|
1073 List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles, true); |
1070 roots = prev.roots.appendList(parsedFiles); |
1074 roots = prev.roots.appendList(parsedFiles); |
1071 |
1075 |
1072 // Check for errors after parsing |
1076 // Check for errors after parsing |
1073 if (unrecoverableError()) { |
1077 if (unrecoverableError()) { |
1074 compiler.initModules(List.nil()); |
1078 compiler.initModules(List.nil()); |
1231 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
1235 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); |
1232 } |
1236 } |
1233 } |
1237 } |
1234 |
1238 |
1235 void showDiagnostics(boolean showAll) { |
1239 void showDiagnostics(boolean showAll) { |
1236 Set<JCDiagnostic.Kind> kinds = EnumSet.allOf(JCDiagnostic.Kind.class); |
1240 deferredDiagnosticHandler.reportDeferredDiagnostics(showAll ? ACCEPT_ALL |
1237 if (!showAll) { |
1241 : ACCEPT_NON_RECOVERABLE); |
1238 // suppress errors, which are all presumed to be transient resolve errors |
|
1239 kinds.remove(JCDiagnostic.Kind.ERROR); |
|
1240 } |
|
1241 deferredDiagnosticHandler.reportDeferredDiagnostics(kinds); |
|
1242 log.popDiagnosticHandler(deferredDiagnosticHandler); |
1242 log.popDiagnosticHandler(deferredDiagnosticHandler); |
1243 compiler.setDeferredDiagnosticHandler(null); |
1243 compiler.setDeferredDiagnosticHandler(null); |
1244 } |
1244 } |
|
1245 //where: |
|
1246 private final Predicate<JCDiagnostic> ACCEPT_NON_RECOVERABLE = |
|
1247 d -> d.getKind() != JCDiagnostic.Kind.ERROR || |
|
1248 !d.isFlagSet(DiagnosticFlag.RECOVERABLE) || |
|
1249 d.isFlagSet(DiagnosticFlag.API); |
|
1250 private final Predicate<JCDiagnostic> ACCEPT_ALL = d -> true; |
1245 |
1251 |
1246 /** Print info about this round. */ |
1252 /** Print info about this round. */ |
1247 private void printRoundInfo(boolean lastRound) { |
1253 private void printRoundInfo(boolean lastRound) { |
1248 if (printRounds || verbose) { |
1254 if (printRounds || verbose) { |
1249 List<ClassSymbol> tlc = lastRound ? List.nil() : topLevelClasses; |
1255 List<ClassSymbol> tlc = lastRound ? List.nil() : topLevelClasses; |
1333 // Processors for round n have run to completion. |
1339 // Processors for round n have run to completion. |
1334 // Check for errors and whether there is more work to do. |
1340 // Check for errors and whether there is more work to do. |
1335 errorStatus = round.unrecoverableError(); |
1341 errorStatus = round.unrecoverableError(); |
1336 moreToDo = moreToDo(); |
1342 moreToDo = moreToDo(); |
1337 |
1343 |
1338 round.showDiagnostics(errorStatus || showResolveErrors); |
1344 round.showDiagnostics(showResolveErrors); |
1339 |
1345 |
1340 // Set up next round. |
1346 // Set up next round. |
1341 // Copy mutable collections returned from filer. |
1347 // Copy mutable collections returned from filer. |
1342 round = round.next( |
1348 round = round.next( |
1343 new LinkedHashSet<>(filer.getGeneratedSourceFileObjects()), |
1349 new LinkedHashSet<>(filer.getGeneratedSourceFileObjects()), |