langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
changeset 6924 ef7a9281ad2f
parent 6721 d92073844278
child 7072 4863847e93a5
equal deleted inserted replaced
6722:7a6305ae0721 6924:ef7a9281ad2f
   171         showResolveErrors = options.isSet("showResolveErrors");
   171         showResolveErrors = options.isSet("showResolveErrors");
   172         werror = options.isSet(WERROR);
   172         werror = options.isSet(WERROR);
   173         platformAnnotations = initPlatformAnnotations();
   173         platformAnnotations = initPlatformAnnotations();
   174         foundTypeProcessors = false;
   174         foundTypeProcessors = false;
   175 
   175 
   176         // Initialize services before any processors are initialzied
   176         // Initialize services before any processors are initialized
   177         // in case processors use them.
   177         // in case processors use them.
   178         filer = new JavacFiler(context);
   178         filer = new JavacFiler(context);
   179         messager = new JavacMessager(context, this);
   179         messager = new JavacMessager(context, this);
   180         elementUtils = new JavacElements(context);
   180         elementUtils = JavacElements.instance(context);
   181         typeUtils = new JavacTypes(context);
   181         typeUtils = JavacTypes.instance(context);
   182         processorOptions = initProcessorOptions(context);
   182         processorOptions = initProcessorOptions(context);
   183         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
   183         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
   184         messages = JavacMessages.instance(context);
   184         messages = JavacMessages.instance(context);
   185         initProcessorIterator(context, processors);
   185         initProcessorIterator(context, processors);
   186     }
   186     }
   863         private Round(Round prev,
   863         private Round(Round prev,
   864                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
   864                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
   865             this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
   865             this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
   866             this.genClassFiles = prev.genClassFiles;
   866             this.genClassFiles = prev.genClassFiles;
   867 
   867 
   868             updateProcessingState();
       
   869 
       
   870             List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
   868             List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
   871             roots = cleanTrees(prev.roots).appendList(parsedFiles);
   869             roots = cleanTrees(prev.roots).appendList(parsedFiles);
   872 
   870 
   873             // Check for errors after parsing
   871             // Check for errors after parsing
   874             if (unrecoverableError())
   872             if (unrecoverableError())
  1027                 kinds.remove(JCDiagnostic.Kind.ERROR);
  1025                 kinds.remove(JCDiagnostic.Kind.ERROR);
  1028             }
  1026             }
  1029             log.reportDeferredDiagnostics(kinds);
  1027             log.reportDeferredDiagnostics(kinds);
  1030         }
  1028         }
  1031 
  1029 
  1032         /** Update the processing state for the current context. */
       
  1033         private void updateProcessingState() {
       
  1034             filer.newRound(context);
       
  1035             messager.newRound(context);
       
  1036 
       
  1037             elementUtils.setContext(context);
       
  1038             typeUtils.setContext(context);
       
  1039         }
       
  1040 
       
  1041         /** Print info about this round. */
  1030         /** Print info about this round. */
  1042         private void printRoundInfo(boolean lastRound) {
  1031         private void printRoundInfo(boolean lastRound) {
  1043             if (printRounds || verbose) {
  1032             if (printRounds || verbose) {
  1044                 List<ClassSymbol> tlc = lastRound ? List.<ClassSymbol>nil() : topLevelClasses;
  1033                 List<ClassSymbol> tlc = lastRound ? List.<ClassSymbol>nil() : topLevelClasses;
  1045                 Set<TypeElement> ap = lastRound ? Collections.<TypeElement>emptySet() : annotationsPresent;
  1034                 Set<TypeElement> ap = lastRound ? Collections.<TypeElement>emptySet() : annotationsPresent;
  1097             next.put(Keywords.keywordsKey, keywords);
  1086             next.put(Keywords.keywordsKey, keywords);
  1098 
  1087 
  1099             JavaCompiler oldCompiler = JavaCompiler.instance(context);
  1088             JavaCompiler oldCompiler = JavaCompiler.instance(context);
  1100             JavaCompiler nextCompiler = JavaCompiler.instance(next);
  1089             JavaCompiler nextCompiler = JavaCompiler.instance(next);
  1101             nextCompiler.initRound(oldCompiler);
  1090             nextCompiler.initRound(oldCompiler);
       
  1091 
       
  1092             filer.newRound(next);
       
  1093             messager.newRound(next);
       
  1094             elementUtils.setContext(next);
       
  1095             typeUtils.setContext(next);
  1102 
  1096 
  1103             JavacTaskImpl task = context.get(JavacTaskImpl.class);
  1097             JavacTaskImpl task = context.get(JavacTaskImpl.class);
  1104             if (task != null) {
  1098             if (task != null) {
  1105                 next.put(JavacTaskImpl.class, task);
  1099                 next.put(JavacTaskImpl.class, task);
  1106                 task.updateContext(next);
  1100                 task.updateContext(next);