Search in sources :

Example 1 with AbstractBoundVisitor

use of com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor in project jqa-java-plugin by buschmais.

the class MethodVisitor method visitLocalVariable.

@Override
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
    if (visitorHelper.getClassModelConfiguration().isMethodDeclaresVariable() && !THIS.equals(name)) {
        final VariableDescriptor variableDescriptor = visitorHelper.getVariableDescriptor(name, SignatureHelper.getFieldSignature(name, desc));
        if (signature == null) {
            TypeDescriptor type = visitorHelper.resolveType(SignatureHelper.getType((desc)), containingType).getTypeDescriptor();
            variableDescriptor.setType(type);
        } else {
            new SignatureReader(signature).accept(new AbstractBoundVisitor(visitorHelper, containingType) {

                @Override
                protected void apply(TypeDescriptor rawTypeBound, BoundDescriptor bound) {
                    variableDescriptor.setType(rawTypeBound);
                    variableDescriptor.setGenericType(bound);
                }
            });
        }
        methodDescriptor.getVariables().add(variableDescriptor);
    }
}
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)

Example 2 with AbstractBoundVisitor

use of com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor 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

BoundDescriptor (com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor)2 AbstractBoundVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)2 SignatureReader (org.objectweb.asm.signature.SignatureReader)2