Java Code Examples for org.objectweb.asm.signature.SignatureReader#acceptType()

The following examples show how to use org.objectweb.asm.signature.SignatureReader#acceptType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Textifier.java    From JByteMod-Beta with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
  buf.setLength(0);
  buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
  appendDescriptor(FIELD_DESCRIPTOR, desc);
  buf.append(' ');
  appendLabel(start);
  buf.append(' ');
  appendLabel(end);
  buf.append(' ').append(index).append('\n');

  if (signature != null) {
    buf.append(tab2);
    appendDescriptor(FIELD_SIGNATURE, signature);

    TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
    SignatureReader r = new SignatureReader(signature);
    r.acceptType(sv);
    buf.append(tab2).append("// declaration: ").append(sv.getDeclaration()).append('\n');
  }
  text.add(buf.toString());
}
 
Example 2
Source File: FieldAnalyzeVisitor.java    From meghanada-server with GNU General Public License v3.0 6 votes vote down vote up
FieldAnalyzeVisitor parseSignature() {
  final EntryMessage m = log.traceEntry("fieldSignature={}", fieldSignature);
  boolean isStatic = (Opcodes.ACC_STATIC & this.access) > 0;
  SignatureReader signatureReader = new SignatureReader(this.fieldSignature);
  FieldSignatureVisitor visitor;
  if (isStatic) {
    visitor = new FieldSignatureVisitor(this.name, new ArrayList<>(4));
  } else {
    visitor = new FieldSignatureVisitor(this.name, this.classAnalyzeVisitor.classTypeParameters);
  }
  if (this.typeMap != null) {
    visitor.setTypeMap(this.typeMap);
  }

  this.fieldSignatureVisitor = visitor;
  signatureReader.acceptType(fieldSignatureVisitor);
  return log.traceExit(m, this);
}
 
Example 3
Source File: NameTranslatorClassVisitor.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private String translateSignature(final String signature, boolean type) {
	if (signature == null) {
		return null;
	}
	SignatureReader r = new SignatureReader(signature);
	SignatureWriter w = new SignatureWriter() {
	    public void visitClassType(final String name) {
	    	String n = translator.getClassMirrorTranslation(name);
	    	super.visitClassType(n);
	    }
	};

	if (type) {
		r.acceptType(w);		
	} else {
		r.accept(w);		
	}
	return w.toString();
}
 
Example 4
Source File: Remapper.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
Example 5
Source File: Remapper.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
Example 6
Source File: Textifier.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Textifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
  buf.setLength(0);
  buf.append('\n');
  if ((access & Opcodes.ACC_DEPRECATED) != 0) {
    buf.append(tab).append("// DEPRECATED\n");
  }
  buf.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');
  if (signature != null) {
    buf.append(tab);
    appendDescriptor(FIELD_SIGNATURE, signature);

    TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
    SignatureReader r = new SignatureReader(signature);
    r.acceptType(sv);
    buf.append(tab).append("// declaration: ").append(sv.getDeclaration()).append('\n');
  }

  buf.append(tab);
  appendAccess(access);

  appendDescriptor(FIELD_DESCRIPTOR, desc);
  buf.append(' ').append(name);
  if (value != null) {
    buf.append(" = ");
    if (value instanceof String) {
      buf.append('\"').append(value).append('\"');
    } else {
      buf.append(value);
    }
  }

  buf.append('\n');
  text.add(buf.toString());

  Textifier t = createTextifier();
  text.add(t.getText());
  return t;
}
 
Example 7
Source File: FieldSignatureVisitorTest.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(
    int access, String name, String desc, String signature, Object value) {
  String target = signature;
  if (target == null) {
    target = desc;
  }
  SignatureReader signatureReader = new SignatureReader(target);
  this.visitor = new FieldSignatureVisitor(name, new ArrayList<>());
  signatureReader.acceptType(this.visitor);
  result.put(name, this.visitor.getResult());
  return super.visitField(access, name, desc, signature, value);
}
 
Example 8
Source File: JavaUtils.java    From jaxrs-analyzer with Apache License 2.0 5 votes vote down vote up
/**
 * Converts the given type signature to a human readable type string.
 * <p>
 * Example: {@code Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>; -> java.util.Map<java.lang.String, java.lang.String>}
 */
public static String toReadableType(final String type) {
    final SignatureReader reader = new SignatureReader(type);
    final TraceSignatureVisitor visitor = new TraceSignatureVisitor(0);
    reader.acceptType(visitor);
    return visitor.getDeclaration();
}
 
Example 9
Source File: ExtraTextifier.java    From TickDynamic with MIT License 5 votes vote down vote up
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    
    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    text.add(buf.toString());
}
 
Example 10
Source File: Remapper.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
Example 11
Source File: Remapper.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Returns the given signature, remapped with the {@link SignatureVisitor} returned by {@link
 * #createSignatureRemapper(SignatureVisitor)}.
 *
 * @param signature a <i>JavaTypeSignature</i>, <i>ClassSignature</i> or <i>MethodSignature</i>.
 * @param typeSignature whether the given signature is a <i>JavaTypeSignature</i>.
 * @return signature the given signature, remapped with the {@link SignatureVisitor} returned by
 *     {@link #createSignatureRemapper(SignatureVisitor)}.
 */
public String mapSignature(final String signature, final boolean typeSignature) {
  if (signature == null) {
    return null;
  }
  SignatureReader signatureReader = new SignatureReader(signature);
  SignatureWriter signatureWriter = new SignatureWriter();
  SignatureVisitor signatureRemapper = createSignatureRemapper(signatureWriter);
  if (typeSignature) {
    signatureReader.acceptType(signatureRemapper);
  } else {
    signatureReader.accept(signatureRemapper);
  }
  return signatureWriter.toString();
}
 
Example 12
Source File: Remapper.java    From bytecode-viewer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param typeSignature true if signature is a FieldTypeSignature, such as the
 *                      signature parameter of the ClassVisitor.visitField or
 *                      MethodVisitor.visitLocalVariable methods
 */
public String mapSignature(String signature, boolean typeSignature) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter();
    SignatureVisitor a = createRemappingSignatureAdapter(w);
    if (typeSignature) {
        r.acceptType(a);
    } else {
        r.accept(a);
    }
    return w.toString();
}