Search in sources :

Example 1 with BoundDescriptor

use of com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor 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 BoundDescriptor

use of com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor in project jqa-java-plugin by buschmais.

the class MethodSignatureVisitor method visitParameterType.

@Override
public SignatureVisitor visitParameterType() {
    final ParameterDescriptor parameterDescriptor = visitorHelper.addParameterDescriptor(descriptor, parameterIndex);
    parameterIndex++;
    return new AbstractBoundVisitor(visitorHelper, containingType) {

        @Override
        protected void apply(TypeDescriptor rawTypeBound, BoundDescriptor bound) {
            parameterDescriptor.setType(rawTypeBound);
            parameterDescriptor.setGenericType(bound);
        }
    };
}
Also used : BoundDescriptor(com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor) TypeDescriptor(com.buschmais.jqassistant.plugin.java.api.model.TypeDescriptor) ParameterDescriptor(com.buschmais.jqassistant.plugin.java.api.model.ParameterDescriptor)

Example 3 with BoundDescriptor

use of com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor 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)3 AbstractBoundVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)2 SignatureReader (org.objectweb.asm.signature.SignatureReader)2 ParameterDescriptor (com.buschmais.jqassistant.plugin.java.api.model.ParameterDescriptor)1 TypeDescriptor (com.buschmais.jqassistant.plugin.java.api.model.TypeDescriptor)1