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

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

Introduction

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

Prototype

public static final int compareWith(char[] array, char[] prefix) 

Source Link

Document

Compares the contents of the two arrays array and prefix.

Usage

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

License:Open Source License

public int resolveLevel(Binding binding) {
    if (binding == null)
        return INACCURATE_MATCH;
    if (!(binding instanceof MethodBinding))
        return IMPOSSIBLE_MATCH;

    MethodBinding method = (MethodBinding) binding;
    boolean skipVerif = this.pattern.findDeclarations && this.mayBeGeneric;
    int methodLevel = matchMethod(method, skipVerif);
    if (methodLevel == IMPOSSIBLE_MATCH) {
        if (method != method.original())
            methodLevel = matchMethod(method.original(), skipVerif);
        if (methodLevel == IMPOSSIBLE_MATCH) {
            return IMPOSSIBLE_MATCH;
        } else {/*  w  w  w . j  ava  2  s. c  o  m*/
            method = method.original();
        }
    }

    // declaring type
    if (this.pattern.declaringSimpleName == null && this.pattern.declaringQualification == null)
        return methodLevel; // since any declaring class will do

    boolean subType = !method.isStatic() && !method.isPrivate();
    if (subType && this.pattern.declaringQualification != null && method.declaringClass != null
            && method.declaringClass.fPackage != null) {
        subType = CharOperation.compareWith(this.pattern.declaringQualification,
                method.declaringClass.fPackage.shortReadableName()) == 0;
    }
    int declaringLevel = subType
            ? resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification,
                    method.declaringClass, method.selector, null, method.declaringClass.qualifiedPackageName(),
                    method.isDefault())
            : resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification,
                    method.declaringClass);
    return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel
            : methodLevel; // return the weaker match
}

From source file:org.eclipse.ajdt.internal.core.search.ExtraPackageReferenceFinder.java

License:Open Source License

protected boolean isMatch(IntertypeElement itd, PackageReferencePattern pattern) {
    ensurePkgNames(pattern);/* w w w  .  j ava 2 s.c om*/
    return pkgNames != null && CharOperation.compareWith(itd.getTargetTypeName().toCharArray(), pkgNames) == 0;
}

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

License:Open Source License

public int resolveLevel(Binding binding) {
    if (binding == null)
        return INACCURATE_MATCH;
    if (!(binding instanceof MethodBinding))
        return IMPOSSIBLE_MATCH;

    MethodBinding method = (MethodBinding) binding;
    boolean skipVerif = this.pattern.findDeclarations && this.mayBeGeneric;
    int methodLevel = matchMethod(method, skipVerif);
    if (methodLevel == IMPOSSIBLE_MATCH) {
        if (method != method.original())
            methodLevel = matchMethod(method.original(), skipVerif);
        if (methodLevel == IMPOSSIBLE_MATCH) {
            return IMPOSSIBLE_MATCH;
        } else {//from w ww.j  a  v  a  2s. c om
            method = method.original();
        }
    }

    // declaring type
    if (this.pattern.declaringSimpleName == null && this.pattern.declaringQualification == null)
        return methodLevel; // since any
    // declaring class will do

    boolean subType = !method.isStatic() && !method.isPrivate();
    if (subType && this.pattern.declaringQualification != null && method.declaringClass != null
            && method.declaringClass.fPackage != null) {
        subType = CharOperation.compareWith(this.pattern.declaringQualification,
                method.declaringClass.fPackage.shortReadableName()) == 0;
    }
    int declaringLevel = subType
            ? resolveLevelAsSubtype(this.pattern.declaringSimpleName, this.pattern.declaringQualification,
                    method.declaringClass, method.selector, null, method.declaringClass.qualifiedPackageName(),
                    method.isDefault())
            : resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification,
                    method.declaringClass);
    return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel
            : methodLevel; // return the weaker match
}