Search in sources :

Example 41 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project jqa-java-plugin by buschmais.

the class ClassVisitor method visitField.

@Override
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
    final FieldDescriptor fieldDescriptor = visitorHelper.getFieldDescriptor(cachedType, SignatureHelper.getFieldSignature(name, desc));
    fieldDescriptor.setName(name);
    fieldDescriptor.setVolatile(hasFlag(access, Opcodes.ACC_VOLATILE));
    fieldDescriptor.setTransient(hasFlag(access, Opcodes.ACC_TRANSIENT));
    setModifiers(access, fieldDescriptor);
    if (signature == null) {
        TypeDescriptor type = visitorHelper.resolveType(SignatureHelper.getType((desc)), cachedType).getTypeDescriptor();
        fieldDescriptor.setType(type);
    } else {
        new SignatureReader(signature).accept(new AbstractBoundVisitor(visitorHelper, cachedType) {

            @Override
            protected void apply(TypeDescriptor rawTypeBound, BoundDescriptor bound) {
                fieldDescriptor.setType(rawTypeBound);
                fieldDescriptor.setGenericType(bound);
            }
        });
    }
    if (value != null) {
        if (value instanceof org.objectweb.asm.Type) {
            visitorHelper.resolveType(SignatureHelper.getType((org.objectweb.asm.Type) value), cachedType);
        }
        PrimitiveValueDescriptor valueDescriptor = visitorHelper.getValueDescriptor(PrimitiveValueDescriptor.class);
        valueDescriptor.setValue(value);
        fieldDescriptor.setValue(valueDescriptor);
    }
    return new FieldVisitor(cachedType, fieldDescriptor, visitorHelper);
}
Also used : BoundDescriptor(com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor) SignatureReader(org.objectweb.asm.signature.SignatureReader) AbstractBoundVisitor(com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)

Aggregations

SignatureReader (org.objectweb.asm.signature.SignatureReader)41 SignatureWriter (org.objectweb.asm.signature.SignatureWriter)12 ArrayList (java.util.ArrayList)5 ClassNode (org.codehaus.groovy.ast.ClassNode)4 GenericsType (org.codehaus.groovy.ast.GenericsType)3 Type (org.objectweb.asm.Type)3 SignatureVisitor (org.objectweb.asm.signature.SignatureVisitor)3 BoundDescriptor (com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor)2 AbstractBoundVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)2 List (java.util.List)2 Map (java.util.Map)2 TypeSignatureVisitor (net.sourceforge.pmd.dcd.asm.TypeSignatureVisitor)2 EntryMessage (org.apache.logging.log4j.message.EntryMessage)2 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)2 ReturnStatement (org.codehaus.groovy.ast.stmt.ReturnStatement)2 DelegatingMethodVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor)1 ClassSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.ClassSignatureVisitor)1 MethodSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.MethodSignatureVisitor)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1