<s> package org . eclipse . jdt . internal . core . search . matching ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMethod ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . IType ; import org . eclipse . jdt . core . ITypeParameter ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchParticipant ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . IndexQueryRequestor ; import org . eclipse . jdt . internal . core . search . JavaSearchScope ; import org . eclipse . jdt . internal . core . util . Util ; public class TypeParameterPattern extends JavaSearchPattern { protected boolean findDeclarations ; protected boolean findReferences ; protected char [ ] name ; protected ITypeParameter typeParameter ; protected char [ ] declaringMemberName ; protected char [ ] methodDeclaringClassName ; protected char [ ] [ ] methodArgumentTypes ; public TypeParameterPattern ( boolean findDeclarations , boolean findReferences , ITypeParameter typeParameter , int matchRule ) { super ( TYPE_PARAM_PATTERN , matchRule ) ; this . findDeclarations = findDeclarations ; this . findReferences = findReferences ; this . typeParameter = typeParameter ; this . name = typeParameter . getElementName ( ) . toCharArray ( ) ; IMember member = typeParameter . getDeclaringMember ( ) ; this . declaringMemberName = member . getElementName ( ) . toCharArray ( ) ; if ( member instanceof IMethod ) { IMethod method = ( IMethod ) member ; this . methodDeclaringClassName = method . getParent ( ) . getElementName ( ) . toCharArray ( ) ; String [ ] parameters = method . getParameterTypes ( ) ; int length = parameters . length ; this . methodArgumentTypes = new char [ length ] [ ] ; for ( int i = 0 ; i < length ; i ++ ) { this . methodArgumentTypes [ i ] = Signature . toCharArray ( parameters [ i ] . toCharArray ( ) ) ; } } } public void findIndexMatches ( Index index , IndexQueryRequestor requestor , SearchParticipant participant , IJavaSearchScope scope , IProgressMonitor progressMonitor ) { IPackageFragmentRoot root = ( IPackageFragmentRoot ) this . typeParameter . getAncestor ( IJavaElement . PACKAGE_FRAGMENT_ROOT ) ; String documentPath ; String relativePath ; if ( root . isArchive ( ) ) { IType type = ( IType ) this . typeParameter . getAncestor ( IJavaElement . TYPE ) ; relativePath = ( type . getFullyQualifiedName ( '$' ) ) . replace ( '.' , '/' ) + SuffixConstants . SUFFIX_STRING_class ; documentPath = root . getPath ( ) + IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR + relativePath ; } else { IPath path = this . typeParameter . getPath ( ) ; documentPath = path . toString ( ) ; relativePath = Util . relativePath ( path , 1 ) ; } if ( scope instanceof JavaSearchScope ) { JavaSearchScope javaSearchScope = ( JavaSearchScope ) scope ; AccessRuleSet access = javaSearchScope . getAccessRuleSet ( relativePath , index . containerPath ) ; if ( access != JavaSearchScope . NOT_ENCLOSED ) { if ( ! requestor . acceptIndexMatch ( documentPath , this , participant , access ) ) throw new OperationCanceledException ( ) ; } } else if ( scope . encloses ( documentPath ) ) { if ( ! requestor . acceptIndexMatch ( documentPath , this , participant , null ) ) throw new OperationCanceledException ( ) ; } } protected StringBuffer print ( StringBuffer output ) { if ( this . findDeclarations ) { output . append ( this . findReferences ? "" : "" ) ; } else { output . append ( "" ) ; } output . append ( this . typeParameter . toString ( ) ) ; return super . print ( output ) ; } } </s>