Example usage for org.eclipse.jdt.core.compiler CharOperation endsWith

List of usage examples for org.eclipse.jdt.core.compiler CharOperation endsWith

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler CharOperation endsWith.

Prototype

public static final boolean endsWith(char[] array, char[] toBeFound) 

Source Link

Document

Return true if array ends with the sequence of characters contained in toBeFound, otherwise false.

Usage

From source file:com.codenvy.ide.ext.java.server.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 ww.ja  v  a 2  s  . c o  m
                    }
                    return (IMethod) createMethodHandle(type, new String(selector),
                            CharOperation.toStrings(parameterTypes));
                }
            }
        }
    }
    return null;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.SuperTypeNamesCollector.java

License:Open Source License

protected boolean matches(char[][] compoundName) {
    int length = compoundName.length;
    if (length == 0)
        return false;
    char[] simpleName = compoundName[length - 1];
    int last = length - 1;
    if (this.typeSimpleName == null || this.pattern.matchesName(simpleName, this.typeSimpleName)) {
        // most frequent case: simple name equals last segment of compoundName
        char[][] qualification = new char[last][];
        System.arraycopy(compoundName, 0, qualification, 0, last);
        return this.pattern.matchesName(this.typeQualification, CharOperation.concatWith(qualification, '.'));
    }/*from   w  w w . j a v  a 2s.co m*/

    if (!CharOperation.endsWith(simpleName, this.typeSimpleName))
        return false;

    // member type -> transform A.B.C$D into A.B.C.D
    System.arraycopy(compoundName, 0, compoundName = new char[length + 1][], 0, last);
    int dollar = CharOperation.indexOf('$', simpleName);
    if (dollar == -1)
        return false;
    compoundName[last] = CharOperation.subarray(simpleName, 0, dollar);
    compoundName[length] = CharOperation.subarray(simpleName, dollar + 1, simpleName.length);
    return this.matches(compoundName);
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java

License:Open Source License

private static boolean isStaticBasecallSurrogate(MethodBinding refMethodBinding) {
    return CharOperation.endsWith(refMethodBinding.selector, "$base".toCharArray()) //$NON-NLS-1$
            && !refMethodBinding.declaringClass.isRole(); // regular base call surrogates are role methods.
    // if it's not a role method, the callin must be static.
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java

License:Open Source License

private MethodBinding getMethodRef(int index) {
    int start = getConstantPoolStartPosition(index);
    assert (u1At(start) == MethodRefTag);
    int class_index = u2At(start + 1);
    int name_index = u2At(start + 3);
    ReferenceBinding class_rb = getClassBinding(class_index);
    // deactivated, see below. ReferenceBinding actualReceiver = class_rb;
    if (class_rb == null)
        return null;

    char[][] nameandtype = getNameAndType(name_index);
    char[] name = nameandtype[0];
    char[] type = nameandtype[1];
    MethodBinding mb = findMethodBinding(class_rb, name, type);

    // Note: donot revert to actual receiver, because the linkage of
    //       copyInheritanceSrc will otherwise be broken!
    if (mb == null && CharOperation.endsWith(name, IOTConstants._OT_TAG)) {
        // This method is faked within the compiler, will be added by the OTRE.
        return new MethodBinding(ClassFileConstants.AccPublic, name, TypeBinding.SHORT, Binding.NO_PARAMETERS,
                Binding.NO_EXCEPTIONS, class_rb);
    }/*  ww w  . j a v a 2 s .  c  om*/
    assert (mb != null);
    return mb;

}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.MethodSignatureEnhancer.java

License:Open Source License

private boolean internalIsEnhanced(AbstractMethodDeclaration methodDeclaration) {
    Argument[] arguments = methodDeclaration.arguments;
    if (arguments == null || arguments.length < this.ENHANCING_ARG_LEN)
        return false;
    for (int i = 0; i < this.ENHANCING_ARG_LEN; i++) {
        if (!CharOperation.endsWith(arguments[i].name, this.ENHANCING_ARG_NAMES[i]))
            return false;
    }//from  ww  w  .  ja  va  2s  .  com
    return true;
}

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  w  w.  j  ava 2  s .  co m

    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;
}