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

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

Introduction

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

Prototype

public static final boolean match(char[] pattern, char[] name, boolean isCaseSensitive) 

Source Link

Document

Answers true if the pattern matches the given name, false otherwise.

Usage

From source file:com.codenvy.ide.ext.java.server.core.search.SearchPattern.java

License:Open Source License

/**
 * Returns whether the given name matches the given pattern.
 * <p>/*from ww w  .jav  a  2s .  c  o m*/
 * This method should be re-implemented in subclasses that need to define how
 * a name matches a pattern.
 * </p>
 *
 * @param pattern the given pattern, or <code>null</code> to represent "*"
 * @param name the given name
 * @return whether the given name matches the given pattern
 */
public boolean matchesName(char[] pattern, char[] name) {
    if (pattern == null)
        return true; // null is as if it was "*"
    if (name != null) {
        boolean isCaseSensitive = (this.matchRule & R_CASE_SENSITIVE) != 0;
        int matchMode = this.matchRule & MODE_MASK;
        boolean emptyPattern = pattern.length == 0;
        if (emptyPattern && (this.matchRule & R_PREFIX_MATCH) != 0)
            return true;
        boolean sameLength = pattern.length == name.length;
        boolean canBePrefix = name.length >= pattern.length;
        boolean matchFirstChar = !isCaseSensitive || emptyPattern || (name.length > 0 && pattern[0] == name[0]);
        switch (matchMode) {
        case R_EXACT_MATCH:
            if (sameLength && matchFirstChar) {
                return CharOperation.equals(pattern, name, isCaseSensitive);
            }
            break;

        case R_PREFIX_MATCH:
            if (canBePrefix && matchFirstChar) {
                return CharOperation.prefixEquals(pattern, name, isCaseSensitive);
            }
            break;

        case R_PATTERN_MATCH:
            if (!isCaseSensitive)
                pattern = CharOperation.toLowerCase(pattern);
            return CharOperation.match(pattern, name, isCaseSensitive);

        case SearchPattern.R_CAMELCASE_MATCH:
            if (matchFirstChar && CharOperation.camelCaseMatch(pattern, name, false)) {
                return true;
            }
            // only test case insensitive as CamelCase already verified prefix case sensitive
            if (!isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(pattern, name, false)) {
                return true;
            }
            break;

        case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
            return matchFirstChar && CharOperation.camelCaseMatch(pattern, name, true);

        case R_REGEXP_MATCH:
            // TODO implement regular expression match
            return true;
        }
    }
    return false;
}

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

License:Open Source License

/**
 * Returns the package fragments whose name matches the given
 * (qualified) name or pattern, or <code>null</code> if none exist.
 * <p/>//  w w w.j  a  v  a 2s .com
 * The name can be:
 * <ul>
 * <li>empty: ""</li>
 * <li>qualified: "pack.pack1.pack2"</li>
 * <li>a pattern: "pack.*.util"</li>
 * </ul>
 *
 * @param partialMatch
 *         partial name matches qualify when <code>true</code>,
 * @param patternMatch
 *         <code>true</code> when the given name might be a pattern,
 *         <code>false</code> otherwise.
 */
