Example usage for org.eclipse.jdt.internal.core.search.matching ClassFileMatchLocator convertClassFileFormat

List of usage examples for org.eclipse.jdt.internal.core.search.matching ClassFileMatchLocator convertClassFileFormat

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.search.matching ClassFileMatchLocator convertClassFileFormat.

Prototype

public static char[] convertClassFileFormat(char[] name) 

Source Link

Usage

From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

IMethod createBinaryMethodHandle(IType type, char[] methodSelector, char[][] argumentTypeNames) {
    ClassFileReader reader = MatchLocator.classFileReader(type);
    if (reader != null) {
        IBinaryMethod[] methods = reader.getMethods();
        if (methods != null) {
            int argCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
            nextMethod: for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
                IBinaryMethod binaryMethod = methods[i];
                char[] selector = binaryMethod.isConstructor() ? type.getElementName().toCharArray()
                        : binaryMethod.getSelector();
                if (CharOperation.equals(selector, methodSelector)) {
                    char[] signature = binaryMethod.getGenericSignature();
                    if (signature == null)
                        signature = binaryMethod.getMethodDescriptor();
                    char[][] parameterTypes = Signature.getParameterTypes(signature);
                    if (argCount != parameterTypes.length)
                        continue nextMethod;
                    if (argumentTypeNames != null) {
                        for (int j = 0; j < argCount; j++) {
                            char[] parameterTypeName = ClassFileMatchLocator
                                    .convertClassFileFormat(parameterTypes[j]);
                            if (!CharOperation.endsWith(
                                    Signature.toCharArray(Signature.getTypeErasure(parameterTypeName)),
                                    CharOperation.replaceOnCopy(argumentTypeNames[j], '$', '.')))
                                continue nextMethod;
                            parameterTypes[j] = parameterTypeName;
                        }/*from w  w  w  .  ja  v  a 2 s .c  om*/
                    }
                    return (IMethod) createMethodHandle(type, new String(selector),
                            CharOperation.toStrings(parameterTypes));
                }
            }
        }
    }
    return null;
}