Buggy code:
CompilationUnitScope unitScope ; SimpleLookupTable bindings ; public class LocalDeclarationVisitor extends ASTVisitor { IJavaElement enclosingElement ; MatchingNodeSet nodeSet ; HashtableOfIntValues occurrencesCounts = new HashtableOfIntValues ( ) ; public LocalDeclarationVisitor ( IJavaElement enclosingElement , MatchingNodeSet nodeSet ) { } public boolean visit ( TypeDeclaration typeDeclaration , BlockScope unused ) { } } public static class WorkingCopyDocument extends JavaSearchDocument { public ICompilationUnit workingCopy ; WorkingCopyDocument ( ICompilationUnit workingCopy , SearchParticipant participant ) { } public String toString ( ) { } } public class WrappedCoreException extends RuntimeException { private static final long serialVersionUID = 8354329870126121212L ; public CoreException coreException ; public WrappedCoreException ( CoreException coreException ) { } } public static SearchDocument [ ] addWorkingCopies ( InternalSearchPattern pattern , SearchDocument [ ] indexMatches , ICompilationUnit [ ] copies , SearchParticipant participant ) { } public static void setFocus ( InternalSearchPattern pattern , IJavaElement focus ) { } private static HashMap workingCopiesThatCanSeeFocus ( ICompilationUnit [ ] copies , IJavaElement focus , boolean isPolymorphicSearch , SearchParticipant participant ) { } public static ClassFileReader classFileReader ( IType type ) { } public static SearchPattern createAndPattern ( final SearchPattern leftPattern , final SearchPattern rightPattern ) { } public static void findIndexMatches ( InternalSearchPattern pattern , Index index , IndexQueryRequestor requestor , SearchParticipant participant , IJavaSearchScope scope , IProgressMonitor monitor ) throws IOException { } public static IJavaElement getProjectOrJar ( IJavaElement element ) { } public static boolean isPolymorphicSearch ( InternalSearchPattern pattern ) { } public static IJavaElement projectOrJarFocus ( InternalSearchPattern pattern ) { } public MatchLocator ( SearchPattern pattern , SearchRequestor requestor , IJavaSearchScope scope , IProgressMonitor progressMonitor ) { } public void accept ( IBinaryType binaryType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { } public void accept ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , AccessRestriction accessRestriction ) { } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { } protected Parser basicParser ( ) { } protected void parseAndBuildBindings ( PossibleMatch possibleMatch , boolean mustResolve ) { } protected BinaryTypeBinding cacheBinaryType ( IType type , IBinaryType binaryType ) throws JavaModelException { } protected char [ ] [ ] [ ] computeSuperTypeNames ( IType focusType ) { } protected IJavaElement createHandle ( AbstractMethodDeclaration method , IJavaElement parent ) { } protected IJavaElement createHandle ( FieldDeclaration fieldDeclaration , TypeDeclaration typeDeclaration , IJavaElement parent ) { } protected boolean createHierarchyResolver ( IType focusType , PossibleMatch [ ] possibleMatches ) { } protected IJavaElement createImportHandle ( ImportReference importRef ) { } protected IType createTypeHandle ( String simpleTypeName ) { } protected boolean encloses ( IJavaElement element ) { } private long findLastTypeArgumentInfo ( TypeReference typeRef ) { } protected IBinaryType getBinaryInfo ( ClassFile classFile , IResource resource ) throws CoreException { } protected IType getFocusType ( ) { } protected void getMethodBodies ( CompilationUnitDeclaration unit ) { } protected TypeBinding getType ( Object typeKey , char [ ] typeName ) { } public MethodBinding getMethodBinding ( IMethod method ) { } protected boolean hasAlreadyDefinedType ( CompilationUnitDeclaration parsedUnit ) { } public void initialize ( JavaProject project , int possibleMatchSize ) throws JavaModelException { } protected void locateMatches ( JavaProject javaProject , PossibleMatch [ ] possibleMatches , int start , int length ) throws CoreException { } protected void locateMatches ( JavaProject javaProject , PossibleMatchSet matchSet , int expected ) throws CoreException { } public void locateMatches ( SearchDocument [ ] searchDocuments ) throws CoreException { } public void locatePackageDeclarations ( SearchParticipant participant ) throws CoreException { } protected void locatePackageDeclarations ( SearchPattern searchPattern , SearchParticipant participant ) throws CoreException { if ( searchPattern instanceof OrPattern ) { SearchPattern [ ] patterns = ( ( OrPattern ) ( searchPattern ) ) . patterns ; for ( int i = 0 , length = patterns . length ; i < length ; i ++ ) locatePackageDeclarations ( patterns [ i ] , participant ) ; } else if ( searchPattern instanceof PackageDeclarationPattern ) { IJavaElement focus = ( ( InternalSearchPattern ) ( searchPattern ) ) . focus ; if ( focus != null ) { SearchDocument document = participant . getDocument ( focus . getPath ( ) . toString ( ) ) ; this . currentPossibleMatch = new PossibleMatch ( this , focus . getResource ( ) , null , document ) ; if ( encloses ( focus ) ) { <START_BUG> SearchMatch match = newDeclarationMatch ( focus , SearchMatch . A_ACCURATE , ( - 1 ) , ( - 1 ) ) ; <END_BUG> report ( match ) ; } return ; } PackageDeclarationPattern pkgPattern = ( ( PackageDeclarationPattern ) ( searchPattern ) ) ; IJavaProject [ ] projects = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) . getJavaProjects ( ) ; for ( int i = 0 , length = projects . length ; i < length ; i ++ ) { IJavaProject javaProject = projects [ i ] ; IPackageFragmentRoot [ ] roots = null ; try { roots = javaProject . getPackageFragmentRoots ( ) ; } catch ( JavaModelException e ) { continue ; } for ( int j = 0 , rootsLength = roots . length ; j < rootsLength ; j ++ ) { IJavaElement [ ] pkgs = null ; try { pkgs = roots [ j ] . getChildren ( ) ; } catch ( JavaModelException e ) { continue ; } for ( int k = 0 , pksLength = pkgs . length ; k < pksLength ; k ++ ) { IPackageFragment pkg = ( ( IPackageFragment ) ( pkgs [ k ] ) ) ; IJavaElement [ ] children = null ; try { children = pkg . getChildren ( ) ; } catch ( JavaModelException e ) { continue ; }

Fix:
SearchMatch match = newDeclarationMatch ( focus . getAncestor ( IJavaElement . PACKAGE_FRAGMENT ) , SearchMatch . A_ACCURATE , ( - 1 ) , ( - 1 ) ) ;