@Override public SignatureVisitor visitTypeArgument(final char tag) { if (argumentStack % 2 == 0) { ++argumentStack; declaration.append('<'); } else { declaration.append(", "); } if (tag == EXTENDS) { declaration.append("? extends "); } else if (tag == SUPER) { declaration.append("? super "); } startType(); return this; }
@Override public SignatureVisitor visitParameterType() { endFormals(); if (seenParameter) { declaration.append(", "); } else { seenParameter = true; declaration.append('('); } startType(); return this; }
@Override public SignatureVisitor visitClassBound() { if (state != FORMAL) { throw new IllegalStateException(); } state = BOUND; SignatureVisitor v = sv == null ? null : sv.visitClassBound(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitInterface() { if (state != SUPER) { throw new IllegalStateException(); } SignatureVisitor v = sv == null ? null : sv.visitInterface(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
/** * @param signature * signature for mapper * @param typeSignature * true if signature is a FieldTypeSignature, such as the * signature parameter of the ClassVisitor.visitField or * MethodVisitor.visitLocalVariable methods * @return signature rewritten as a string */ public String mapSignature(String signature, boolean typeSignature) { if (signature == null) { return null; } SignatureReader r = new SignatureReader(signature); SignatureWriter w = new SignatureWriter(); SignatureVisitor a = createSignatureRemapper(w); if (typeSignature) { r.acceptType(a); } else { r.accept(a); } return w.toString(); }
@Override public SignatureVisitor visitSuperclass() { endFormals(); separator = " extends "; startType(); return this; }
@Override public SignatureVisitor visitInterface() { separator = seenInterface ? ", " : isInterface ? " extends " : " implements "; seenInterface = true; startType(); return this; }
@Override public SignatureVisitor visitTypeArgument(final char wildcard) { if (state != CLASS_TYPE) { throw new IllegalStateException(); } if ("+-=".indexOf(wildcard) == -1) { throw new IllegalArgumentException(); } SignatureVisitor v = sv == null ? null : sv.visitTypeArgument(wildcard); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitSuperclass() { if (type != CLASS_SIGNATURE || (state & (EMPTY | FORMAL | BOUND)) == 0) { throw new IllegalArgumentException(); } state = SUPER; SignatureVisitor v = sv == null ? null : sv.visitSuperclass(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitParameterType() { if (type != METHOD_SIGNATURE || (state & (EMPTY | FORMAL | BOUND | PARAM)) == 0) { throw new IllegalArgumentException(); } state = PARAM; SignatureVisitor v = sv == null ? null : sv.visitParameterType(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitReturnType() { if (type != METHOD_SIGNATURE || (state & (EMPTY | FORMAL | BOUND | PARAM)) == 0) { throw new IllegalArgumentException(); } state = RETURN; SignatureVisitor v = sv == null ? null : sv.visitReturnType(); CheckSignatureAdapter cv = new CheckSignatureAdapter(TYPE_SIGNATURE, v); cv.canBeVoid = true; return cv; }
@Override public SignatureVisitor visitExceptionType() { if (state != RETURN) { throw new IllegalStateException(); } SignatureVisitor v = sv == null ? null : sv.visitExceptionType(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitArrayType() { if (type != TYPE_SIGNATURE || state != EMPTY) { throw new IllegalStateException(); } state = SIMPLE_TYPE; SignatureVisitor v = sv == null ? null : sv.visitArrayType(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
@Override public SignatureVisitor visitExceptionType() { if (exceptions == null) { exceptions = new StringBuilder(); } else { exceptions.append(", "); } // startType(); return new TraceSignatureVisitor(exceptions); }
@Override public SignatureVisitor visitInterfaceBound() { separator = seenInterfaceBound ? ", " : " extends "; seenInterfaceBound = true; startType(); return this; }
@Override public SignatureVisitor visitTypeArgument(char c) { return new NullSignVisitor(); }
@Override public SignatureVisitor visitArrayType() { load(Opcodes.ALOAD, paramIndex++); localSize++; return new NullSignVisitor(); }
@Override public SignatureVisitor visitExceptionType() { return new NullSignVisitor(); }
@Override public SignatureVisitor visitReturnType() { return new NullSignVisitor(); }
@Override public SignatureVisitor visitInterface() { return null; }
@Override public SignatureVisitor visitSuperclass() { return null; }
@Override public SignatureVisitor visitInterfaceBound() { return new NullSignVisitor(); }
@Override public SignatureVisitor visitClassBound() { return new NullSignVisitor(); }
@Override public SignatureVisitor visitTypeArgument(char wildcard) { v.visitTypeArgument(wildcard); return this; }
protected RemappingSignatureAdapter(final int api, final SignatureVisitor v, final Remapper remapper) { super(api); this.v = v; this.remapper = remapper; }
@Override public SignatureVisitor visitArrayType() { v.visitArrayType(); return this; }
public SignatureRemapper(final SignatureVisitor v, final Remapper remapper) { this(Opcodes.ASM5, v, remapper); }
@Override public SignatureVisitor visitInterfaceBound() { v.visitInterfaceBound(); return this; }
@Override public SignatureVisitor visitParameterType() { v.visitParameterType(); return this; }