@Override public String visitClassType(Type.ClassType t, Void s) { StringBuilder sb = new StringBuilder(); sb.append(t.tsym.getSimpleName()); if (t.getTypeArguments().nonEmpty()) { sb.append('<'); sb.append( t.getTypeArguments().stream() .map(a -> a.accept(this, null)) .collect(joining(", "))); sb.append(">"); } return sb.toString(); }
@Override public String visitClassType(Type.ClassType t, Void unused) { StringBuilder sb = new StringBuilder(); if (state == null || fix == null) { sb.append(t.tsym.getSimpleName()); } else { sb.append(qualifyType(state, fix, t.tsym)); } if (t.getTypeArguments().nonEmpty()) { sb.append('<'); sb.append( t.getTypeArguments().stream() .map(a -> a.accept(this, null)) .collect(joining(", "))); sb.append(">"); } return sb.toString(); }
/** Visitor method: Translate list of trees. */ public <T extends JCTree> List<T> translate(List<T> trees, Type type) { if (trees == null) return null; for (List<T> l = trees; l.nonEmpty(); l = l.tail) l.head = translate(l.head, type); return trees; }
/** The total width taken up by a vector of objects. */ public static int width(List<Type> types) { int w = 0; for (List<Type> l = types; l.nonEmpty(); l = l.tail) w = w + width(l.head); return w; }
/** Analyze a list of expressions. */ void scanExprs(List<? extends JCExpression> trees) { if (trees != null) for (List<? extends JCExpression> l = trees; l.nonEmpty(); l = l.tail) scanExpr(l.head); }
@Override public Type visitTypeVar(TypeVar t, Void ignored) { for (List<Type> from = this.from, to = this.to; from.nonEmpty(); from = from.tail, to = to.tail) { if (t == from.head) { return to.head.withTypeVar(t); } } return t; }
/** 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
/** Enter members from a list of trees. */ void memberEnter(List<? extends JCTree> trees, Env<AttrContext> env) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) memberEnter(l.head, env); }
/** Form the union of two type set lists. */ List<Type> union(List<Type> ts1, List<Type> ts2) { List<Type> ts = ts1; for (List<Type> l = ts2; l.nonEmpty(); l = l.tail) ts = incl(l.head, ts); return ts; }
/** Attribute a list of statements, returning nothing. */ <T extends JCTree> void attribStats(List<T> trees, Env<AttrContext> env) { for (List<T> l = trees; l.nonEmpty(); l = l.tail) attribStat(l.head, env); }
/** Derived visitor method: generate code for a list of statements. */ public void genStats(List<? extends JCTree> trees, Env<GenContext> env) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) genStat(l.head, env, CRT_STATEMENT); }
/** Visitor method: compute source positions for * a list of case blocks of switch statements. */ public SourceRange cspCases(List<JCCase> trees) { if ((trees == null) || !(trees.nonEmpty())) return null; SourceRange list_sr = new SourceRange(); for (List<JCCase> l = trees; l.nonEmpty(); l = l.tail) { list_sr.mergeWith(csp(l.head)); } positions.put(trees, list_sr); return list_sr; }
private void printTypeParameters(List < JCTypeParameter > trees) { if (trees.nonEmpty()) { print('<'); printExprs(trees); print('>'); } }
/** Derived visitor method: print list of statements, each on a separate line. */ public void printStats(List<? extends JCTree> trees) throws IOException { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) { align(); printStat(l.head); println(); } }
/** Return all exceptions in thrown list that are not in handled list. * @param thrown The list of thrown exceptions. * @param handled The list of handled exceptions. */ List<Type> unHandled(List<Type> thrown, List<Type> handled) { List<Type> unhandled = List.nil(); for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) if (!isHandled(l.head, handled)) unhandled = unhandled.prepend(l.head); return unhandled; }
void addBridges(DiagnosticPosition pos, TypeSymbol i, ClassSymbol origin, ListBuffer<JCTree> bridges) { for (Scope.Entry e = i.members().elems; e != null; e = e.sibling) addBridgeIfNeeded(pos, e.sym, origin, bridges); for (List<Type> l = types.interfaces(i.type); l.nonEmpty(); l = l.tail) addBridges(pos, l.head.tsym, origin, bridges); }
/** 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(); }
void writeMethods(Scope.Entry e) { List<MethodSymbol> methods = List.nil(); for (Scope.Entry i = e; i != null; i = i.sibling) { if (i.sym.kind == MTH && (i.sym.flags() & HYPOTHETICAL) == 0) methods = methods.prepend((MethodSymbol)i.sym); } while (methods.nonEmpty()) { writeMethod(methods.head); methods = methods.tail; } }
/** 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); }
/** Attribute the arguments in a method call, returning a list of types. */ List<Type> attribArgs(List<JCExpression> trees, Env<AttrContext> env) { ListBuffer<Type> argtypes = new ListBuffer<Type>(); for (List<JCExpression> l = trees; l.nonEmpty(); l = l.tail) argtypes.append(chk.checkNonVoid( l.head.pos(), types.upperBound(attribTree(l.head, env, VAL, Infer.anyPoly)))); return argtypes.toList(); }