Package com.buschmais.jqassistant.plugin.java.impl.store.visitor

Source Code of com.buschmais.jqassistant.plugin.java.impl.store.visitor.MethodSignatureVisitor

package com.buschmais.jqassistant.plugin.java.impl.store.visitor;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.signature.SignatureVisitor;

import com.buschmais.jqassistant.plugin.java.impl.store.descriptor.MethodDescriptor;
import com.buschmais.jqassistant.plugin.java.impl.store.descriptor.ParameterDescriptor;
import com.buschmais.jqassistant.plugin.java.impl.store.descriptor.TypeDescriptor;

/**
* Visitor for method signatures.
*/
public class MethodSignatureVisitor extends SignatureVisitor {

  private MethodDescriptor methodDescriptor;
  private VisitorHelper visitorHelper;
  private int parameterIndex = 0;

  MethodSignatureVisitor(MethodDescriptor methodDescriptor, VisitorHelper visitorHelper) {
    super(Opcodes.ASM4);
    this.methodDescriptor = methodDescriptor;
    this.visitorHelper = visitorHelper;
  }

  @Override
  public void visitFormalTypeParameter(String name) {
  }

  @Override
  public SignatureVisitor visitClassBound() {
    return new DependentTypeSignatureVisitor(methodDescriptor, visitorHelper);
  }

  @Override
  public SignatureVisitor visitInterfaceBound() {
    return new DependentTypeSignatureVisitor(methodDescriptor, visitorHelper);
  }

  @Override
  public SignatureVisitor visitSuperclass() {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public SignatureVisitor visitInterface() {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

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

      @Override
      public SignatureVisitor visitArrayType() {
        return new DependentTypeSignatureVisitor(parameterDescriptor, visitorHelper);
      }

      @Override
      public SignatureVisitor visitTypeArgument(char wildcard) {
        return new DependentTypeSignatureVisitor(parameterDescriptor, visitorHelper);
      }

      @Override
      public void visitEnd(TypeDescriptor resolvedTypeDescriptor) {
        parameterDescriptor.setType(resolvedTypeDescriptor);
      }
    };
  }

  @Override
  public SignatureVisitor visitReturnType() {
    return new AbstractTypeSignatureVisitor(methodDescriptor, visitorHelper) {

      @Override
      public SignatureVisitor visitArrayType() {
        return new DependentTypeSignatureVisitor(methodDescriptor, visitorHelper);
      }

      @Override
      public SignatureVisitor visitTypeArgument(char wildcard) {
        return new DependentTypeSignatureVisitor(methodDescriptor, visitorHelper);
      }

      @Override
      public void visitEnd(TypeDescriptor resolvedTypeDescriptor) {
        methodDescriptor.setReturns(resolvedTypeDescriptor);
      }
    };
  }

  @Override
  public SignatureVisitor visitExceptionType() {
    return new DependentTypeSignatureVisitor(methodDescriptor, visitorHelper);
  }

  @Override
  public void visitBaseType(char descriptor) {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public void visitTypeVariable(String name) {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public SignatureVisitor visitArrayType() {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public void visitClassType(String name) {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public void visitInnerClassType(String name) {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public void visitTypeArgument() {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public SignatureVisitor visitTypeArgument(char wildcard) {
    throw new UnsupportedOperationException("Method is not implemented.");
  }

  @Override
  public void visitEnd() {
  }
}
TOP

Related Classes of com.buschmais.jqassistant.plugin.java.impl.store.visitor.MethodSignatureVisitor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.