Bug 81505 Search Again throws NPE if a search query cannot be rerun
I200412162000 - new workspace, new Java Propject with CU p/A.java: package p; public class A {} - Find identifier occurrences for A - activate the search result view and don't open the context menu - press F5 -> the problem seems to be that the query is rerun although it answers false to canRerun() Error 2004-12-17 12:04:49.929 An internal error occurred during: "Search for Occurrences in File". java.lang.NullPointerException at org.eclipse.jdt.internal.ui.search.OccurrencesSearchQuery.run(OccurrencesSearchQuery.java:46) at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:85) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/OccurrencesSearchQuery.java
public OccurrencesSearchQuery(IOccurrencesFinder finder, IDocument document, IJavaElement element) {
		fFinder= finder;
		fDocument= document;
		fElement= element;
		fSingularLabel= fFinder.getSingularLabel(element.getElementName());
		fPluralLabelPattern= fFinder.getPluralLabelPattern(element.getElementName());
		fJobLabel= fFinder.getJobLabel();
	}
	/*
	 * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
	 */
	public IStatus run(IProgressMonitor monitor) {
		fFinder.perform();
		org.eclipse.search.ui.text.Match[] matches= Match.convert(fFinder.getOccurrenceMatches(fElement, fDocument));
		fResult.addMatches(matches);
		
		fFinder= null;
		fDocument= null;
		monitor.done();
		return Status.OK_STATUS;
	}
	
	/*
	 * @see org.eclipse.search.ui.ISearchQuery#getLabel()
	 */
	public String getLabel() {
		return fJobLabel;
	}