Beispiel #1
0
  /**
   * Main method: enter one class from a list of toplevel trees and place the rest on uncompleted
   * for later processing.
   *
   * @param trees The list of trees to be processed.
   * @param c The class symbol to be processed.
   */
  public void complete(List<JCCompilationUnit> trees, ClassSymbol c) {
    annotate.enterStart();
    ListBuffer<ClassSymbol> prevUncompleted = uncompleted;
    if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>();

    try {
      // enter all classes, and construct uncompleted list
      classEnter(trees, null);

      // complete all uncompleted classes in memberEnter
      if (memberEnter.completionEnabled) {
        while (uncompleted.nonEmpty()) {
          ClassSymbol clazz = uncompleted.next();
          if (c == null || c == clazz || prevUncompleted == null) clazz.complete();
          else
            // defer
            prevUncompleted.append(clazz);
        }

        // if there remain any unimported toplevels (these must have
        // no classes at all), process their import statements as well.
        for (JCCompilationUnit tree : trees) {
          if (tree.starImportScope.elems == null) {
            JavaFileObject prev = log.useSource(tree.sourcefile);
            Env<AttrContext> topEnv = topLevelEnv(tree);
            memberEnter.memberEnter(tree, topEnv);
            log.useSource(prev);
          }
        }
      }
    } finally {
      uncompleted = prevUncompleted;
      annotate.enterDone();
    }
  }
    protected Enter(Context context) {
		DEBUG.P(this,"Enter(1)");
		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);
		annotate = Annotate.instance(context);
		lint = Lint.instance(context);

		predefClassDef = make.ClassDef(
			make.Modifiers(PUBLIC),
			syms.predefClass.name, null, null, null, null);
		//predefClass是一个ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage)
		//且它的Scope members_field已有成员(几个基本类型符号(symbols for basic types)及其他操作符)
		//请参考Systab类的predefClass字段说明
		predefClassDef.sym = syms.predefClass;

		todo = Todo.instance(context);
		fileManager = context.get(JavaFileManager.class);
		
		names = Name.Table.instance(context);    //我加上的
		DEBUG.P(0,this,"Enter(1)");
    }
Beispiel #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);
  }