Example usage for org.eclipse.jdt.internal.core.util Util typeSignature

List of usage examples for org.eclipse.jdt.internal.core.util Util typeSignature

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Util typeSignature.

Prototype

public static String typeSignature(TypeReference type) 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.util.ASTNodeFinder.java

License:Open Source License

public AbstractMethodDeclaration findMethod(IMethod methodHandle) {
    TypeDeclaration typeDecl = findType((IType) methodHandle.getParent());
    if (typeDecl == null)
        return null;
    AbstractMethodDeclaration[] methods = typeDecl.methods;
    if (methods != null) {
        char[] selector = methodHandle.getElementName().toCharArray();
        String[] parameterTypeSignatures = methodHandle.getParameterTypes();
        int parameterCount = parameterTypeSignatures.length;
        nextMethod: for (int i = 0, length = methods.length; i < length; i++) {
            AbstractMethodDeclaration method = methods[i];
            if (CharOperation.equals(selector, method.selector)) {
                Argument[] args = method.arguments;
                int argsLength = args == null ? 0 : args.length;
                if (argsLength == parameterCount) {
                    for (int j = 0; j < parameterCount; j++) {
                        TypeReference type = args[j].type;
                        String signature = Util.typeSignature(type);
                        if (!signature.equals(parameterTypeSignatures[j])) {
                            continue nextMethod;
                        }/*from w  ww  . jav a2s  .  co  m*/
                    }
                    return method;
                }
            }
        }
    }
    return null;
}