Example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants CLONE

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants CLONE

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants CLONE.

Prototype

null CLONE

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants CLONE.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java

License:Open Source License

public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes,
        InvocationSite invocationSite) {

    TypeBinding leafType = receiverType.leafComponentType();
    if (leafType instanceof ReferenceBinding) {
        if (!((ReferenceBinding) leafType).canBeSeenBy(this))
            return new ProblemMethodBinding(selector, Binding.NO_PARAMETERS, (ReferenceBinding) leafType,
                    ProblemReasons.ReceiverTypeNotVisible);
    }/* ww  w .  j a v  a2 s  .  co m*/

    ReferenceBinding object = getJavaLangObject();
    MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
    if (methodBinding != null) {
        // handle the method clone() specially... cannot be protected or throw exceptions
        if (argumentTypes == Binding.NO_PARAMETERS) {
            switch (selector[0]) {
            case 'c':
                if (CharOperation.equals(selector, TypeConstants.CLONE)) {
                    return environment().computeArrayClone(methodBinding);
                }
                break;
            case 'g':
                if (CharOperation.equals(selector, TypeConstants.GETCLASS)
                        && methodBinding.returnType.isParameterizedType()/*1.5*/) {
                    return environment().createGetClassMethod(receiverType, methodBinding, this);
                }
                break;
            }
        }
        if (methodBinding.canBeSeenBy(receiverType, invocationSite, this))
            return methodBinding;
    }
    methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
    if (methodBinding == null)
        return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
    return methodBinding;
}

From source file:org.eclipse.recommenders.completion.rcp.utils.ProposalUtils.java

License:Open Source License

private static boolean isArrayCloneMethod(CompletionProposal proposal) {
    if (proposal.isConstructor()) {
        // Not a method proposal
        return false;
    }/*from w ww  . j  av a2s.  c  om*/

    char[] declarationSignature = proposal.getDeclarationSignature();
    if (declarationSignature[0] != '[') {
        // Not an array
        return false;
    }

    if (!CharOperation.equals(TypeConstants.CLONE, proposal.getName())) {
        // Not named clone
        return false;
    }

    char[] signature = proposal.getSignature();
    if (signature.length != declarationSignature.length + 2 || signature[0] != '(' || signature[1] != ')') {
        // Overload of real (no-args) clone method
        return false;
    }

    if (!CharOperation.endsWith(signature, declarationSignature)) {
        // Wrong return type
        return false;
    }

    return true;
}