Search in sources :

Example 1 with DelegatingMethodVisitor

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

the class ClassVisitor method visitMethod.

@Override
public org.objectweb.asm.MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
    MethodDescriptor methodDescriptor = visitorHelper.getMethodDescriptor(cachedType, SignatureHelper.getMethodSignature(name, desc));
    visitorHelper.getTypeVariableResolver().push();
    methodDescriptor.setName(name);
    setModifiers(access, methodDescriptor);
    if (hasFlag(access, Opcodes.ACC_ABSTRACT)) {
        methodDescriptor.setAbstract(Boolean.TRUE);
    }
    if (hasFlag(access, Opcodes.ACC_NATIVE)) {
        methodDescriptor.setNative(Boolean.TRUE);
    }
    if (signature == null) {
        String returnType = SignatureHelper.getType(org.objectweb.asm.Type.getReturnType(desc));
        methodDescriptor.setReturns(visitorHelper.resolveType(returnType, cachedType).getTypeDescriptor());
        org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            String parameterType = SignatureHelper.getType(types[i]);
            TypeDescriptor typeDescriptor = visitorHelper.resolveType(parameterType, cachedType).getTypeDescriptor();
            ParameterDescriptor parameterDescriptor = visitorHelper.addParameterDescriptor(methodDescriptor, i);
            parameterDescriptor.setType(typeDescriptor);
        }
    } else {
        new SignatureReader(signature).accept(new MethodSignatureVisitor(cachedType, methodDescriptor, visitorHelper));
    }
    for (int i = 0; exceptions != null && i < exceptions.length; i++) {
        TypeDescriptor exceptionType = visitorHelper.resolveType(SignatureHelper.getObjectType(exceptions[i]), cachedType).getTypeDescriptor();
        methodDescriptor.getThrows().add(exceptionType);
    }
    return new DelegatingMethodVisitor(asList(new MethodVisitor(cachedType, methodDescriptor, visitorHelper), new MethodLoCVisitor(methodDescriptor), new MethodComplexityVisitor(methodDescriptor)));
}
Also used : DelegatingMethodVisitor(com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor) SignatureReader(org.objectweb.asm.signature.SignatureReader) DelegatingMethodVisitor(com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor) MethodSignatureVisitor(com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.MethodSignatureVisitor)

Aggregations

DelegatingMethodVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor)1 MethodSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.MethodSignatureVisitor)1 SignatureReader (org.objectweb.asm.signature.SignatureReader)1