public IPackageFragment[] findPackageFragments(String name, boolean partialMatch, boolean patternMatch) {
    boolean isStarPattern = name.equals("*"); //$NON-NLS-1$
    boolean hasPatternChars = isStarPattern
            || (patternMatch && (name.indexOf('*') >= 0 || name.indexOf('?') >= 0));
    if (partialMatch || hasPatternChars) {
        String[] splittedName = Util.splitOn('.', name, 0, name.length());
        IPackageFragment[] oneFragment = null;
        ArrayList pkgs = null;
        char[] lowercaseName = hasPatternChars && !isStarPattern ? name.toLowerCase().toCharArray() : null;
        Object[][] keys = this.packageFragments.keyTable;
        for (int i = 0, length = keys.length; i < length; i++) {
            String[] pkgName = (String[]) keys[i];
            if (pkgName != null) {
                boolean match = isStarPattern || (hasPatternChars
                        ? CharOperation.match(lowercaseName, Util.concatCompoundNameToCharArray(pkgName), false)
                        : Util.startsWithIgnoreCase(pkgName, splittedName, partialMatch));
                if (match) {
                    Object value = this.packageFragments.valueTable[i];
                    if (value instanceof PackageFragmentRoot) {
                        IPackageFragment pkg = ((PackageFragmentRoot) value).getPackageFragment(pkgName);
                        if (oneFragment == null) {
                            oneFragment = new IPackageFragment[] { pkg };
                        } else {
                            if (pkgs == null) {
                                pkgs = new ArrayList();
                                pkgs.add(oneFragment[0]);
                            }
                            pkgs.add(pkg);
                        }
                    } else {
                        IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) value;
                        for (int j = 0, length2 = roots.length; j < length2; j++) {
                            PackageFragmentRoot root = (PackageFragmentRoot) roots[j];
                            IPackageFragment pkg = root.getPackageFragment(pkgName);
                            if (oneFragment == null) {
                                oneFragment = new IPackageFragment[] { pkg };
                            } else {
                                if (pkgs == null) {
                                    pkgs = new ArrayList();
                                    pkgs.add(oneFragment[0]);
                                }
                                pkgs.add(pkg);
                            }
                        }
                    }
                }
            }
        }
        if (pkgs == null)
            return oneFragment;
        int resultLength = pkgs.size();
        IPackageFragment[] result = new IPackageFragment[resultLength];
        pkgs.toArray(result);
        return result;
    } else {
        String[] splittedName = Util.splitOn('.', name, 0, name.length());
        int pkgIndex = this.packageFragments.getIndex(splittedName);
        if (pkgIndex == -1)
            return null;
        Object value = this.packageFragments.valueTable[pkgIndex];
        // reuse existing String[]
        String[] pkgName = (String[]) this.packageFragments.keyTable[pkgIndex];
        if (value instanceof PackageFragmentRoot) {
            return new IPackageFragment[] { ((PackageFragmentRoot) value).getPackageFragment(pkgName) };
        } else {
            IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) value;
            IPackageFragment[] result = new IPackageFragment[roots.length];
            for (int i = 0; i < roots.length; i++) {
                result[i] = ((PackageFragmentRoot) roots[i]).getPackageFragment(pkgName);
            }
            return result;
        }
    }
}

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

License:Open Source License

