public Iterable<Symbol> getLocalElements() { if (scope == null) return List.nil(); return scope.getElements(); }
.addOnConnectionFailedListener(this) .addApi(Plus.API, Plus.PlusOptions.builder().build()) .addScope(new Scope("email"));
/** Enter type variables of this classtype and all enclosing ones in * `typevars'. */ protected void enterTypevars(Type t) { if (t.getEnclosingType() != null && t.getEnclosingType().tag == CLASS) enterTypevars(t.getEnclosingType()); for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail) typevars.enter(xs.head.tsym); }
@Override protected Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) { Scope sc = new Scope(syms.arrayClass); MethodSymbol arrayConstr = new MethodSymbol(PUBLIC, name, null, site.tsym); arrayConstr.type = new MethodType(List.<Type>of(syms.intType), site, List.<Type>nil(), syms.methodClass); sc.enter(arrayConstr); return findMethodInScope(env, site, name, argtypes, typeargtypes, sc, methodNotFound, phase.isBoxingRequired(), phase.isVarargsRequired(), false, false); }
for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail) localEnv.info.scope.enterIfAbsent(l.head.type.tsym); tree.params.nonEmpty()) log.error(tree.params.head.pos(), "intf.annotation.members.cant.have.params"); for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { attribStat(l.head, localEnv); localEnv.info.scope.leave(); result = tree.type = m.type; chk.validateAnnotations(tree.mods.annotations, m);
if (owner.kind == VAR && owner.owner.kind == TYP) { lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared())); ClassSymbol enclClass = owner.enclClass(); for (Symbol s : enclClass.members_field.getElementsByName(names.init)) { lambdaEnv.info.scope.owner = s; break; Type clinitType = new MethodType(List.<Type>nil(), syms.voidType, List.<Type>nil(), syms.methodClass); clinit = new MethodSymbol(STATIC | SYNTHETIC | PRIVATE, names.clinit, clinitType, enclClass); clinit.params = List.<VarSymbol>nil(); clinits.put(enclClass, clinit); lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup()));
public void visitForeachLoop(JCEnhancedForLoop tree) { Env<AttrContext> loopEnv = env.dup(env.tree, env.info.dup(env.info.scope.dup())); attribStat(tree.var, loopEnv); Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv)); chk.checkNonVoid(tree.pos(), exprType); Type elemtype = types.elemtype(exprType); // perhaps expr is an array? if (elemtype == null) { // or perhaps expr implements Iterable<T>? Type base = types.asSuper(exprType, syms.iterableType.tsym); if (base == null) { log.error(tree.expr.pos(), "foreach.not.applicable.to.type"); elemtype = syms.errType; } else { List<Type> iterableParams = base.allparams(); elemtype = iterableParams.isEmpty() ? syms.objectType : types.upperBound(iterableParams.head); } } chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type); loopEnv.tree = tree; // before, we were not in loop! attribStat(tree.body, loopEnv); loopEnv.info.scope.leave(); result = null; }
void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; // also import inherited names importFrom(types.supertype(tsym.type).tsym); for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); final Scope fromScope = tsym.members(); for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { Symbol sym = e.sym; if (sym.kind == TYP && (sym.flags() & STATIC) != 0 && staticImportAccessible(sym, packge) && sym.isMemberOf(origin, types) && !toScope.includes(sym)) toScope.enter(sym, fromScope, origin.members()); } } }.importFrom(tsym);
new MethodType(List.<Type>nil(), syms.voidType, List.<Type>nil(), syms.methodClass), csym); clinits.put(csym, clinit); } else { for (Symbol s : csym.members_field.getElementsByName(names.init)) { return s;
q.flags_field |= EXISTS; c = reader.enterClass(tree.name, packge); packge.members().enterIfAbsent(c); if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) { log.error(tree.pos(), enclScope.enter(c); c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); c.sourcefile = env.toplevel.sourcefile; c.members_field = new Scope(c);
/** Enter a constant into symbol table. * @param name The constant's name. * @param type The constant's type. */ private VarSymbol enterConstant(String name, Type type) { VarSymbol c = new VarSymbol( PUBLIC | STATIC | FINAL, names.fromString(name), type, predefClass); c.setData(type.constValue()); predefClass.members().enter(c); return c; }
public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) { Env<AttrContext> mEnv = methodEnv(tree, env); mEnv.info.lint = mEnv.info.lint.augment(tree.sym); for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail) mEnv.info.scope.enterIfAbsent(l.head.type.tsym); for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) mEnv.info.scope.enterIfAbsent(l.head.sym); return mEnv; }
public void visitTry(JCTry tree) { // Attribute body attribStat(tree.body, env.dup(tree, env.info.dup())); // Attribute catch clauses for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) { JCCatch c = l.head; Env<AttrContext> catchEnv = env.dup(c, env.info.dup(env.info.scope.dup())); Type ctype = attribStat(c.param, catchEnv); if (c.param.type.tsym.kind == Kinds.VAR) { c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER); } chk.checkType(c.param.vartype.pos(), chk.checkClassType(c.param.vartype.pos(), ctype), syms.throwableType); attribStat(c.body, catchEnv); catchEnv.info.scope.leave(); } // Attribute finalizer if (tree.finalizer != null) attribStat(tree.finalizer, env); result = null; }
/** Add any variables defined in stats to the switch scope. */ private static void addVars(List<JCStatement> stats, Scope switchScope) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; if (stat.tag == JCTree.VARDEF) switchScope.enter(((JCVariableDecl) stat).sym); } } // where
/** Find or create an implicit method of exactly the given type (after erasure). * Searches in a side table, not the main scope of the site. * This emulates the lookup process required by JSR 292 in JVM. * @param env Attribution environment * @param spMethod signature polymorphic method - i.e. MH.invokeExact * @param argtypes The required argument types */ Symbol findPolymorphicSignatureInstance(Env<AttrContext> env, final Symbol spMethod, List<Type> argtypes) { Type mtype = infer.instantiatePolymorphicSignatureInstance(env, (MethodSymbol)spMethod, currentResolutionContext, argtypes); for (Symbol sym : polymorphicSignatureScope.getElementsByName(spMethod.name)) { if (types.isSameType(mtype, sym.type)) { return sym; } } // create the desired method long flags = ABSTRACT | HYPOTHETICAL | spMethod.flags() & Flags.AccessFlags; Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner) { @Override public Symbol baseSymbol() { return spMethod; } }; if (!mtype.isErroneous()) { // Cache only if kosher. polymorphicSignatureScope.enter(msym); } return msym; }
Symbol findTypeVar(Env<AttrContext> env, Name name, boolean staticOnly) { for (Scope.Entry e = env.info.scope.lookup(name); e.scope != null; e = e.next()) { if (e.sym.kind == TYP) { if (staticOnly && e.sym.type.hasTag(TYPEVAR) && e.sym.owner.kind == TYP) return new StaticError(e.sym); return e.sym; } } return typeNotFound; }
/** Create a fresh environment for method bodies. * @param tree The method definition. * @param env The environment current outside of the method definition. */ Env<AttrContext> methodEnv(JCMethodDecl tree, Env<AttrContext> env) { Env<AttrContext> localEnv = env.dup(tree, env.info.dup(env.info.scope.dupUnshared())); localEnv.enclMethod = tree; localEnv.info.scope.owner = tree.sym; if (tree.sym.type != null) { //when this is called in the enter stage, there's no type to be set localEnv.info.returnResult = attr.new ResultInfo(VAL, tree.sym.type.getReturnType()); } if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++; return localEnv; }
public void visitBlock(JCBlock tree) { if (env.info.scope.owner.kind == TYP) { // Block is a static or instance initializer; // let the owner of the environment be a freshly // created BLOCK-method. Env<AttrContext> localEnv = env.dup(tree, env.info.dup(env.info.scope.dupUnshared())); localEnv.info.scope.owner = new MethodSymbol(tree.flags | BLOCK, names.empty, null, env.info.scope.owner); if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++; attribStats(tree.stats, localEnv); } else { // Create a new local environment with a local scope. Env<AttrContext> localEnv = env.dup(tree, env.info.dup(env.info.scope.dup())); attribStats(tree.stats, localEnv); localEnv.info.scope.leave(); } result = null; }