public Enter enter() { return Enter.instance(context); }
Iterable<Type> tyargTypes) { Resolve resolve = Resolve.instance(state.context); Enter enter = Enter.instance(state.context); Log log = Log.instance(state.context); DeferredDiagnosticHandler handler = new DeferredDiagnosticHandler(log); return resolve.resolveInternalMethod( enter.getEnv(base), base.type, name,
/** Finds a declaration with the given name and type that is in scope at the current location. */ @Nullable public static Symbol findIdent(String name, VisitorState state, KindSelector kind) { ClassType enclosingClass = ASTHelpers.getType(state.findEnclosing(ClassTree.class)); if (enclosingClass == null || enclosingClass.tsym == null) { return null; } Env<AttrContext> env = Enter.instance(state.context).getClassEnv(enclosingClass.tsym); MethodTree enclosingMethod = state.findEnclosing(MethodTree.class); if (enclosingMethod != null) { env = MemberEnter.instance(state.context).getMethodEnv((JCMethodDecl) enclosingMethod, env); } try { Method method = Resolve.class.getDeclaredMethod("findIdent", Env.class, Name.class, KindSelector.class); method.setAccessible(true); Symbol result = (Symbol) method.invoke(Resolve.instance(state.context), env, state.getName(name), kind); return result.exists() ? result : null; } catch (ReflectiveOperationException e) { throw new LinkageError(e.getMessage(), e); } }
public void visitClassDef(JCClassDecl tree) { Symbol owner = env.info.scope.owner; Scope enclScope = enterScope(env); ClassSymbol c; if (owner.kind == PCK) { c = reader.enterClass(tree.name, packge); packge.members().enterIfAbsent(c); if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) { log.error(tree.pos(), "class.public.should.be.in.file", tree.name); duplicateClass(tree.pos(), c); result = new ErrorType(tree.name, (TypeSymbol)owner); tree.sym = (ClassSymbol)result.tsym; Env<AttrContext> localEnv = classEnv(tree, env); typeEnvs.put(c, localEnv); ct.typarams_field = classEnter(tree.typarams, localEnv); classEnter(tree.defs, localEnv);
public Env<AttrContext> getClassEnv(TypeSymbol sym) { Env<AttrContext> localEnv = getEnv(sym); Env<AttrContext> lintEnv = localEnv; while (lintEnv.info.lint == null) lintEnv = lintEnv.next; localEnv.info.lint = lintEnv.info.lint.augment(sym); return localEnv; }
case COMPILATION_UNIT: env = enter.getTopLevelEnv((JCCompilationUnit)tree); break; case CLASS: env = enter.getClassEnv(((JCClassDecl)tree).sym); break; case METHOD:
classEnter(trees, null); Env<AttrContext> env = typeEnvs.get(tree); if (env == null) env = topLevelEnv(tree); memberEnter.memberEnter(tree, env); log.useSource(prev);
/** Visitor method: enter classes of a list of trees, returning a list of types. */ <T extends JCTree> List<Type> classEnter(List<T> trees, Env<AttrContext> env) { ListBuffer<Type> ts = new ListBuffer<Type>(); for (List<T> l = trees; l.nonEmpty(); l = l.tail) { Type t = classEnter(l.head, env); if (t != null) ts.append(t); } return ts.toList(); }
public static Enter instance(Context context) { Enter instance = context.get(enterKey); if (instance == null) instance = new Enter(context); return instance; }
enter.getTopLevelEnv(TreeMaker.instance(inliner.getContext()).TopLevel(List.<JCTree>nil()));
public static void analyze(Iterable<? extends Element> elems, Context ctx) { assert elems != null; PostFlowAnalysis postFlowAnalysis = new PostFlowAnalysis(ctx); for (Element e : elems) { if (e instanceof TypeSymbol) { Env<AttrContext> env = postFlowAnalysis.enter.getClassEnv((TypeSymbol)e); if (env != null) { JavaFileObject prev = postFlowAnalysis.log.useSource(env.enclClass.sym.sourcefile != null ? env.enclClass.sym.sourcefile : env.toplevel.sourcefile); try { postFlowAnalysis.scan(env.toplevel); } finally { postFlowAnalysis.log.useSource(prev); } } } } }
/** Main method: enter all classes in a list of toplevel trees. * @param trees The list of trees to be processed. */ public void main(List<JCCompilationUnit> trees) { complete(trees, null); }
Env<AttrContext> cenv = enter.classEnv(cd, env); enter.typeEnvs.put(c, cenv);
public void visitClassDef(JCClassDecl tree) { Symbol owner = env.info.scope.owner; Scope enclScope = enterScope(env); ClassSymbol c; if (owner.kind == PCK) { c = reader.enterClass(tree.name, packge); packge.members().enterIfAbsent(c); if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) { log.error(tree.pos(), "class.public.should.be.in.file", tree.name); duplicateClass(tree.pos(), c); result = new ErrorType(tree.name, (TypeSymbol)owner); tree.sym = (ClassSymbol)result.tsym; Env<AttrContext> localEnv = classEnv(tree, env); typeEnvs.put(c, localEnv); ct.typarams_field = classEnter(tree.typarams, localEnv); classEnter(tree.defs, localEnv);
/** * Returns a symbol's enter environment, or null if it has none. */ private Env<AttrContext> getEnterEnv(Symbol sym) { // Get enclosing class of sym, or sym itself if it is a class // or package. TypeSymbol ts = (sym.kind != Kinds.PCK) ? sym.enclClass() : (PackageSymbol) sym; return (ts != null) ? enter.getEnv(ts) : null; }
case COMPILATION_UNIT: env = enter.getTopLevelEnv((JCCompilationUnit)tree); break; case CLASS: env = enter.getClassEnv(((JCClassDecl)tree).sym); break; case METHOD:
classEnter(trees, null); Env<AttrContext> env = typeEnvs.get(tree); if (env == null) env = topLevelEnv(tree); memberEnter.memberEnter(tree, env); log.useSource(prev);
/** Visitor method: enter classes of a list of trees, returning a list of types. */ <T extends JCTree> List<Type> classEnter(List<T> trees, Env<AttrContext> env) { ListBuffer<Type> ts = new ListBuffer<Type>(); for (List<T> l = trees; l.nonEmpty(); l = l.tail) ts.append(classEnter(l.head, env)); return ts.toList(); }