boolean match(char patternTypeSuffix, char[] patternPkg, int matchRulePkg, char[] patternTypeName,
        int matchRuleType, int typeKind, char[] pkg, char[] typeName) {
    switch (patternTypeSuffix) {
    case IIndexConstants.CLASS_SUFFIX:
        if (typeKind != TypeDeclaration.CLASS_DECL)
            return false;
        break;/*from   www.  j  av  a  2  s.  c  om*/
    case IIndexConstants.CLASS_AND_INTERFACE_SUFFIX:
        if (typeKind != TypeDeclaration.CLASS_DECL && typeKind != TypeDeclaration.INTERFACE_DECL)
            return false;
        break;
    case IIndexConstants.CLASS_AND_ENUM_SUFFIX:
        if (typeKind != TypeDeclaration.CLASS_DECL && typeKind != TypeDeclaration.ENUM_DECL)
            return false;
        break;
    case IIndexConstants.INTERFACE_SUFFIX:
        if (typeKind != TypeDeclaration.INTERFACE_DECL)
            return false;
        break;
    case IIndexConstants.INTERFACE_AND_ANNOTATION_SUFFIX:
        if (typeKind != TypeDeclaration.INTERFACE_DECL && typeKind != TypeDeclaration.ANNOTATION_TYPE_DECL)
            return false;
        break;
    case IIndexConstants.ENUM_SUFFIX:
        if (typeKind != TypeDeclaration.ENUM_DECL)
            return false;
        break;
    case IIndexConstants.ANNOTATION_TYPE_SUFFIX:
        if (typeKind != TypeDeclaration.ANNOTATION_TYPE_DECL)
            return false;
        break;
    case IIndexConstants.TYPE_SUFFIX: // nothing
    }

    boolean isPkgCaseSensitive = (matchRulePkg & SearchPattern.R_CASE_SENSITIVE) != 0;
    if (patternPkg != null && !CharOperation.equals(patternPkg, pkg, isPkgCaseSensitive))
        return false;

    boolean isCaseSensitive = (matchRuleType & SearchPattern.R_CASE_SENSITIVE) != 0;
    if (patternTypeName != null) {
        boolean isCamelCase = (matchRuleType
                & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
        int matchMode = matchRuleType & JavaSearchPattern.MATCH_MODE_MASK;
        if (!isCaseSensitive && !isCamelCase) {
            patternTypeName = CharOperation.toLowerCase(patternTypeName);
        }
        boolean matchFirstChar = !isCaseSensitive || patternTypeName[0] == typeName[0];
        switch (matchMode) {
        case SearchPattern.R_EXACT_MATCH:
            return matchFirstChar && CharOperation.equals(patternTypeName, typeName, isCaseSensitive);
        case SearchPattern.R_PREFIX_MATCH:
            return matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, isCaseSensitive);
        case SearchPattern.R_PATTERN_MATCH:
            return CharOperation.match(patternTypeName, typeName, isCaseSensitive);
        case SearchPattern.R_REGEXP_MATCH:
            // TODO (frederic) implement regular expression match
            break;
        case SearchPattern.R_CAMELCASE_MATCH:
            if (matchFirstChar && CharOperation.camelCaseMatch(patternTypeName, typeName, false)) {
                return true;
            }
            return !isCaseSensitive && matchFirstChar
                    && CharOperation.prefixEquals(patternTypeName, typeName, false);
        case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
            return matchFirstChar && CharOperation.camelCaseMatch(patternTypeName, typeName, true);
        }
    }
    return true;

}

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

License:Open Source License

private boolean checkTypeName(char[] simpleName, char[] qualification, char[] fullyQualifiedTypeName,
        boolean isCaseSensitive, boolean isCamelCase) {
    // NOTE: if case insensitive then simpleName & qualification are assumed to be lowercase
    char[] wildcardPattern = PatternLocator.qualifiedPattern(simpleName, qualification);
    if (wildcardPattern == null)
        return true;
    return CharOperation.match(wildcardPattern, fullyQualifiedTypeName, isCaseSensitive);
}

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

License:Open Source License

