@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitNoType(this, p); }
/** * Finds all declared types (classes and interfaces) that are referenced in the given * {@code Set<TypeMirror>}. This includes classes and interfaces that appear directly in the set, * but also ones that appear in type parameters and the like. For example, if the set contains * {@code java.util.List<? extends java.lang.Number>} then both {@code java.util.List} and * {@code java.lang.Number} will be in the resulting set. */ private static Set<TypeMirror> referencedClassTypes(Types typeUtil, Set<TypeMirror> types) { Set<TypeMirror> referenced = new HashSet<TypeMirror>(); TypeVisitor<Void, Void> typeVisitor = new ReferencedClassTypeVisitor(typeUtil, referenced); for (TypeMirror type : types) { type.accept(typeVisitor, null); } return referenced; }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { switch(this.getKind()) { case NULL : return v.visitNull(this, p); default: return v.visitNoType(this, p); } }
@Override public Void visitIntersection(IntersectionType t, StringBuilderAndState<TypeMirror> state) { Iterator<? extends TypeMirror> it = IgnoreCompletionFailures.in(t::getBounds).iterator(); if (it.hasNext()) { it.next().accept(this, state); } TypeVisitor<Void, StringBuilderAndState<TypeMirror>> me = this; it.forEachRemaining(b -> { state.bld.append(", "); b.accept(me, state); }); return null; }
private DeclaredType getMockAnnotationType() { return new DeclaredType() { @Override public String toString() { return UsesMocks.class.getName(); } @Override public Element asElement() { return null; } @Override public TypeMirror getEnclosingType() { return null; } @Override public List<? extends TypeMirror> getTypeArguments() { return null; } @Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return null; } @Override public TypeKind getKind() { return null; } }; }
private String getMethodDescriptor(ExecutableElement element) { final StringBuilder buf = new StringBuilder(); buf.append(element.getSimpleName()).append('('); TypeVisitor<Void, Void> typeWriter = new BinaryTypeWriter(buf); for ( VariableElement param : element.getParameters() ) { TypeMirror type = processingEnv.getTypeUtils().erasure(param.asType()); type.accept(typeWriter, null); } buf.append(')'); processingEnv.getTypeUtils().erasure(element.getReturnType()).accept(typeWriter, null); return buf.toString(); }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { switch (kind) { case BOOLEAN: case BYTE: case SHORT: case INT: case LONG: case CHAR: case FLOAT: case DOUBLE: return v.visitPrimitive((PrimitiveType) this, p); case PACKAGE: case VOID: case NONE: return v.visitNoType((NoType) this, p); case NULL: return v.visitNull((NullType) this, p); case ARRAY: return v.visitArray((ArrayType) this, p); case DECLARED: return v.visitDeclared((DeclaredType) this, p); case ERROR: return v.visitError((ErrorType) this, p); case TYPEVAR: return v.visitTypeVariable((TypeVariable) this, p); case WILDCARD: return v.visitWildcard((WildcardType) this, p); case EXECUTABLE: return v.visitExecutable((ExecutableType) this, p); case OTHER: return v.visit(this, p); case UNION: return v.visitUnion((UnionType) this, p); case INTERSECTION: return v.visitIntersection((IntersectionType) this, p); default: throw new AssertionError(String.format("Unknown TypeKind: %s", kind)); } }
private static TypeMirror noType() { return new NoType() { @Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { throw new UnsupportedOperationException(); } @Override public TypeKind getKind() { throw new UnsupportedOperationException(); } }; }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return delegate.accept(v, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { if (isPrimitive()) return v.visitPrimitive(this, p); else throw new AssertionError(); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitWildcard(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitDeclared(this, p); }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitUnion(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitArray(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitExecutable(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitNoType(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitTypeVariable(this, p); }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitNull(this, p); }
public <R, P> R accept(TypeVisitor<R, P> v, P p) { return v.visitError(this, p); }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { throw new IllegalStateException(); }
@Override public <R, P> R accept(TypeVisitor<R, P> v, P p) { return null; }
public ParameterVisitor( TypeVisitor<Boolean,Void> parameterTypeVisitor ) { this.parameterTypeVisitor = parameterTypeVisitor; }
@Override protected TypeVisitor<Boolean,Void> visitor() { return new RecordFieldTypeVisitor( types, typeMirrorUtils ); }
@Override protected TypeVisitor<Boolean,Void> visitor() { return new ParameterTypeVisitor( types, typeMirrorUtils ); }
@Override public <R, P> R accept(TypeVisitor<R, P> typeVisitor, P p) { return typeVisitor.visitError(this, p); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitDeclared(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitPrimitive(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitTypeVariable(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitNoType(this, parameter); }
@Override public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitWildcard(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitArray(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitUnknown(this, parameter); }
@Override @Nullable public <R, P> R accept(TypeVisitor<R, P> visitor, @Nullable P parameter) { return visitor.visitNull(this, parameter); }