@Override public Void visitArrayType(Type.ArrayType type, Void unused) { type.elemtype.accept(this, null); return null; }
@Override public String visitArrayType(Type.ArrayType t, Void unused) { return t.elemtype.accept(this, null) + "[]"; }
/** Pretty-prints a Type for use in diagnostics, using simple names for class types */ public static String prettyType(Type type) { return type.accept(PRETTY_TYPE_VISITOR, null); }
@Override public String visitArrayType(Type.ArrayType t, Void aVoid) { return t.elemtype.accept(this, null) + "[]"; }
public UType template(Type type) { return type.accept(typeTemplater, null); }
@Override public Void visitTypeVar(Type.TypeVar type, Void unused) { // only visit f-bounds once: if (!seen.add(type.tsym)) { return null; } if (type.bound != null) { type.bound.accept(this, null); } return null; }
@Override public String visitWildcardType(Type.WildcardType t, Void unused) { StringBuilder sb = new StringBuilder(); sb.append(t.kind); if (t.kind != BoundKind.UNBOUND) { sb.append(t.type.accept(this, null)); } return sb.toString(); }
@Override public String visitWildcardType(Type.WildcardType t, Void aVoid) { StringBuilder sb = new StringBuilder(); sb.append(t.kind); if (t.kind != BoundKind.UNBOUND) { sb.append(t.type.accept(this, null)); } return sb.toString(); }
static Set<Symbol.TypeSymbol> visit(Type type) { TypeParameterFinder visitor = new TypeParameterFinder(); type.accept(visitor, null); return visitor.seen; }
@Override public final Choice<Unifier> unify(Type target, Unifier unifier) { return (target != null) ? target.accept(this, unifier) : Choice.<Unifier>none(); } }
public void visitIntersectionClassType(Type.IntersectionClassType type) { for (Type component : type.getComponents()) { component.accept(this, null); } }
/** * Returns an {@link Violation} explaining whether the type is threadsafe. * * @param allowContainerTypeParameters true when checking the instantiation of an {@code * typeParameterAnnotation}-annotated type parameter; indicates that {@code * containerTypeParameters} should be ignored * @param containerTypeParameters type parameters in enclosing elements' containerOf * specifications * @param type to check for thread-safety */ public Violation isThreadSafeType( boolean allowContainerTypeParameters, Set<String> containerTypeParameters, Type type) { return type.accept( new ThreadSafeTypeVisitor(allowContainerTypeParameters, containerTypeParameters), null); }
@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 Void visitClassType(Type.ClassType type, Void unused) { if (type instanceof Type.IntersectionClassType) { // TypeVisitor doesn't support intersection types natively visitIntersectionClassType((Type.IntersectionClassType) type); } else { for (Type t : type.getTypeArguments()) { t.accept(this, null); } } return null; }
@Override public Violation visitWildcardType(WildcardType type, Void s) { return state.getTypes().wildUpperBound(type).accept(this, null); }
/** * Pretty-prints a method signature for use in diagnostics. * * <p>Uses simple names for declared types, and omitting formal type parameters and the return * type since they do not affect overload resolution. */ public static String prettyMethodSignature(ClassSymbol origin, MethodSymbol m) { StringBuilder sb = new StringBuilder(); if (!m.owner.equals(origin)) { sb.append(m.owner.getSimpleName()).append('.'); } sb.append(m.isConstructor() ? origin.getSimpleName() : m.getSimpleName()).append('('); sb.append( m.getParameters().stream() .map(v -> v.type.accept(PRETTY_TYPE_VISITOR, 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(); }
Type enclosing = tree.type.getEnclosingType(); if (enclosing != null) { enclosing.accept(new TypeVariableScanner(), null);