Buggy code:
public class MatchLocator implements ITypeRequestor { public static final int MAX_AT_ONCE = 500 ; public static final PotentialMatch [ ] NO_POTENTIAL_MATH = new PotentialMatch [ 0 ] ; public SearchPattern pattern ; public int detailLevel ; public IJavaSearchResultCollector collector ; public IJavaSearchScope scope ; public IProgressMonitor progressMonitor ; public IWorkingCopy [ ] workingCopies ; public HandleFactory handleFactory ; public MatchLocatorParser parser ; public INameEnvironment nameEnvironment ; public NameLookup nameLookup ; public LookupEnvironment lookupEnvironment ; public HierarchyResolver hierarchyResolver ; boolean compilationAborted ; public PotentialMatchSet matchSet ; public int parseThreshold = - 1 ; public CompilerOptions options ; public CompilationUnitDeclaration [ ] unitsToProcess ; public PotentialMatch [ ] matchesToProcess ; public int totalUnits ; public PotentialMatch currentPotentialMatch ; public long resultCollectorTime = 0 ; public MatchLocator ( SearchPattern pattern , int detailLevel , IJavaSearchResultCollector collector , IJavaSearchScope scope , IProgressMonitor progressMonitor ) { } public void accept ( IBinaryType binaryType , PackageBinding packageBinding ) { } public void accept ( ICompilationUnit sourceUnit ) { } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding ) { } protected void addCompilationUnit ( ICompilationUnit sourceUnit , CompilationUnitDeclaration parsedUnit ) { } void addPotentialMatch ( IResource resource , Openable openable ) { } BinaryTypeBinding cacheBinaryType ( IType type ) throws JavaModelException { } public ClassFileReader classFileReader ( IType type ) { } protected void createAndResolveBindings ( PotentialMatch [ ] potentialMatches , int start , int length ) { } public IField createFieldHandle ( FieldDeclaration field , IType type ) { } protected boolean createHierarchyResolver ( PotentialMatch [ ] potentialMatches ) { } public IJavaElement createImportHandle ( ImportReference importRef ) { } public IInitializer createInitializerHandle ( TypeDeclaration typeDecl , FieldDeclaration initializer , IType type ) { } public IMethod createMethodHandle ( AbstractMethodDeclaration method , IType type ) { } public IType createTypeHandle ( char [ ] simpleTypeName ) { } public IType createTypeHandle ( IType parent , char [ ] simpleTypeName ) { } protected Openable getCurrentOpenable ( ) { } protected IResource getCurrentResource ( ) { } protected IType getFocusType ( ) { } public IBinaryType getBinaryInfo ( ClassFile classFile , IResource resource ) throws CoreException { } protected void getMethodBodies ( CompilationUnitDeclaration unit , int place ) { } public void initialize ( JavaProject project ) throws JavaModelException { } public void initialize ( JavaProject project , PotentialMatch [ ] potentialMatches ) throws JavaModelException { if ( ( this . nameEnvironment ) != null ) { this . nameEnvironment . cleanup ( ) ; } if ( ( potentialMatches . length ) == 1 ) { this . nameEnvironment = project . getSearchableNameEnvironment ( ) ; } else { <START_BUG> this . nameEnvironment = new JavaSearchNameEnvironment2 ( project ) ; <END_BUG> } this . options = new CompilerOptions ( project . getOptions ( true ) ) ; ProblemReporter problemReporter = new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , this . options , new DefaultProblemFactory ( ) ) ; this . lookupEnvironment = new LookupEnvironment ( this , this . options , problemReporter , this . nameEnvironment ) ; this . parser = new MatchLocatorParser ( problemReporter , this . options . sourceLevel ) ; this . nameLookup = project . getNameLookup ( ) ; this . totalUnits = 0 ; int maxUnits = potentialMatches . length ; this . unitsToProcess = new CompilationUnitDeclaration [ maxUnits ] ; this . matchesToProcess = new PotentialMatch [ maxUnits ] ; } public boolean hasAlreadyDefinedType ( CompilationUnitDeclaration parsedUnit ) { } private void locateMatches ( JavaProject javaProject ) throws JavaModelException { } private void locateMatches ( JavaProject javaProject , PotentialMatch [ ] potentialMatches , int start , int length ) throws JavaModelException { } public void locateMatches ( String [ ] filePaths , IWorkspace workspace , IWorkingCopy [ ] copies ) throws JavaModelException { } public void locatePackageDeclarations ( IWorkspace workspace ) throws JavaModelException { } private void locatePackageDeclarations ( SearchPattern searchPattern , IWorkspace workspace ) throws JavaModelException { } public IType lookupType ( TypeBinding typeBinding ) { } public void process ( CompilationUnitDeclaration unit , int i ) throws CoreException { } public void report ( int sourceStart , int sourceEnd , IJavaElement element , int accuracy ) throws CoreException { } public void report ( IResource resource , int sourceStart , int sourceEnd , IJavaElement element , int accuracy ) throws CoreException { } public void reportAccurateReference ( int sourceStart , int sourceEnd , char [ ] [ ] qualifiedName , IJavaElement element , int accuracy ) throws CoreException { } public void reportAccurateReference ( int sourceStart , int sourceEnd , char [ ] [ ] tokens , IJavaElement element , int [ ] accuracies ) throws CoreException { } public void reportBinaryMatch ( IMember binaryMember , IBinaryType info , int accuracy ) throws CoreException , JavaModelException { } public void reportBinaryMatch ( IResource resource , IMember binaryMember , IBinaryType info , int accuracy ) throws CoreException , JavaModelException { } public void reportFieldDeclaration ( FieldDeclaration fieldDeclaration , IJavaElement parent , int accuracy ) throws CoreException { } public void reportImport ( ImportReference reference , int accuracy ) throws CoreException { } public void reportMethodDeclaration ( AbstractMethodDeclaration methodDeclaration , IJavaElement parent , int accuracy ) throws CoreException { } public void reportPackageDeclaration ( ImportReference node ) { } public void reportReference ( AstNode reference , AbstractMethodDeclaration methodDeclaration , IJavaElement parent , int accuracy ) throws CoreException { } public void reportReference ( AstNode reference , TypeDeclaration typeDeclaration , FieldDeclaration fieldDeclaration , IJavaElement parent , int accuracy ) throws CoreException { } public void reportSuperTypeReference ( TypeReference typeRef , IJavaElement type , int accuracy ) throws CoreException { } public void reportTypeDeclaration ( TypeDeclaration typeDeclaration , IJavaElement parent , int accuracy ) throws CoreException { } }

Fix:
this . nameEnvironment = new JavaSearchNameEnvironment ( project ) ;