public static SearchResultGroup[] groupByCu(List matchList, RefactoringStatus status) { Map grouped= new HashMap(); boolean hasPotentialMatches= false; boolean hasNonCuMatches= false;  for (Iterator iter= matchList.iterator(); iter.hasNext();) { SearchMatch searchMatch= (SearchMatch) iter.next(); if (searchMatch.getAccuracy() == SearchMatch.A_INACCURATE) hasPotentialMatches= true; if (! grouped.containsKey(searchMatch.getResource())) grouped.put(searchMatch.getResource(), new ArrayList(1)); ((List) grouped.get(searchMatch.getResource())).add(searchMatch); }  for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) { IResource resource= (IResource) iter.next(); IJavaElement element= JavaCore.create(resource); if (! (element instanceof ICompilationUnit)) { iter.remove(); hasNonCuMatches= true; } }  SearchResultGroup[] result= new SearchResultGroup[grouped.keySet().size()]; int i= 0; for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) { IResource resource= (IResource) iter.next(); List searchMatches= (List) grouped.get(resource); SearchMatch[] matchArray= (SearchMatch[]) searchMatches.toArray(new SearchMatch[searchMatches.size()]); result[i]= new SearchResultGroup(resource, matchArray); i++; } addStatusErrors(status, hasPotentialMatches, hasNonCuMatches); return result;
public static SearchResultGroup[] groupByCu(SearchMatch[] matches, RefactoringStatus status) { return groupByCu(Arrays.asList(matches), status);
	public static SearchResultGroup[] groupByCu(List matchList, RefactoringStatus status) {		Map/*<IResource, List<SearchMatch>>*/ grouped= new HashMap();		boolean hasPotentialMatches= false;		boolean hasNonCuMatches= false;				for (Iterator iter= matchList.iterator(); iter.hasNext();) {			SearchMatch searchMatch= (SearchMatch) iter.next();			if (searchMatch.getAccuracy() == SearchMatch.A_INACCURATE)				hasPotentialMatches= true;			if (! grouped.containsKey(searchMatch.getResource()))				grouped.put(searchMatch.getResource(), new ArrayList(1));			((List) grouped.get(searchMatch.getResource())).add(searchMatch);		}				for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) {			IResource resource= (IResource) iter.next();			IJavaElement element= JavaCore.create(resource);			if (! (element instanceof ICompilationUnit)) {				iter.remove();				hasNonCuMatches= true;			}		}				SearchResultGroup[] result= new SearchResultGroup[grouped.keySet().size()];		int i= 0;		for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) {			IResource resource= (IResource) iter.next();			List searchMatches= (List) grouped.get(resource);			SearchMatch[] matchArray= (SearchMatch[]) searchMatches.toArray(new SearchMatch[searchMatches.size()]);			result[i]= new SearchResultGroup(resource, matchArray);			i++;		}		addStatusErrors(status, hasPotentialMatches, hasNonCuMatches);		return result;	}