protected int matchMethod(MethodBinding method, boolean skipImpossibleArg) {
    if (!matchesName(this.pattern.selector, method.selector))
        return IMPOSSIBLE_MATCH;

    int level = ACCURATE_MATCH;
    // look at return type only if declaring type is not specified
    if (this.pattern.declaringSimpleName == null) {
        // TODO (frederic) use this call to refine accuracy on return type
        // int newLevel = resolveLevelForType(this.pattern.returnSimpleName, this.pattern.returnQualification, this.pattern.returnTypeArguments, 0, method.returnType);
        int newLevel = resolveLevelForType(this.pattern.returnSimpleName, this.pattern.returnQualification,
                method.returnType);/*  www  .  j  a  va 2s . c om*/
        if (level > newLevel) {
            if (newLevel == IMPOSSIBLE_MATCH)
                return IMPOSSIBLE_MATCH;
            level = newLevel; // can only be downgraded
        }
    }

    // parameter types
    int parameterCount = this.pattern.parameterSimpleNames == null ? -1
            : this.pattern.parameterSimpleNames.length;
    if (parameterCount > -1) {
        // global verification
        if (method.parameters == null)
            return INACCURATE_MATCH;
        if (parameterCount != method.parameters.length)
            return IMPOSSIBLE_MATCH;
        if (!method.isValidBinding()
                && ((ProblemMethodBinding) method).problemId() == ProblemReasons.Ambiguous) {
            // return inaccurate match for ambiguous call (bug 80890)
            return INACCURATE_MATCH;
        }
        boolean foundTypeVariable = false;
        // verify each parameter
        for (int i = 0; i < parameterCount; i++) {
            TypeBinding argType = method.parameters[i];
            int newLevel = IMPOSSIBLE_MATCH;
            if (argType.isMemberType()) {
                // only compare source name for member type (bug 41018)
                newLevel = CharOperation.match(this.pattern.parameterSimpleNames[i], argType.sourceName(),
                        this.isCaseSensitive) ? ACCURATE_MATCH : IMPOSSIBLE_MATCH;
            } else {
                // TODO (frederic) use this call to refine accuracy on parameter types
                //             newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i], this.pattern.parameterQualifications[i], this.pattern.parametersTypeArguments[i], 0, argType);
                newLevel = resolveLevelForType(this.pattern.parameterSimpleNames[i],
                        this.pattern.parameterQualifications[i], argType);
            }
            if (level > newLevel) {
                if (newLevel == IMPOSSIBLE_MATCH) {
                    if (skipImpossibleArg) {
                        // Do not consider match as impossible while finding declarations and source level >= 1.5
                        // (see  bugs https://bugs.eclipse.org/bugs/show_bug.cgi?id=79990, 96761, 96763)
                        newLevel = level;
                    } else if (argType.isTypeVariable()) {
                        newLevel = level;
                        foundTypeVariable = true;
                    } else {
                        return IMPOSSIBLE_MATCH;
                    }
                }
                level = newLevel; // can only be downgraded
            }
        }
        if (foundTypeVariable) {
            if (!method.isStatic() && !method.isPrivate()) {
                // https://bugs.eclipse.org/bugs/show_bug.cgi?id=123836, No point in textually comparing type variables, captures etc with concrete types.
                MethodBinding focusMethodBinding = this.matchLocator.getMethodBinding(this.pattern);
                if (focusMethodBinding != null) {
                    if (matchOverriddenMethod(focusMethodBinding.declaringClass, focusMethodBinding, method)) {
                        return ACCURATE_MATCH;
                    }
                }
            }
            return IMPOSSIBLE_MATCH;
        }
    }

    return level;
}

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

License:Open Source License

private boolean methodParametersEqualsPattern(MethodBinding method) {
    TypeBinding[] methodParameters = method.parameters;

    int length = methodParameters.length;
    if (length != this.pattern.parameterSimpleNames.length)
        return false;

    for (int i = 0; i < length; i++) {
        char[] paramQualifiedName = qualifiedPattern(this.pattern.parameterSimpleNames[i],
                this.pattern.parameterQualifications[i]);
        if (!CharOperation.match(paramQualifiedName, methodParameters[i].readableName(),
                this.isCaseSensitive)) {
            return false;
        }//from ww w.  j  a  va 2 s .  com
    }
    return true;
}

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

License:Open Source License

protected int matchLevelForTokens(char[][] tokens) {
    if (this.pattern.pkgName == null)
        return ACCURATE_MATCH;

    switch (this.matchMode) {
    case SearchPattern.R_EXACT_MATCH:
    case SearchPattern.R_PREFIX_MATCH:
        if (CharOperation.prefixEquals(this.pattern.pkgName, CharOperation.concatWith(tokens, '.'),
                this.isCaseSensitive)) {
            return POSSIBLE_MATCH;
        }/*from   w  w w  .j av  a2 s . c  o m*/
        break;

    case SearchPattern.R_PATTERN_MATCH:
        char[] patternName = this.pattern.pkgName[this.pattern.pkgName.length - 1] == '*' ? this.pattern.pkgName
                : CharOperation.concat(this.pattern.pkgName, ".*".toCharArray()); //$NON-NLS-1$
        if (CharOperation.match(patternName, CharOperation.concatWith(tokens, '.'), this.isCaseSensitive)) {
            return POSSIBLE_MATCH;
        }
        break;

    case SearchPattern.R_REGEXP_MATCH:
        // TODO (frederic) implement regular expression match
        break;

    case SearchPattern.R_CAMELCASE_MATCH:
        char[] packageName = CharOperation.concatWith(tokens, '.');
        if (CharOperation.camelCaseMatch(this.pattern.pkgName, packageName, false)) {
            return POSSIBLE_MATCH;
        }
        // only test case insensitive as CamelCase already verified prefix case sensitive
        if (!this.isCaseSensitive && CharOperation.prefixEquals(this.pattern.pkgName, packageName, false)) {
            return POSSIBLE_MATCH;
        }
        break;

    case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
        if (CharOperation.camelCaseMatch(this.pattern.pkgName, CharOperation.concatWith(tokens, '.'), true)) {
            return POSSIBLE_MATCH;
        }
        break;
    }
    return IMPOSSIBLE_MATCH;
}

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

