Buggy code:
public class BasicSearchEngine { private Parser parser ; private CompilerOptions compilerOptions ; private ICompilationUnit [ ] workingCopies ; private WorkingCopyOwner workingCopyOwner ; public static boolean VERBOSE = false ; public BasicSearchEngine ( ) { } public BasicSearchEngine ( ICompilationUnit [ ] workingCopies ) { } char convertTypeKind ( int typeDeclarationKind ) { } public BasicSearchEngine ( WorkingCopyOwner workingCopyOwner ) { } public static IJavaSearchScope createHierarchyScope ( IType type ) throws JavaModelException { } public static IJavaSearchScope createHierarchyScope ( IType type , WorkingCopyOwner owner ) throws JavaModelException { } public static IJavaSearchScope createJavaSearchScope ( IJavaElement [ ] elements ) { } public static IJavaSearchScope createJavaSearchScope ( IJavaElement [ ] elements , boolean includeReferencedProjects ) { } public static IJavaSearchScope createJavaSearchScope ( IJavaElement [ ] elements , int includeMask ) { HashSet projectsToBeAdded = new HashSet ( 2 ) ; for ( int i = 0 , length = elements . length ; i < length ; i ++ ) { IJavaElement element = elements [ i ] ; if ( element instanceof JavaProject ) { projectsToBeAdded . add ( element ) ; } } JavaSearchScope scope = new JavaSearchScope ( ) ; for ( int i = 0 , length = elements . length ; i < length ; i ++ ) { IJavaElement element = elements [ i ] ; if ( element != null ) { try { <START_BUG> if ( projectsToBeAdded . remove ( element ) ) { <END_BUG> scope . add ( ( ( JavaProject ) ( element ) ) , includeMask , projectsToBeAdded ) ; } else { scope . add ( element ) ; } } catch ( JavaModelException e ) { } } } return scope ; } public static TypeNameMatch createTypeNameMatch ( IType type , int modifiers ) { } public static IJavaSearchScope createWorkspaceScope ( ) { } void findMatches ( SearchPattern pattern , SearchParticipant [ ] participants , IJavaSearchScope scope , SearchRequestor requestor , IProgressMonitor monitor ) throws CoreException { } public static SearchParticipant getDefaultSearchParticipant ( ) { } public static String getMatchRuleString ( final int matchRule ) { } public static String getSearchForString ( final int searchFor ) { } private Parser getParser ( ) { } private ICompilationUnit [ ] getWorkingCopies ( ) { } private ICompilationUnit [ ] getWorkingCopies ( IJavaElement element ) { } boolean match ( char patternTypeSuffix , int modifiers ) { } boolean match ( char patternTypeSuffix , char [ ] patternPkg , char [ ] patternTypeName , int matchRule , int typeKind , char [ ] pkg , char [ ] typeName ) { } public void search ( SearchPattern pattern , SearchParticipant [ ] participants , IJavaSearchScope scope , SearchRequestor requestor , IProgressMonitor monitor ) throws CoreException { } public void searchAllSecondaryTypeNames ( IPackageFragmentRoot [ ] sourceFolders , final IRestrictedAccessTypeRequestor nameRequestor , boolean waitForIndexes , IProgressMonitor progressMonitor ) throws JavaModelException { } public void searchAllTypeNames ( final char [ ] packageName , final int packageMatchRule , final char [ ] typeName , final int typeMatchRule , int searchFor , IJavaSearchScope scope , final IRestrictedAccessTypeRequestor nameRequestor , int waitingPolicy , IProgressMonitor progressMonitor ) throws JavaModelException { } public void searchAllTypeNames ( final char [ ] [ ] qualifications , final char [ ] [ ] typeNames , int matchRule , int searchFor , IJavaSearchScope scope , final IRestrictedAccessTypeRequestor nameRequestor , int waitingPolicy , IProgressMonitor progressMonitor ) throws JavaModelException { } public void searchDeclarations ( IJavaElement enclosingElement , SearchRequestor requestor , SearchPattern pattern , IProgressMonitor monitor ) throws JavaModelException { } public void searchDeclarationsOfAccessedFields ( IJavaElement enclosingElement , SearchRequestor requestor , IProgressMonitor monitor ) throws JavaModelException { } public void searchDeclarationsOfReferencedTypes ( IJavaElement enclosingElement , SearchRequestor requestor , IProgressMonitor monitor ) throws JavaModelException { } public void searchDeclarationsOfSentMessages ( IJavaElement enclosingElement , SearchRequestor requestor , IProgressMonitor monitor ) throws JavaModelException { } }

Fix:
if ( projectsToBeAdded . contains ( element ) ) {