IQueryParticipant[] participants= getSearchParticipants(projects); int[] ticks= new int[participants.length]; for (int i= 0; i < participants.length; i++) { ticks[i]= participants[i].estimateTicks(fPatternData);
final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects); final int[] ticks= new int[participantDescriptors.length]; for (int i= 0; i < participantDescriptors.length; i++) { final int iPrime= i; ISafeRunnable runnable= new ISafeRunnable() { public void handleException(Throwable exception) { ticks[iPrime]= 0; String message= SearchMessages.getString("JavaSearchQuery.error.participant.estimate"); JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, message, exception)); }  public void run() throws Exception { ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData); } };  Platform.run(runnable);
	public IStatus run(IProgressMonitor monitor) {		final JavaSearchResult textResult= (JavaSearchResult) getSearchResult();		textResult.removeAll();		// Don't need to pass in working copies in 3.0 here		SearchEngine engine= new SearchEngine();		try {			int totalTicks= 1000;			IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());			IQueryParticipant[] participants= getSearchParticipants(projects);			int[] ticks= new int[participants.length];			for (int i= 0; i < participants.length; i++) {				ticks[i]= participants[i].estimateTicks(fPatternData);				totalTicks+= ticks[i];			}			monitor.beginTask(SearchMessages.getString("JavaSearchQuery.task.label"), totalTicks); //$NON-NLS-1$			IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);			boolean ignorePotentials= SearchPreferencePage.arePotentialMatchesIgnored();			NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);						SearchPattern pattern;			String stringPattern= null;						if (fPatternData instanceof ElementQuerySpecification) {				pattern= SearchPattern.createPattern(((ElementQuerySpecification)fPatternData).getElement(), fPatternData.getLimitTo());				stringPattern= ((ElementQuerySpecification)fPatternData).getElement().getElementName();			} else {				PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;				stringPattern = patternSpec.getPattern();				int matchMode = stringPattern.indexOf('*') != -1 || stringPattern.indexOf('?') != -1 ? SearchPattern.R_PATTERN_MATCH : SearchPattern.R_EXACT_MATCH;				if (patternSpec.isCaseSensitive())					matchMode |= SearchPattern.R_CASE_SENSITIVE;				pattern = SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);			}						if (pattern == null) {				return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, SearchMessages.getFormattedString("JavaSearchQuery.error.unsupported_pattern", stringPattern), null);  //$NON-NLS-1$			}			engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);			for (int i= 0; i < participants.length; i++) {				ISearchRequestor requestor= new SearchRequestor(participants[i], textResult);				IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);				participants[i].search(requestor, fPatternData, participantPM);			}					} catch (CoreException e) {			return e.getStatus();		}		// TODO fix status message		String message= SearchMessages.getString("JavaSearchQuery.status.ok.message"); //$NON-NLS-1$		MessageFormat.format(message, new Object[] { new Integer(textResult.getMatchCount()) });		return new Status(IStatus.OK, JavaPlugin.getPluginId(), 0, message, null);	}