License:Open Source License

/**
 * Return how the given name matches the given pattern.
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=79866"
 *
 * @param pattern/*from   www . j  a  v a  2 s.  c  om*/
 * @param name
 * @return Possible values are:
 * <ul>
 *    <li> {@link #ACCURATE_MATCH}</li>
 *    <li> {@link #IMPOSSIBLE_MATCH}</li>
 *    <li> {@link #POSSIBLE_MATCH} which may be flavored with following values:
 *       <ul>
 *       <li>{@link #EXACT_FLAVOR}: Given name is equals to pattern</li>
 *       <li>{@link #PREFIX_FLAVOR}: Given name prefix equals to pattern</li>
 *       <li>{@link #CAMELCASE_FLAVOR}: Given name matches pattern as Camel Case</li>
 *       <li>{@link #PATTERN_FLAVOR}: Given name matches pattern as Pattern (i.e. using '*' and '?' characters)</li>
 *       </ul>
 *    </li>
 * </ul>
 */
protected int matchNameValue(char[] pattern, char[] name) {
    if (pattern == null)
        return ACCURATE_MATCH; // null is as if it was "*"
    if (name == null)
        return IMPOSSIBLE_MATCH; // cannot match null name
    if (name.length == 0) { // empty name
        if (pattern.length == 0) { // can only matches empty pattern
            return ACCURATE_MATCH;
        }
        return IMPOSSIBLE_MATCH;
    } else if (pattern.length == 0) {
        return IMPOSSIBLE_MATCH; // need to have both name and pattern length==0 to be accurate
    }
    boolean matchFirstChar = !this.isCaseSensitive || pattern[0] == name[0];
    boolean sameLength = pattern.length == name.length;
    boolean canBePrefix = name.length >= pattern.length;
    switch (this.matchMode) {
    case SearchPattern.R_EXACT_MATCH:
        if (sameLength && matchFirstChar && CharOperation.equals(pattern, name, this.isCaseSensitive)) {
            return POSSIBLE_MATCH | EXACT_FLAVOR;
        }
        break;

    case SearchPattern.R_PREFIX_MATCH:
        if (canBePrefix && matchFirstChar && CharOperation.prefixEquals(pattern, name, this.isCaseSensitive)) {
            return POSSIBLE_MATCH;
        }
        break;

    case SearchPattern.R_PATTERN_MATCH:
        // TODO_PERFS (frederic) Not sure this lowercase is necessary
        if (!this.isCaseSensitive) {
            pattern = CharOperation.toLowerCase(pattern);
        }
        if (CharOperation.match(pattern, name, this.isCaseSensitive)) {
            return POSSIBLE_MATCH;
        }
        break;

    case SearchPattern.R_REGEXP_MATCH:
        // TODO (frederic) implement regular expression match
        break;

    case SearchPattern.R_CAMELCASE_MATCH:
        if (CharOperation.camelCaseMatch(pattern, name, false)) {
            return POSSIBLE_MATCH;
        }
        // only test case insensitive as CamelCase same part count already verified prefix case sensitive
        if (!this.isCaseSensitive && CharOperation.prefixEquals(pattern, name, false)) {
            return POSSIBLE_MATCH;
        }
        break;

    case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
        if (CharOperation.camelCaseMatch(pattern, name, true)) {
            return POSSIBLE_MATCH;
        }
        break;
    }
    return IMPOSSIBLE_MATCH;
}

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

License:Open Source License

/**
 * Returns whether the given type binding matches the given simple name pattern
 * and qualification pattern./*  ww  w.  j  a  va  2 s.  co m*/
 * Note that from since 3.1, this method resolve to accurate member or local types
 * even if they are not fully qualified (i.e. X.Member instead of p.X.Member).
 * Returns ACCURATE_MATCH if it does.
 * Returns INACCURATE_MATCH if resolve failed.
 * Returns IMPOSSIBLE_MATCH if it doesn't.
 */
protected int resolveLevelForType(char[] simpleNamePattern, char[] qualificationPattern, TypeBinding binding) {
    //   return resolveLevelForType(qualifiedPattern(simpleNamePattern, qualificationPattern), type);
    char[] qualifiedPattern = getQualifiedPattern(simpleNamePattern, qualificationPattern);
    int level = resolveLevelForType(qualifiedPattern, binding);
    if (level == ACCURATE_MATCH || binding == null || !binding.isValidBinding())
        return level;
    TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding) binding).leafComponentType : binding;
    char[] sourceName = null;
    if (type.isMemberType() || type.isLocalType()) {
        if (qualificationPattern != null) {
            sourceName = getQualifiedSourceName(binding);
        } else {
            sourceName = binding.sourceName();
        }
    } else if (qualificationPattern == null) {
        sourceName = getQualifiedSourceName(binding);
    }
    if (sourceName == null)
        return IMPOSSIBLE_MATCH;
    switch (this.matchMode) {
    case SearchPattern.R_PREFIX_MATCH:
        if (CharOperation.prefixEquals(qualifiedPattern, sourceName, this.isCaseSensitive)) {
            return ACCURATE_MATCH;
        }
        break;
    case SearchPattern.R_CAMELCASE_MATCH:
        if ((qualifiedPattern.length > 0 && sourceName.length > 0 && qualifiedPattern[0] == sourceName[0])) {
            if (CharOperation.camelCaseMatch(qualifiedPattern, sourceName, false)) {
                return ACCURATE_MATCH;
            }
            if (!this.isCaseSensitive && CharOperation.prefixEquals(qualifiedPattern, sourceName, false)) {
                return ACCURATE_MATCH;
            }
        }
        break;
    case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
        if ((qualifiedPattern.length > 0 && sourceName.length > 0 && qualifiedPattern[0] == sourceName[0])) {
            if (CharOperation.camelCaseMatch(qualifiedPattern, sourceName, true)) {
                return ACCURATE_MATCH;
            }
        }
        break;
    default:
        if (CharOperation.match(qualifiedPattern, sourceName, this.isCaseSensitive)) {
            return ACCURATE_MATCH;
        }
    }
    return IMPOSSIBLE_MATCH;
}

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

License:Open Source License

/**
 * Returns whether the given type binding matches the given qualified pattern.
 * Returns ACCURATE_MATCH if it does.// w  ww.  ja  v  a2s  .  c  o  m
 * Returns INACCURATE_MATCH if resolve failed.
 * Returns IMPOSSIBLE_MATCH if it doesn't.
 */
protected int resolveLevelForType(char[] qualifiedPattern, TypeBinding type) {
    if (qualifiedPattern == null)
        return ACCURATE_MATCH;
    if (type == null || !type.isValidBinding())
        return INACCURATE_MATCH;

    // Type variable cannot be specified through pattern => this kind of binding cannot match it (see bug 79803)
    if (type.isTypeVariable())
        return IMPOSSIBLE_MATCH;

    // NOTE: if case insensitive search then qualifiedPattern is assumed to be lowercase

    char[] qualifiedPackageName = type.qualifiedPackageName();
    char[] qualifiedSourceName = qualifiedSourceName(type);
    char[] fullyQualifiedTypeName = qualifiedPackageName.length == 0 ? qualifiedSourceName
            : CharOperation.concat(qualifiedPackageName, qualifiedSourceName, '.');
    return CharOperation.match(qualifiedPattern, fullyQualifiedTypeName, this.isCaseSensitive) ? ACCURATE_MATCH
            : IMPOSSIBLE_MATCH;
}