< prev index next >

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

Print this page




 790          */
 791         public void removeSupportedOptions(Set<String> unmatchedProcessorOptions) {
 792             unmatchedProcessorOptions.removeAll(supportedOptionNames);
 793         }
 794     }
 795 
 796     // TODO: These two classes can probably be rewritten better...
 797     /**
 798      * This class holds information about the processors that have
 799      * been discovered so far as well as the means to discover more, if
 800      * necessary.  A single iterator should be used per round of
 801      * annotation processing.  The iterator first visits already
 802      * discovered processors then fails over to the service provider
 803      * mechanism if additional queries are made.
 804      */
 805     class DiscoveredProcessors implements Iterable<ProcessorState> {
 806 
 807         class ProcessorStateIterator implements Iterator<ProcessorState> {
 808             DiscoveredProcessors psi;
 809             Iterator<ProcessorState> innerIter;
 810             boolean onProcInterator;
 811 
 812             ProcessorStateIterator(DiscoveredProcessors psi) {
 813                 this.psi = psi;
 814                 this.innerIter = psi.procStateList.iterator();
 815                 this.onProcInterator = false;
 816             }
 817 
 818             public ProcessorState next() {
 819                 if (!onProcInterator) {
 820                     if (innerIter.hasNext())
 821                         return innerIter.next();
 822                     else
 823                         onProcInterator = true;
 824                 }
 825 
 826                 if (psi.processorIterator.hasNext()) {
 827                     ProcessorState ps = new ProcessorState(psi.processorIterator.next(),
 828                                                            log, source, dcfh,
 829                                                            Feature.MODULES.allowedInSource(source),
 830                                                            JavacProcessingEnvironment.this,
 831                                                            lint);
 832                     psi.procStateList.add(ps);
 833                     return ps;
 834                 } else
 835                     throw new NoSuchElementException();
 836             }
 837 
 838             public boolean hasNext() {
 839                 if (onProcInterator)
 840                     return  psi.processorIterator.hasNext();
 841                 else
 842                     return innerIter.hasNext() || psi.processorIterator.hasNext();
 843             }
 844 
 845             public void remove () {
 846                 throw new UnsupportedOperationException();
 847             }
 848 
 849             /**
 850              * Run all remaining processors on the procStateList that
 851              * have not already run this round with an empty set of
 852              * annotations.
 853              */
 854             public void runContributingProcs(RoundEnvironment re) {
 855                 if (!onProcInterator) {
 856                     Set<TypeElement> emptyTypeElements = Collections.emptySet();
 857                     while(innerIter.hasNext()) {
 858                         ProcessorState ps = innerIter.next();
 859                         if (ps.contributed)
 860                             callProcessor(ps.processor, emptyTypeElements, re);
 861                     }
 862                 }
 863             }
 864         }
 865 
 866         Iterator<? extends Processor> processorIterator;
 867         ArrayList<ProcessorState>  procStateList;
 868 
 869         public ProcessorStateIterator iterator() {
 870             return new ProcessorStateIterator(this);
 871         }
 872 
 873         DiscoveredProcessors(Iterator<? extends Processor> processorIterator) {
 874             this.processorIterator = processorIterator;
 875             this.procStateList = new ArrayList<>();


1144             packageInfoFiles = join(
1145                     getPackageInfoFiles(parsedFiles),
1146                     getPackageInfoFilesFromClasses(newClasses));
1147 
1148             moduleInfoFiles = List.nil(); //module-info cannot be generated
1149 
1150             findAnnotationsPresent();
1151         }
1152 
1153         /** Create the next round to be used. */
1154         Round next(Set<JavaFileObject> newSourceFiles, Map<ModuleSymbol, Map<String, JavaFileObject>> newClassFiles) {
1155             return new Round(this, newSourceFiles, newClassFiles);
1156         }
1157 
1158         /** Prepare the compiler for the final compilation. */
1159         void finalCompiler() {
1160             newRound();
1161         }
1162 
1163         /** Return the number of errors found so far in this round.
1164          * This may include uncoverable errors, such as parse errors,
1165          * and transient errors, such as missing symbols. */
1166         int errorCount() {
1167             return compiler.errorCount();
1168         }
1169 
1170         /** Return the number of warnings found so far in this round. */
1171         int warningCount() {
1172             return compiler.warningCount();
1173         }
1174 
1175         /** Return whether or not an unrecoverable error has occurred. */
1176         boolean unrecoverableError() {
1177             if (messager.errorRaised())
1178                 return true;
1179 
1180             for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
1181                 switch (d.getKind()) {
1182                     case WARNING:
1183                         if (werror)
1184                             return true;




 790          */
 791         public void removeSupportedOptions(Set<String> unmatchedProcessorOptions) {
 792             unmatchedProcessorOptions.removeAll(supportedOptionNames);
 793         }
 794     }
 795 
 796     // TODO: These two classes can probably be rewritten better...
 797     /**
 798      * This class holds information about the processors that have
 799      * been discovered so far as well as the means to discover more, if
 800      * necessary.  A single iterator should be used per round of
 801      * annotation processing.  The iterator first visits already
 802      * discovered processors then fails over to the service provider
 803      * mechanism if additional queries are made.
 804      */
 805     class DiscoveredProcessors implements Iterable<ProcessorState> {
 806 
 807         class ProcessorStateIterator implements Iterator<ProcessorState> {
 808             DiscoveredProcessors psi;
 809             Iterator<ProcessorState> innerIter;
 810             boolean onProcIterator;
 811 
 812             ProcessorStateIterator(DiscoveredProcessors psi) {
 813                 this.psi = psi;
 814                 this.innerIter = psi.procStateList.iterator();
 815                 this.onProcIterator = false;
 816             }
 817 
 818             public ProcessorState next() {
 819                 if (!onProcIterator) {
 820                     if (innerIter.hasNext())
 821                         return innerIter.next();
 822                     else
 823                         onProcIterator = true;
 824                 }
 825 
 826                 if (psi.processorIterator.hasNext()) {
 827                     ProcessorState ps = new ProcessorState(psi.processorIterator.next(),
 828                                                            log, source, dcfh,
 829                                                            Feature.MODULES.allowedInSource(source),
 830                                                            JavacProcessingEnvironment.this,
 831                                                            lint);
 832                     psi.procStateList.add(ps);
 833                     return ps;
 834                 } else
 835                     throw new NoSuchElementException();
 836             }
 837 
 838             public boolean hasNext() {
 839                 if (onProcIterator)
 840                     return  psi.processorIterator.hasNext();
 841                 else
 842                     return innerIter.hasNext() || psi.processorIterator.hasNext();
 843             }
 844 
 845             public void remove () {
 846                 throw new UnsupportedOperationException();
 847             }
 848 
 849             /**
 850              * Run all remaining processors on the procStateList that
 851              * have not already run this round with an empty set of
 852              * annotations.
 853              */
 854             public void runContributingProcs(RoundEnvironment re) {
 855                 if (!onProcIterator) {
 856                     Set<TypeElement> emptyTypeElements = Collections.emptySet();
 857                     while(innerIter.hasNext()) {
 858                         ProcessorState ps = innerIter.next();
 859                         if (ps.contributed)
 860                             callProcessor(ps.processor, emptyTypeElements, re);
 861                     }
 862                 }
 863             }
 864         }
 865 
 866         Iterator<? extends Processor> processorIterator;
 867         ArrayList<ProcessorState>  procStateList;
 868 
 869         public ProcessorStateIterator iterator() {
 870             return new ProcessorStateIterator(this);
 871         }
 872 
 873         DiscoveredProcessors(Iterator<? extends Processor> processorIterator) {
 874             this.processorIterator = processorIterator;
 875             this.procStateList = new ArrayList<>();


1144             packageInfoFiles = join(
1145                     getPackageInfoFiles(parsedFiles),
1146                     getPackageInfoFilesFromClasses(newClasses));
1147 
1148             moduleInfoFiles = List.nil(); //module-info cannot be generated
1149 
1150             findAnnotationsPresent();
1151         }
1152 
1153         /** Create the next round to be used. */
1154         Round next(Set<JavaFileObject> newSourceFiles, Map<ModuleSymbol, Map<String, JavaFileObject>> newClassFiles) {
1155             return new Round(this, newSourceFiles, newClassFiles);
1156         }
1157 
1158         /** Prepare the compiler for the final compilation. */
1159         void finalCompiler() {
1160             newRound();
1161         }
1162 
1163         /** Return the number of errors found so far in this round.
1164          * This may include unrecoverable errors, such as parse errors,
1165          * and transient errors, such as missing symbols. */
1166         int errorCount() {
1167             return compiler.errorCount();
1168         }
1169 
1170         /** Return the number of warnings found so far in this round. */
1171         int warningCount() {
1172             return compiler.warningCount();
1173         }
1174 
1175         /** Return whether or not an unrecoverable error has occurred. */
1176         boolean unrecoverableError() {
1177             if (messager.errorRaised())
1178                 return true;
1179 
1180             for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
1181                 switch (d.getKind()) {
1182                     case WARNING:
1183                         if (werror)
1184                             return true;


< prev index next >