private static SearchResultGroup[] internalSearch( SearchEngine searchEngine, SearchPattern pattern, IDLTKSearchScope scope, CollectingSearchRequestor requestor, IProgressMonitor monitor, RefactoringStatus status) throws CoreException { searchEngine.search( pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, monitor); return groupByCu(requestor.getResults(), status); }
public static ISourceModule[] findAffectedCompilationUnits( SearchPattern pattern, IDLTKSearchScope scope, final IProgressMonitor pm, RefactoringStatus status, final boolean tolerateInAccurateMatches) throws CoreException { boolean hasNonCuMatches = false; class ResourceSearchRequestor extends SearchRequestor { boolean hasPotentialMatches = false; Set<IResource> resources = new HashSet<IResource>(5); private IResource fLastResource; public void acceptSearchMatch(SearchMatch match) { if (!tolerateInAccurateMatches && match.getAccuracy() == SearchMatch.A_INACCURATE) { hasPotentialMatches = true; } if (fLastResource != match.getResource()) { fLastResource = match.getResource(); resources.add(fLastResource); } } } ResourceSearchRequestor requestor = new ResourceSearchRequestor(); new SearchEngine() .search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm); List<ISourceModule> result = new ArrayList<ISourceModule>(requestor.resources.size()); for (IResource resource : requestor.resources) { IModelElement element = DLTKCore.create(resource); if (element instanceof ISourceModule) { result.add((ISourceModule) element); } else { hasNonCuMatches = true; } } addStatusErrors(status, requestor.hasPotentialMatches, hasNonCuMatches); return (ISourceModule[]) result.toArray(new ISourceModule[result.size()]); }