public <R> com.sun.tools.javac.util.List<R> inlineList( Iterable<? extends Inlineable<? extends R>> elements) throws CouldNotResolveImportException { ListBuffer<R> result = new ListBuffer<>(); for (Inlineable<? extends R> e : elements) { if (e instanceof URepeated) { // URepeated is bound to a list of expressions. URepeated repeated = (URepeated) e; for (JCExpression expr : getBinding(repeated.key())) { @SuppressWarnings("unchecked") // URepeated is an Inlineable<JCExpression>, so if e is also an Inlineable<? extends R>, // then R must be ? super JCExpression. R r = (R) expr; result.append(r); } } else { result.append(e.inline(this)); } } return result.toList(); }
@Override public com.sun.tools.javac.util.List<JCStatement> inlineStatements(Inliner inliner) { ListBuffer<JCStatement> buffer = new ListBuffer<>(); for (StatementTree stmt : inliner.getOptionalBinding(key()).or(ImmutableList.<StatementTree>of())) { buffer.add((JCStatement) stmt); } return buffer.toList(); } }
static com.sun.tools.javac.util.List<JCStatement> inlineStatementList( Iterable<? extends UStatement> statements, Inliner inliner) throws CouldNotResolveImportException { ListBuffer<JCStatement> buffer = new ListBuffer<>(); for (UStatement statement : statements) { buffer.appendList(statement.inlineStatements(inliner)); } return buffer.toList(); }
/** * Return the minimum types of a closure, suitable for computing * compoundMin or glb. */ private List<Type> closureMin(List<Type> cl) { ListBuffer<Type> classes = new ListBuffer<>(); ListBuffer<Type> interfaces = new ListBuffer<>(); while (!cl.isEmpty()) { Type current = cl.head; if (current.isInterface()) interfaces.append(current); else classes.append(current); ListBuffer<Type> candidates = new ListBuffer<>(); for (Type t : cl.tail) { if (!isSubtypeNoCapture(current, t)) candidates.append(t); } cl = candidates.toList(); } return classes.appendList(interfaces).toList(); }
private Attribute.Compound[] unpackContained(Attribute.Compound container) { // Pack them in an array Attribute[] contained0 = null; if (container != null) contained0 = unpackAttributes(container); ListBuffer<Attribute.Compound> compounds = new ListBuffer<>(); if (contained0 != null) { for (Attribute a : contained0) if (a instanceof Attribute.Compound) compounds = compounds.append((Attribute.Compound)a); } return compounds.toArray(new Attribute.Compound[compounds.size()]); }
final ListBuffer<Symbol> abstracts = new ListBuffer<>(); for (Symbol sym : membersCache.getElements(new DescriptorFilter(origin))) { Type mtype = memberType(origin.type, sym); if (abstracts.isEmpty() || (sym.name == abstracts.first().name && overrideEquivalent(mtype, memberType(origin.type, abstracts.first())))) { abstracts.append(sym); } else { if (abstracts.isEmpty()) { } else if (abstracts.size() == 1) { return new FunctionDescriptor(abstracts.first()); } else { // size > 1 FunctionDescriptor descRes = mergeDescriptors(origin, abstracts.toList()); if (descRes == null) { ListBuffer<JCDiagnostic> descriptors = new ListBuffer<>(); for (Symbol desc : abstracts) { String key = desc.type.getThrownTypes().nonEmpty() ? "descriptor.throws" : "descriptor"; descriptors.append(diags.fragment(key, desc.name, desc.type.getParameterTypes(), desc.type.getReturnType(), Kinds.kindName(origin), origin), descriptors.toList()); throw failure(incompatibleDescriptors);
List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m); if (prov.size() > 1) { ListBuffer<Symbol> abstracts = new ListBuffer<>(); ListBuffer<Symbol> defaults = new ListBuffer<>(); for (MethodSymbol provSym : prov) { if ((provSym.flags() & DEFAULT) != 0) { defaults = defaults.append(provSym); } else if ((provSym.flags() & ABSTRACT) != 0) { abstracts = abstracts.append(provSym); if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) { Symbol s1 = defaults.first(); Symbol s2; if (defaults.size() > 1) { errKey = "types.incompatible.unrelated.defaults"; s2 = defaults.toList().tail.head; } else { errKey = "types.incompatible.abstract.default"; s2 = abstracts.first();
/** * Attribute a list of parse trees, such as found on the "todo" list. * Note that attributing classes may cause additional files to be * parsed and entered via the SourceCompleter. * Attribution of the entries in the list does not stop if any errors occur. * @returns a list of environments for attributd classes. */ public List<Env<AttrContext>> attribute(ListBuffer<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); while (envs.nonEmpty()) results.append(attribute(envs.next())); return results.toList(); }
final List<Type> freeVarsIn(List<Type> ts) { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : ts) { buf.appendList(freeVarsIn(t)); } ListBuffer<Type> buf2 = new ListBuffer<>(); for (Type t : buf) { if (!buf2.contains(t)) { buf2.add(t); } } return buf2.toList(); }
private Type rewriteSupers(Type t) { if (!t.isParameterized()) return t; ListBuffer<Type> from = lb(); ListBuffer<Type> to = lb(); adaptSelf(t, from, to); if (from.isEmpty()) return t; ListBuffer<Type> rewrite = lb(); boolean changed = false; for (Type orig : to.toList()) { Type s = rewriteSupers(orig); if (s.isSuperBound() && !s.isExtendsBound()) { s = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass); changed = true; } else if (s != orig) { s = new WildcardType(upperBound(s), BoundKind.EXTENDS, syms.boundClass); changed = true; } rewrite.append(s); } if (changed) return subst(t.tsym.type, from.toList(), rewrite.toList()); else return t; }
/** * Return the minimum types of a closure, suitable for computing * compoundMin or glb. */ private List<Type> closureMin(List<Type> cl) { ListBuffer<Type> classes = lb(); ListBuffer<Type> interfaces = lb(); while (!cl.isEmpty()) { Type current = cl.head; if (current.isInterface()) interfaces.append(current); else classes.append(current); ListBuffer<Type> candidates = lb(); for (Type t : cl.tail) { if (!isSubtypeNoCapture(current, t)) candidates.append(t); } cl = candidates.toList(); } return classes.appendList(interfaces).toList(); }
public void visitMethodDef(JCMethodDecl tree) { if (tree.body == null) return; Lint lintPrev = lint; lint = lint.augment(tree.sym); Assert.check(pendingExits.isEmpty()); try { alive = true; scanStat(tree.body); if (alive && !tree.sym.type.getReturnType().hasTag(VOID)) log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt"); List<PendingExit> exits = pendingExits.toList(); pendingExits = new ListBuffer<PendingExit>(); while (exits.nonEmpty()) { PendingExit exit = exits.head; exits = exits.tail; Assert.check(exit.tree.hasTag(RETURN)); } } finally { lint = lintPrev; } }
final ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>(); try { compiler.generate(compiler.desugar(genList.toList()), results); genList.clear(); f.run(genList, classes); if (genList.isEmpty()) { compiler.reportDeferredDiagnostics(); compiler.log.flush();
final ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>(); try { genList.clear(); f.run(genList, classes); if (genList.isEmpty()) { compiler.reportDeferredDiagnostics(); cleanup();
/** Append all elements in a list to buffer. */ public ListBuffer<A> appendList(ListBuffer<A> xs) { return appendList(xs.toList()); }
public static <T> ListBuffer<T> of(T x) { ListBuffer<T> lb = new ListBuffer<T>(); lb.add(x); return lb; }
/** * Attribute a list of parse trees, such as found on the "todo" list. * Note that attributing classes may cause additional files to be * parsed and entered via the SourceCompleter. * Attribution of the entries in the list does not stop if any errors occur. * @returns a list of environments for attributd classes. */ public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); while (!envs.isEmpty()) results.append(attribute(envs.remove())); return stopIfError(CompileState.ATTR, results); }
private void handleFlowResults(List<Env<AttrContext>> list, ListBuffer<Element> elems) { for (Env<AttrContext> env: list) { switch (env.tree.tag) { case JCTree.CLASSDEF: JCClassDecl cdef = (JCClassDecl) env.tree; if (cdef.sym != null) elems.append(cdef.sym); break; case JCTree.TOPLEVEL: JCCompilationUnit unit = (JCCompilationUnit) env.tree; if (unit.packge != null) elems.append(unit.packge); break; } } genList.appendList(list); }
/** ForInit = StatementExpression MoreStatementExpressions * | { FINAL | '@' Annotation } Type VariableDeclarators */ List<JCStatement> forInit() { ListBuffer<JCStatement> stats = lb(); int pos = S.pos(); if (S.token() == FINAL || S.token() == MONKEYS_AT) { return variableDeclarators(optFinal(0), type(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM)) return variableDeclarators(modifiersOpt(), t, stats).toList(); else return moreStatementExpressions(pos, t, stats).toList(); } }