langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
changeset 8032 e1aa25ccdabb
parent 8031 d5fe2c1cecfc
child 8422 b2ac1acf3937
equal deleted inserted replaced
8031:d5fe2c1cecfc 8032:e1aa25ccdabb
    63 import com.sun.tools.javac.model.JavacTypes;
    63 import com.sun.tools.javac.model.JavacTypes;
    64 import com.sun.tools.javac.parser.*;
    64 import com.sun.tools.javac.parser.*;
    65 import com.sun.tools.javac.tree.*;
    65 import com.sun.tools.javac.tree.*;
    66 import com.sun.tools.javac.tree.JCTree.*;
    66 import com.sun.tools.javac.tree.JCTree.*;
    67 import com.sun.tools.javac.util.Abort;
    67 import com.sun.tools.javac.util.Abort;
       
    68 import com.sun.tools.javac.util.Assert;
    68 import com.sun.tools.javac.util.Context;
    69 import com.sun.tools.javac.util.Context;
    69 import com.sun.tools.javac.util.Convert;
    70 import com.sun.tools.javac.util.Convert;
    70 import com.sun.tools.javac.util.FatalError;
    71 import com.sun.tools.javac.util.FatalError;
    71 import com.sun.tools.javac.util.JCDiagnostic;
    72 import com.sun.tools.javac.util.JCDiagnostic;
    72 import com.sun.tools.javac.util.List;
    73 import com.sun.tools.javac.util.List;
  1044          */
  1045          */
  1045         private Context nextContext() {
  1046         private Context nextContext() {
  1046             Context next = new Context();
  1047             Context next = new Context();
  1047 
  1048 
  1048             Options options = Options.instance(context);
  1049             Options options = Options.instance(context);
  1049             assert options != null;
  1050             Assert.checkNonNull(options);
  1050             next.put(Options.optionsKey, options);
  1051             next.put(Options.optionsKey, options);
  1051 
  1052 
  1052             PrintWriter out = context.get(Log.outKey);
  1053             PrintWriter out = context.get(Log.outKey);
  1053             assert out != null;
  1054             Assert.checkNonNull(out);
  1054             next.put(Log.outKey, out);
  1055             next.put(Log.outKey, out);
  1055 
  1056 
  1056             final boolean shareNames = true;
  1057             final boolean shareNames = true;
  1057             if (shareNames) {
  1058             if (shareNames) {
  1058                 Names names = Names.instance(context);
  1059                 Names names = Names.instance(context);
  1059                 assert names != null;
  1060                 Assert.checkNonNull(names);
  1060                 next.put(Names.namesKey, names);
  1061                 next.put(Names.namesKey, names);
  1061             }
  1062             }
  1062 
  1063 
  1063             DiagnosticListener<?> dl = context.get(DiagnosticListener.class);
  1064             DiagnosticListener<?> dl = context.get(DiagnosticListener.class);
  1064             if (dl != null)
  1065             if (dl != null)
  1067             TaskListener tl = context.get(TaskListener.class);
  1068             TaskListener tl = context.get(TaskListener.class);
  1068             if (tl != null)
  1069             if (tl != null)
  1069                 next.put(TaskListener.class, tl);
  1070                 next.put(TaskListener.class, tl);
  1070 
  1071 
  1071             JavaFileManager jfm = context.get(JavaFileManager.class);
  1072             JavaFileManager jfm = context.get(JavaFileManager.class);
  1072             assert jfm != null;
  1073             Assert.checkNonNull(jfm);
  1073             next.put(JavaFileManager.class, jfm);
  1074             next.put(JavaFileManager.class, jfm);
  1074             if (jfm instanceof JavacFileManager) {
  1075             if (jfm instanceof JavacFileManager) {
  1075                 ((JavacFileManager)jfm).setContext(next);
  1076                 ((JavacFileManager)jfm).setContext(next);
  1076             }
  1077             }
  1077 
  1078 
  1078             Names names = Names.instance(context);
  1079             Names names = Names.instance(context);
  1079             assert names != null;
  1080             Assert.checkNonNull(names);
  1080             next.put(Names.namesKey, names);
  1081             next.put(Names.namesKey, names);
  1081 
  1082 
  1082             Keywords keywords = Keywords.instance(context);
  1083             Keywords keywords = Keywords.instance(context);
  1083             assert(keywords != null);
  1084             Assert.checkNonNull(keywords);
  1084             next.put(Keywords.keywordsKey, keywords);
  1085             next.put(Keywords.keywordsKey, keywords);
  1085 
  1086 
  1086             JavaCompiler oldCompiler = JavaCompiler.instance(context);
  1087             JavaCompiler oldCompiler = JavaCompiler.instance(context);
  1087             JavaCompiler nextCompiler = JavaCompiler.instance(next);
  1088             JavaCompiler nextCompiler = JavaCompiler.instance(next);
  1088             nextCompiler.initRound(oldCompiler);
  1089             nextCompiler.initRound(oldCompiler);
  1237         List<ClassSymbol> classes = List.nil();
  1238         List<ClassSymbol> classes = List.nil();
  1238         for (JCCompilationUnit unit : units) {
  1239         for (JCCompilationUnit unit : units) {
  1239             for (JCTree node : unit.defs) {
  1240             for (JCTree node : unit.defs) {
  1240                 if (node.getTag() == JCTree.CLASSDEF) {
  1241                 if (node.getTag() == JCTree.CLASSDEF) {
  1241                     ClassSymbol sym = ((JCClassDecl) node).sym;
  1242                     ClassSymbol sym = ((JCClassDecl) node).sym;
  1242                     assert sym != null;
  1243                     Assert.checkNonNull(sym);
  1243                     classes = classes.prepend(sym);
  1244                     classes = classes.prepend(sym);
  1244                 }
  1245                 }
  1245             }
  1246             }
  1246         }
  1247         }
  1247         return classes.reverse();
  1248         return classes.reverse();