src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
equal
deleted
inserted
replaced
50 import static javax.tools.StandardLocation.*; |
50 import static javax.tools.StandardLocation.*; |
51 |
51 |
52 import com.sun.source.util.TaskEvent; |
52 import com.sun.source.util.TaskEvent; |
53 import com.sun.tools.javac.api.MultiTaskListener; |
53 import com.sun.tools.javac.api.MultiTaskListener; |
54 import com.sun.tools.javac.code.*; |
54 import com.sun.tools.javac.code.*; |
|
55 import com.sun.tools.javac.code.DeferredCompletionFailureHandler.Handler; |
55 import com.sun.tools.javac.code.Scope.WriteableScope; |
56 import com.sun.tools.javac.code.Scope.WriteableScope; |
56 import com.sun.tools.javac.code.Source.Feature; |
57 import com.sun.tools.javac.code.Source.Feature; |
57 import com.sun.tools.javac.code.Symbol.*; |
58 import com.sun.tools.javac.code.Symbol.*; |
58 import com.sun.tools.javac.code.Type.ClassType; |
59 import com.sun.tools.javac.code.Type.ClassType; |
59 import com.sun.tools.javac.code.Types; |
60 import com.sun.tools.javac.code.Types; |
175 */ |
176 */ |
176 private JavacMessages messages; |
177 private JavacMessages messages; |
177 |
178 |
178 private MultiTaskListener taskListener; |
179 private MultiTaskListener taskListener; |
179 private final Symtab symtab; |
180 private final Symtab symtab; |
|
181 private final DeferredCompletionFailureHandler dcfh; |
180 private final Names names; |
182 private final Names names; |
181 private final Enter enter; |
183 private final Enter enter; |
182 private final Completer initialCompleter; |
184 private final Completer initialCompleter; |
183 private final Check chk; |
185 private final Check chk; |
184 |
186 |
225 processorOptions = initProcessorOptions(); |
227 processorOptions = initProcessorOptions(); |
226 unmatchedProcessorOptions = initUnmatchedProcessorOptions(); |
228 unmatchedProcessorOptions = initUnmatchedProcessorOptions(); |
227 messages = JavacMessages.instance(context); |
229 messages = JavacMessages.instance(context); |
228 taskListener = MultiTaskListener.instance(context); |
230 taskListener = MultiTaskListener.instance(context); |
229 symtab = Symtab.instance(context); |
231 symtab = Symtab.instance(context); |
|
232 dcfh = DeferredCompletionFailureHandler.instance(context); |
230 names = Names.instance(context); |
233 names = Names.instance(context); |
231 enter = Enter.instance(context); |
234 enter = Enter.instance(context); |
232 initialCompleter = ClassFinder.instance(context).getCompleter(); |
235 initialCompleter = ClassFinder.instance(context).getCompleter(); |
233 chk = Check.instance(context); |
236 chk = Check.instance(context); |
234 initProcessorLoader(); |
237 initProcessorLoader(); |
663 public Processor processor; |
666 public Processor processor; |
664 public boolean contributed; |
667 public boolean contributed; |
665 private ArrayList<Pattern> supportedAnnotationPatterns; |
668 private ArrayList<Pattern> supportedAnnotationPatterns; |
666 private ArrayList<String> supportedOptionNames; |
669 private ArrayList<String> supportedOptionNames; |
667 |
670 |
668 ProcessorState(Processor p, Log log, Source source, boolean allowModules, ProcessingEnvironment env) { |
671 ProcessorState(Processor p, Log log, Source source, DeferredCompletionFailureHandler dcfh, |
|
672 boolean allowModules, ProcessingEnvironment env) { |
669 processor = p; |
673 processor = p; |
670 contributed = false; |
674 contributed = false; |
671 |
675 |
|
676 Handler prevDeferredHandler = dcfh.setHandler(dcfh.userCodeHandler); |
672 try { |
677 try { |
673 processor.init(env); |
678 processor.init(env); |
674 |
679 |
675 checkSourceVersionCompatibility(source, log); |
680 checkSourceVersionCompatibility(source, log); |
676 |
681 |
690 |
695 |
691 } catch (ClientCodeException e) { |
696 } catch (ClientCodeException e) { |
692 throw e; |
697 throw e; |
693 } catch (Throwable t) { |
698 } catch (Throwable t) { |
694 throw new AnnotationProcessingError(t); |
699 throw new AnnotationProcessingError(t); |
|
700 } finally { |
|
701 dcfh.setHandler(prevDeferredHandler); |
695 } |
702 } |
696 } |
703 } |
697 |
704 |
698 /** |
705 /** |
699 * Checks whether or not a processor's source version is |
706 * Checks whether or not a processor's source version is |
765 onProcInterator = true; |
772 onProcInterator = true; |
766 } |
773 } |
767 |
774 |
768 if (psi.processorIterator.hasNext()) { |
775 if (psi.processorIterator.hasNext()) { |
769 ProcessorState ps = new ProcessorState(psi.processorIterator.next(), |
776 ProcessorState ps = new ProcessorState(psi.processorIterator.next(), |
770 log, source, Feature.MODULES.allowedInSource(source), |
777 log, source, dcfh, |
|
778 Feature.MODULES.allowedInSource(source), |
771 JavacProcessingEnvironment.this); |
779 JavacProcessingEnvironment.this); |
772 psi.procStateList.add(ps); |
780 psi.procStateList.add(ps); |
773 return ps; |
781 return ps; |
774 } else |
782 } else |
775 throw new NoSuchElementException(); |
783 throw new NoSuchElementException(); |
957 } |
965 } |
958 |
966 |
959 private boolean callProcessor(Processor proc, |
967 private boolean callProcessor(Processor proc, |
960 Set<? extends TypeElement> tes, |
968 Set<? extends TypeElement> tes, |
961 RoundEnvironment renv) { |
969 RoundEnvironment renv) { |
|
970 Handler prevDeferredHandler = dcfh.setHandler(dcfh.userCodeHandler); |
962 try { |
971 try { |
963 return proc.process(tes, renv); |
972 return proc.process(tes, renv); |
964 } catch (ClassFinder.BadClassFile ex) { |
973 } catch (ClassFinder.BadClassFile ex) { |
965 log.error(Errors.ProcCantAccess1(ex.sym, ex.getDetailValue())); |
974 log.error(Errors.ProcCantAccess1(ex.sym, ex.getDetailValue())); |
966 return false; |
975 return false; |
971 return false; |
980 return false; |
972 } catch (ClientCodeException e) { |
981 } catch (ClientCodeException e) { |
973 throw e; |
982 throw e; |
974 } catch (Throwable t) { |
983 } catch (Throwable t) { |
975 throw new AnnotationProcessingError(t); |
984 throw new AnnotationProcessingError(t); |
|
985 } finally { |
|
986 dcfh.setHandler(prevDeferredHandler); |
976 } |
987 } |
977 } |
988 } |
978 |
989 |
979 /** |
990 /** |
980 * Helper object for a single round of annotation processing. |
991 * Helper object for a single round of annotation processing. |