<s> package org . eclipse . jdt . internal . core . search . matching ; import org . eclipse . core . runtime . * ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . core . search . indexing . IIndexConstants ; public abstract class PatternLocator implements IIndexConstants { protected int matchMode ; protected boolean isCaseSensitive ; protected boolean isEquivalentMatch ; protected boolean isErasureMatch ; protected boolean mustResolve ; protected boolean mayBeGeneric ; SearchMatch match = null ; public static final int IMPOSSIBLE_MATCH = 0 ; public static final int INACCURATE_MATCH = 1 ; public static final int POSSIBLE_MATCH = 2 ; public static final int ACCURATE_MATCH = 3 ; public static final int ERASURE_MATCH = 4 ; int flavors = 0 ; public static final int NO_FLAVOR = 0x0000 ; public static final int EXACT_FLAVOR = 0x0010 ; public static final int PREFIX_FLAVOR = 0x0020 ; public static final int PATTERN_FLAVOR = 0x0040 ; public static final int REGEXP_FLAVOR = 0x0080 ; public static final int CAMELCASE_FLAVOR = 0x0100 ; public static final int SUPER_INVOCATION_FLAVOR = 0x0200 ; public static final int SUB_INVOCATION_FLAVOR = 0x0400 ; public static final int OVERRIDDEN_METHOD_FLAVOR = 0x0800 ; public static final int SUPERTYPE_REF_FLAVOR = 0x1000 ; public static final int MATCH_LEVEL_MASK = 0x0F ; public static final int FLAVORS_MASK = ~ MATCH_LEVEL_MASK ; public static final int COMPILATION_UNIT_CONTAINER = 1 ; public static final int CLASS_CONTAINER = 2 ; public static final int METHOD_CONTAINER = 4 ; public static final int FIELD_CONTAINER = 8 ; public static final int ALL_CONTAINER = COMPILATION_UNIT_CONTAINER | CLASS_CONTAINER | METHOD_CONTAINER | FIELD_CONTAINER ; public static final int RAW_MASK = SearchPattern . R_EQUIVALENT_MATCH | SearchPattern . R_ERASURE_MATCH ; public static final int RULE_MASK = RAW_MASK ; public static PatternLocator patternLocator ( SearchPattern pattern ) { switch ( pattern . kind ) { case IIndexConstants . PKG_REF_PATTERN : return new PackageReferenceLocator ( ( PackageReferencePattern ) pattern ) ; case IIndexConstants . PKG_DECL_PATTERN : return new PackageDeclarationLocator ( ( PackageDeclarationPattern ) pattern ) ; case IIndexConstants . TYPE_REF_PATTERN : return new TypeReferenceLocator ( ( TypeReferencePattern ) pattern ) ; case IIndexConstants . TYPE_DECL_PATTERN : return new TypeDeclarationLocator ( ( TypeDeclarationPattern ) pattern ) ; case IIndexConstants . SUPER_REF_PATTERN : return new SuperTypeReferenceLocator ( ( SuperTypeReferencePattern ) pattern ) ; case IIndexConstants . CONSTRUCTOR_PATTERN : return new ConstructorLocator ( ( ConstructorPattern ) pattern ) ; case IIndexConstants . FIELD_PATTERN : return new FieldLocator ( ( FieldPattern ) pattern ) ; case IIndexConstants . METHOD_PATTERN : return new MethodLocator ( ( MethodPattern ) pattern ) ; case IIndexConstants . OR_PATTERN : return new OrLocator ( ( OrPattern ) pattern ) ; case IIndexConstants . AND_PATTERN : return new AndLocator ( ( AndPattern ) pattern ) ; case IIndexConstants . LOCAL_VAR_PATTERN : return new LocalVariableLocator ( ( LocalVariablePattern ) pattern ) ; case IIndexConstants . TYPE_PARAM_PATTERN : return new TypeParameterLocator ( ( TypeParameterPattern ) pattern ) ; } return null ; } public static char [ ] qualifiedPattern ( char [ ] simpleNamePattern , char [ ] qualificationPattern ) { if ( simpleNamePattern == null ) { if ( qualificationPattern == null ) return null ; return CharOperation . concat ( qualificationPattern , ONE_STAR , '.' ) ; } else { return qualificationPattern == null ? CharOperation . concat ( ONE_STAR , simpleNamePattern ) : CharOperation . concat ( qualificationPattern , simpleNamePattern , '.' ) ; } } public static char [ ] qualifiedSourceName ( TypeBinding binding ) { if ( binding instanceof ReferenceBinding ) { ReferenceBinding type = ( ReferenceBinding ) binding ; if ( type . isLocalType ( ) ) return type . isMemberType ( ) ? CharOperation . concat ( qualifiedSourceName ( type . enclosingType ( ) ) , type . sourceName ( ) , '.' ) : CharOperation . concat ( qualifiedSourceName ( type . enclosingType ( ) ) , new char [ ] { '.' , '1' , '.' } , type . sourceName ( ) ) ; } return binding != null ? binding . qualifiedSourceName ( ) : null ; } public PatternLocator ( SearchPattern pattern ) { int matchRule = pattern . getMatchRule ( ) ; this . isCaseSensitive = ( matchRule & SearchPattern . R_CASE_SENSITIVE ) != 0 ; this . isErasureMatch = ( matchRule & SearchPattern . R_ERASURE_MATCH ) != 0 ; this . isEquivalentMatch = ( matchRule & SearchPattern . R_EQUIVALENT_MATCH ) != 0 ; this . matchMode = matchRule & JavaSearchPattern . MATCH_MODE_MASK ; this . mustResolve = pattern . mustResolve ; } protected void clear ( ) { } protected char [ ] getQualifiedPattern ( char [ ] simpleNamePattern , char [ ] qualificationPattern ) { if ( simpleNamePattern == null ) { if ( qualificationPattern == null ) return null ; return CharOperation . concat ( qualificationPattern , ONE_STAR , '.' ) ; } else if ( qualificationPattern == null ) { return simpleNamePattern ; } else { return CharOperation . concat ( qualificationPattern , simpleNamePattern , '.' ) ; } } protected char [ ] getQualifiedSourceName ( TypeBinding binding ) { TypeBinding type = binding instanceof ArrayBinding ? ( ( ArrayBinding ) binding ) . leafComponentType : binding ; if ( type instanceof ReferenceBinding ) { if ( type . isLocalType ( ) ) { return CharOperation . concat ( qualifiedSourceName ( type . enclosingType ( ) ) , new char [ ] { '.' , '1' , '.' } , binding . sourceName ( ) ) ; } else if ( type . isMemberType ( ) ) { return CharOperation . concat ( qualifiedSourceName ( type . enclosingType ( ) ) , binding . sourceName ( ) , '.' ) ; } } return binding != null ? binding . qualifiedSourceName ( ) : null ; } protected TypeBinding getTypeNameBinding ( int index ) { return null ; } public void initializePolymorphicSearch ( MatchLocator locator ) { } public int match ( Annotation node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( ASTNode node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( ConstructorDeclaration node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( Expression node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( FieldDeclaration node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( LocalDeclaration node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( MethodDeclaration node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( MemberValuePair node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( MessageSend node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( Reference node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( TypeDeclaration node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( TypeParameter node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } public int match ( TypeReference node , MatchingNodeSet nodeSet ) { return IMPOSSIBLE_MATCH ; } protected int matchContainer ( ) { return ALL_CONTAINER ; } protected int fineGrain ( ) { return 0 ; } protected boolean matchesName ( char [ ] pattern , char [ ] name ) { if ( pattern == null ) return true ; if ( name == null ) return false ; return matchNameValue ( pattern , name ) != IMPOSSIBLE_MATCH ; } protected int matchNameValue ( char [ ] pattern , char [ ] name ) { if ( pattern == null ) return ACCURATE_MATCH ; if ( name == null ) return IMPOSSIBLE_MATCH ; if ( name . length == 0 ) { if ( pattern . length == 0 ) { return ACCURATE_MATCH ; } return IMPOSSIBLE_MATCH ; } else if ( pattern . length == 0 ) { return IMPOSSIBLE_MATCH ; } 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 : if ( ! this . isCaseSensitive ) { pattern = CharOperation . toLowerCase ( pattern ) ; } if ( CharOperation . match ( pattern , name , this . isCaseSensitive ) ) { return POSSIBLE_MATCH ; } break ; case SearchPattern . R_REGEXP_MATCH : break ; case SearchPattern . R_CAMELCASE_MATCH : if ( CharOperation . camelCaseMatch ( pattern , name , false ) ) { return POSSIBLE_MATCH ; } 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 ; } protected boolean matchesTypeReference ( char [ ] pattern , TypeReference type ) { if ( pattern == null ) return true ; if ( type == null ) return true ; char [ ] [ ] compoundName = type . getTypeName ( ) ; char [ ] simpleName = compoundName [ compoundName . length - 1 ] ; int dimensions = type . dimensions ( ) * 2 ; if ( dimensions > 0 ) { int length = simpleName . length ; char [ ] result = new char [ length + dimensions ] ; System . arraycopy ( simpleName , 0 , result , 0 , length ) ; for ( int i = length , l = result . length ; i < l ; ) { result [ i ++ ] = '[' ; result [ i ++ ] = ']' ; } simpleName = result ; } return matchesName ( pattern , simpleName ) ; } protected int matchLevel ( ImportReference importRef ) { return IMPOSSIBLE_MATCH ; } protected void matchLevelAndReportImportRef ( ImportReference importRef , Binding binding , MatchLocator locator ) throws CoreException { int level = resolveLevel ( binding ) ; if ( level >= INACCURATE_MATCH ) { matchReportImportRef ( importRef , binding , locator . createImportHandle ( importRef ) , level == ACCURATE_MATCH ? SearchMatch . A_ACCURATE : SearchMatch . A_INACCURATE , locator ) ; } } protected void matchReportImportRef ( ImportReference importRef , Binding binding , IJavaElement element , int accuracy , MatchLocator locator ) throws CoreException { if ( locator . encloses ( element ) ) { this . matchReportReference ( importRef , element , null , accuracy , locator ) ; } } protected void matchReportReference ( ASTNode reference , IJavaElement element , Binding elementBinding , int accuracy , MatchLocator locator ) throws CoreException { this . match = null ; int referenceType = referenceType ( ) ; int offset = reference . sourceStart ; switch ( referenceType ) { case IJavaElement . PACKAGE_FRAGMENT : this . match = locator . newPackageReferenceMatch ( element , accuracy , offset , reference . sourceEnd - offset + 1 , reference ) ; break ; case IJavaElement . TYPE : this . match = locator . newTypeReferenceMatch ( element , elementBinding , accuracy , offset , reference . sourceEnd - offset + 1 , reference ) ; break ; case IJavaElement . FIELD : this . match = locator . newFieldReferenceMatch ( element , null , elementBinding , accuracy , offset , reference . sourceEnd - offset + 1 , reference ) ; break ; case IJavaElement . LOCAL_VARIABLE : this . match = locator . newLocalVariableReferenceMatch ( element , accuracy , offset , reference . sourceEnd - offset + 1 , reference ) ; break ; case IJavaElement . TYPE_PARAMETER : this . match = locator . newTypeParameterReferenceMatch ( element , accuracy , offset , reference . sourceEnd - offset + 1 , reference ) ; break ; } if ( this . match != null ) { locator . report ( this . match ) ; } } protected void matchReportReference ( ASTNode reference , IJavaElement element , IJavaElement localElement , IJavaElement [ ] otherElements , Binding elementBinding , int accuracy , MatchLocator locator ) throws CoreException { matchReportReference ( reference , element , elementBinding , accuracy , locator ) ; } public SearchMatch newDeclarationMatch ( ASTNode reference , IJavaElement element , Binding elementBinding , int accuracy , int length , MatchLocator locator ) { return locator . newDeclarationMatch ( element , elementBinding , accuracy , reference . sourceStart , length ) ; } protected int referenceType ( ) { return 0 ; } public int resolveLevel ( ASTNode possibleMatchingNode ) { return IMPOSSIBLE_MATCH ; } void setFlavors ( int flavors ) { this . flavors = flavors ; } protected void updateMatch ( ParameterizedTypeBinding parameterizedBinding , char [ ] [ ] [ ] patternTypeArguments , MatchLocator locator ) { if ( locator . unitScope != null ) { updateMatch ( parameterizedBinding , patternTypeArguments , false , 0 , locator ) ; } } protected void updateMatch ( ParameterizedTypeBinding parameterizedBinding , char [ ] [ ] [ ] patternTypeArguments , boolean patternHasTypeParameters , int depth , MatchLocator locator ) { if ( locator . unitScope == null ) return ; boolean endPattern = patternTypeArguments == null ? true : depth >= patternTypeArguments . length ; TypeBinding [ ] argumentsBindings = parameterizedBinding . arguments ; boolean isRaw = parameterizedBinding . isRawType ( ) || ( argumentsBindings == null && parameterizedBinding . genericType ( ) . isGenericType ( ) ) ; if ( isRaw && ! this . match . isRaw ( ) ) { this . match . setRaw ( isRaw ) ; } if ( ! endPattern && patternTypeArguments != null ) { if ( ! isRaw && patternHasTypeParameters && argumentsBindings != null ) { boolean needUpdate = false ; TypeVariableBinding [ ] typeVariables = parameterizedBinding . genericType ( ) . typeVariables ( ) ; int length = argumentsBindings . length ; if ( length == typeVariables . length ) { for ( int i = 0 ; i < length ; i ++ ) { if ( argumentsBindings [ i ] != typeVariables [ i ] ) { needUpdate = true ; break ; } } } if ( needUpdate ) { char [ ] [ ] patternArguments = patternTypeArguments [ depth ] ; updateMatch ( argumentsBindings , locator , patternArguments , patternHasTypeParameters ) ; } } else { char [ ] [ ] patternArguments = patternTypeArguments [ depth ] ; updateMatch ( argumentsBindings , locator , patternArguments , patternHasTypeParameters ) ; } } TypeBinding enclosingType = parameterizedBinding . enclosingType ( ) ; if ( enclosingType != null && ( enclosingType . isParameterizedType ( ) || enclosingType . isRawType ( ) ) ) { updateMatch ( ( ParameterizedTypeBinding ) enclosingType , patternTypeArguments , patternHasTypeParameters , depth + 1 , locator ) ; } } protected void updateMatch ( TypeBinding [ ] argumentsBinding , MatchLocator locator , char [ ] [ ] patternArguments , boolean hasTypeParameters ) { if ( locator . unitScope == null ) return ; int patternTypeArgsLength = patternArguments == null ? 0 : patternArguments . length ; int typeArgumentsLength = argumentsBinding == null ? 0 : argumentsBinding . length ; int matchRule = this . match . getRule ( ) ; if ( this . match . isRaw ( ) ) { if ( patternTypeArgsLength != 0 ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; } } if ( hasTypeParameters ) { matchRule = SearchPattern . R_ERASURE_MATCH ; } if ( patternTypeArgsLength == typeArgumentsLength ) { if ( ! this . match . isRaw ( ) && hasTypeParameters ) { this . match . setRule ( SearchPattern . R_ERASURE_MATCH ) ; return ; } } else { if ( patternTypeArgsLength == 0 ) { if ( ! this . match . isRaw ( ) || hasTypeParameters ) { this . match . setRule ( matchRule & ~ SearchPattern . R_FULL_MATCH ) ; } } else if ( typeArgumentsLength == 0 ) { this . match . setRule ( matchRule & ~ SearchPattern . R_FULL_MATCH ) ; } else { this . match . setRule ( 0 ) ; } return ; } if ( argumentsBinding == null || patternArguments == null ) { this . match . setRule ( matchRule ) ; return ; } if ( ! hasTypeParameters && ! this . match . isRaw ( ) && ( this . match . isEquivalent ( ) || this . match . isExact ( ) ) ) { for ( int i = 0 ; i < typeArgumentsLength ; i ++ ) { TypeBinding argumentBinding = argumentsBinding [ i ] ; if ( argumentBinding instanceof CaptureBinding ) { WildcardBinding capturedWildcard = ( ( CaptureBinding ) argumentBinding ) . wildcard ; if ( capturedWildcard != null ) argumentBinding = capturedWildcard ; } char [ ] patternTypeArgument = patternArguments [ i ] ; char patternWildcard = patternTypeArgument [ 0 ] ; char [ ] patternTypeName = patternTypeArgument ; int patternWildcardKind = - 1 ; switch ( patternWildcard ) { case Signature . C_STAR : if ( argumentBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argumentBinding ; if ( wildcardBinding . boundKind == Wildcard . UNBOUND ) continue ; } matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; case Signature . C_EXTENDS : patternWildcardKind = Wildcard . EXTENDS ; patternTypeName = CharOperation . subarray ( patternTypeArgument , 1 , patternTypeArgument . length ) ; break ; case Signature . C_SUPER : patternWildcardKind = Wildcard . SUPER ; patternTypeName = CharOperation . subarray ( patternTypeArgument , 1 , patternTypeArgument . length ) ; break ; default : break ; } patternTypeName = Signature . toCharArray ( patternTypeName ) ; TypeBinding patternBinding = locator . getType ( patternTypeArgument , patternTypeName ) ; if ( patternBinding == null ) { if ( argumentBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argumentBinding ; if ( wildcardBinding . boundKind == Wildcard . UNBOUND ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; } else { this . match . setRule ( SearchPattern . R_ERASURE_MATCH ) ; return ; } } continue ; } switch ( patternWildcard ) { case Signature . C_STAR : matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; case Signature . C_EXTENDS : if ( argumentBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argumentBinding ; if ( wildcardBinding . boundKind == patternWildcardKind && wildcardBinding . bound == patternBinding ) { continue ; } switch ( wildcardBinding . boundKind ) { case Wildcard . EXTENDS : if ( wildcardBinding . bound == null || wildcardBinding . bound . isCompatibleWith ( patternBinding ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; case Wildcard . SUPER : break ; case Wildcard . UNBOUND : matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } } else if ( argumentBinding . isCompatibleWith ( patternBinding ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; case Signature . C_SUPER : if ( argumentBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argumentBinding ; if ( wildcardBinding . boundKind == patternWildcardKind && wildcardBinding . bound == patternBinding ) { continue ; } switch ( wildcardBinding . boundKind ) { case Wildcard . EXTENDS : break ; case Wildcard . SUPER : if ( wildcardBinding . bound == null || patternBinding . isCompatibleWith ( wildcardBinding . bound ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; case Wildcard . UNBOUND : matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } } else if ( patternBinding . isCompatibleWith ( argumentBinding ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; default : if ( argumentBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argumentBinding ; switch ( wildcardBinding . boundKind ) { case Wildcard . EXTENDS : if ( wildcardBinding . bound == null || patternBinding . isCompatibleWith ( wildcardBinding . bound ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; case Wildcard . SUPER : if ( wildcardBinding . bound == null || wildcardBinding . bound . isCompatibleWith ( patternBinding ) ) { matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } break ; case Wildcard . UNBOUND : matchRule &= ~ SearchPattern . R_FULL_MATCH ; continue ; } } else if ( argumentBinding == patternBinding ) continue ; break ; } this . match . setRule ( SearchPattern . R_ERASURE_MATCH ) ; return ; } } this . match . setRule ( matchRule ) ; } public int resolveLevel ( Binding binding ) { return INACCURATE_MATCH ; } protected int resolveLevelForType ( char [ ] simpleNamePattern , char [ ] qualificationPattern , TypeBinding binding ) { 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 ; } protected int resolveLevelForType ( char [ ] qualifiedPattern , TypeBinding type ) { if ( qualifiedPattern == null ) return ACCURATE_MATCH ; if ( type == null || ! type . isValidBinding ( ) ) return INACCURATE_MATCH ; if ( type . isTypeVariable ( ) ) return IMPOSSIBLE_MATCH ; 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 ; } protected int resolveLevelForType ( char [ ] simpleNamePattern , char [ ] qualificationPattern , char [ ] [ ] [ ] patternTypeArguments , int depth , TypeBinding type ) { int level = resolveLevelForType ( simpleNamePattern , qualificationPattern , type ) ; if ( level == IMPOSSIBLE_MATCH ) return IMPOSSIBLE_MATCH ; if ( type == null || patternTypeArguments == null || patternTypeArguments . length == 0 || depth >= patternTypeArguments . length ) { return level ; } int impossible = this . isErasureMatch ? ERASURE_MATCH : IMPOSSIBLE_MATCH ; if ( type . isGenericType ( ) ) { TypeVariableBinding [ ] typeVariables = null ; if ( type instanceof SourceTypeBinding ) { SourceTypeBinding sourceTypeBinding = ( SourceTypeBinding ) type ; typeVariables = sourceTypeBinding . typeVariables ; } else if ( type instanceof BinaryTypeBinding ) { BinaryTypeBinding binaryTypeBinding = ( BinaryTypeBinding ) type ; if ( this . mustResolve ) typeVariables = binaryTypeBinding . typeVariables ( ) ; } if ( patternTypeArguments [ depth ] != null && patternTypeArguments [ depth ] . length > 0 && typeVariables != null && typeVariables . length > 0 ) { if ( typeVariables . length != patternTypeArguments [ depth ] . length ) return IMPOSSIBLE_MATCH ; } return level ; } if ( type . isRawType ( ) ) { return level ; } TypeBinding leafType = type . leafComponentType ( ) ; if ( ! leafType . isParameterizedType ( ) ) { return ( patternTypeArguments [ depth ] == null || patternTypeArguments [ depth ] . length == 0 ) ? level : IMPOSSIBLE_MATCH ; } ParameterizedTypeBinding paramTypeBinding = ( ParameterizedTypeBinding ) leafType ; if ( patternTypeArguments [ depth ] != null && patternTypeArguments [ depth ] . length > 0 && paramTypeBinding . arguments != null && paramTypeBinding . arguments . length > 0 ) { int length = patternTypeArguments [ depth ] . length ; if ( paramTypeBinding . arguments . length != length ) return IMPOSSIBLE_MATCH ; nextTypeArgument : for ( int i = 0 ; i < length ; i ++ ) { char [ ] patternTypeArgument = patternTypeArguments [ depth ] [ i ] ; TypeBinding argTypeBinding = paramTypeBinding . arguments [ i ] ; switch ( patternTypeArgument [ 0 ] ) { case Signature . C_STAR : case Signature . C_SUPER : continue nextTypeArgument ; case Signature . C_EXTENDS : patternTypeArgument = CharOperation . subarray ( patternTypeArgument , 1 , patternTypeArgument . length ) ; break ; default : break ; } patternTypeArgument = Signature . toCharArray ( patternTypeArgument ) ; if ( ! this . isCaseSensitive ) patternTypeArgument = CharOperation . toLowerCase ( patternTypeArgument ) ; boolean patternTypeArgHasAnyChars = CharOperation . contains ( new char [ ] { '*' , '?' } , patternTypeArgument ) ; if ( argTypeBinding instanceof CaptureBinding ) { WildcardBinding capturedWildcard = ( ( CaptureBinding ) argTypeBinding ) . wildcard ; if ( capturedWildcard != null ) argTypeBinding = capturedWildcard ; } if ( argTypeBinding . isWildcard ( ) ) { WildcardBinding wildcardBinding = ( WildcardBinding ) argTypeBinding ; switch ( wildcardBinding . boundKind ) { case Wildcard . EXTENDS : if ( patternTypeArgHasAnyChars ) return impossible ; continue nextTypeArgument ; case Wildcard . UNBOUND : continue nextTypeArgument ; } ReferenceBinding boundBinding = ( ReferenceBinding ) wildcardBinding . bound ; if ( CharOperation . match ( patternTypeArgument , boundBinding . shortReadableName ( ) , this . isCaseSensitive ) || CharOperation . match ( patternTypeArgument , boundBinding . readableName ( ) , this . isCaseSensitive ) ) { continue nextTypeArgument ; } if ( patternTypeArgHasAnyChars ) return impossible ; boundBinding = boundBinding . superclass ( ) ; while ( boundBinding != null ) { if ( CharOperation . equals ( patternTypeArgument , boundBinding . shortReadableName ( ) , this . isCaseSensitive ) || CharOperation . equals ( patternTypeArgument , boundBinding . readableName ( ) , this . isCaseSensitive ) ) { continue nextTypeArgument ; } else if ( boundBinding . isLocalType ( ) || boundBinding . isMemberType ( ) ) { if ( CharOperation . match ( patternTypeArgument , boundBinding . sourceName ( ) , this . isCaseSensitive ) ) continue nextTypeArgument ; } boundBinding = boundBinding . superclass ( ) ; } return impossible ; } if ( CharOperation . match ( patternTypeArgument , argTypeBinding . shortReadableName ( ) , this . isCaseSensitive ) || CharOperation . match ( patternTypeArgument , argTypeBinding . readableName ( ) , this . isCaseSensitive ) ) { continue nextTypeArgument ; } else if ( argTypeBinding . isLocalType ( ) || argTypeBinding . isMemberType ( ) ) { if ( CharOperation . match ( patternTypeArgument , argTypeBinding . sourceName ( ) , this . isCaseSensitive ) ) continue nextTypeArgument ; } if ( patternTypeArgHasAnyChars ) return impossible ; TypeBinding leafTypeBinding = argTypeBinding . leafComponentType ( ) ; if ( leafTypeBinding . isBaseType ( ) ) return impossible ; ReferenceBinding refBinding = ( ( ReferenceBinding ) leafTypeBinding ) . superclass ( ) ; while ( refBinding != null ) { if ( CharOperation . equals ( patternTypeArgument , refBinding . shortReadableName ( ) , this . isCaseSensitive ) || CharOperation . equals ( patternTypeArgument , refBinding . readableName ( ) , this . isCaseSensitive ) ) { continue nextTypeArgument ; } else if ( refBinding . isLocalType ( ) || refBinding . isMemberType ( ) ) { if ( CharOperation . match ( patternTypeArgument , refBinding . sourceName ( ) , this . isCaseSensitive ) ) continue nextTypeArgument ; } refBinding = refBinding . superclass ( ) ; } return impossible ; } } TypeBinding enclosingType = paramTypeBinding . enclosingType ( ) ; if ( enclosingType != null && enclosingType . isParameterizedType ( ) && depth < patternTypeArguments . length && qualificationPattern != null ) { int lastDot = CharOperation . lastIndexOf ( '.' , qualificationPattern ) ; char [ ] enclosingQualificationPattern = lastDot == - 1 ? null : CharOperation . subarray ( qualificationPattern , 0 , lastDot ) ; char [ ] enclosingSimpleNamePattern = lastDot == - 1 ? qualificationPattern : CharOperation . subarray ( qualificationPattern , lastDot + 1 , qualificationPattern . length ) ; int enclosingLevel = resolveLevelForType ( enclosingSimpleNamePattern , enclosingQualificationPattern , patternTypeArguments , depth + 1 , enclosingType ) ; if ( enclosingLevel == impossible ) return impossible ; if ( enclosingLevel == IMPOSSIBLE_MATCH ) return IMPOSSIBLE_MATCH ; } return level ; } public String toString ( ) { return "" ; } } </s>