private static Context preRegister(Context context) {
    Bark.preRegister(context);

    if (context.get(JavaFileManager.class) == null) JavacFileManager.preRegister(context);

    return context;
  }
  /** Construct a new compiler from a shared context. */
  public AptJavaCompiler(Context context) {
    super(preRegister(context));

    context.put(compilerKey, this);
    apt = Apt.instance(context);

    ClassReader classReader = ClassReader.instance(context);
    classReader.preferSource = true;

    // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
    // original identities, to remember the original intent.
    log = Log.instance(context);
    bark = Bark.instance(context);

    Options options = Options.instance(context);
    classOutput = options.get("-retrofit") == null;
    nocompile = options.get("-nocompile") != null;
    print = options.get("-print") != null;
    classesAsDecls = options.get("-XclassesAsDecls") != null;

    genSourceFileNames = new java.util.LinkedHashSet<String>();
    genClassFileNames = new java.util.LinkedHashSet<String>();

    // this forces a copy of the line map to be kept in the tree,
    // for use by com.sun.mirror.util.SourcePosition.
    lineDebugInfo = true;
  }
示例#3
0
  protected Enter(Context context) {
    context.put(enterKey, this);

    log = Log.instance(context);
    reader = ClassReader.instance(context);
    make = TreeMaker.instance(context);
    syms = Symtab.instance(context);
    chk = Check.instance(context);
    memberEnter = MemberEnter.instance(context);
    types = Types.instance(context);
    annotate = Annotate.instance(context);
    lint = Lint.instance(context);

    predefClassDef =
        make.ClassDef(make.Modifiers(PUBLIC), syms.predefClass.name, null, null, null, null);
    predefClassDef.sym = syms.predefClass;
    todo = Todo.instance(context);
    fileManager = context.get(JavaFileManager.class);
  }
 protected Annotate(Context context) {
   context.put(annotateKey, this);
   attr = Attr.instance(context);
   make = TreeMaker.instance(context);
   log = Log.instance(context);
   syms = Symtab.instance(context);
   names = Names.instance(context);
   rs = Resolve.instance(context);
   types = Types.instance(context);
   cfolder = ConstFold.instance(context);
   chk = Check.instance(context);
 }
 /** Get the JavaCompiler instance for this context. */
 public static AptJavaCompiler instance(Context context) {
   AptJavaCompiler instance = context.get(compilerKey);
   if (instance == null) instance = new AptJavaCompiler(context);
   return instance;
 }
示例#6
0
 public static Enter instance(Context context) {
   Enter instance = context.get(enterKey);
   if (instance == null) instance = new Enter(context);
   return instance;
 }
 public static Annotate instance(Context context) {
   Annotate instance = context.get(annotateKey);
   if (instance == null) instance = new Annotate(context);
   return instance;
 }
示例#8
0
 /**
  * Use a new context. May be called from outside to update internal state for a new
  * annotation-processing round.
  */
 public void setContext(Context context) {
   context.put(JavacTypes.class, this);
   syms = Symtab.instance(context);
   types = Types.instance(context);
 }
示例#9
0
 public static JavacTypes instance(Context context) {
   JavacTypes instance = context.get(JavacTypes.class);
   if (instance == null) instance = new JavacTypes(context);
   return instance;
 }
 /** Get the DiagnosticFormatter instance for this context. */
 public static RichDiagnosticFormatter instance(Context context) {
   RichDiagnosticFormatter instance = context.get(RichDiagnosticFormatter.class);
   if (instance == null) instance = new RichDiagnosticFormatter(context);
   return instance;
 }