use of org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup in project che by eclipse.
the class RenameMethodProcessor method analyzeRenameChanges.
//-------
private RefactoringStatus analyzeRenameChanges(IProgressMonitor pm) throws CoreException {
ICompilationUnit[] newDeclarationWCs = null;
try {
//$NON-NLS-1$
pm.beginTask("", 4);
RefactoringStatus result = new RefactoringStatus();
ICompilationUnit[] declarationCUs = getDeclarationCUs();
newDeclarationWCs = RenameAnalyzeUtil.createNewWorkingCopies(declarationCUs, fChangeManager, fWorkingCopyOwner, new SubProgressMonitor(pm, 1));
IMethod[] wcOldMethods = new IMethod[fMethodsToRename.size()];
IMethod[] wcNewMethods = new IMethod[fMethodsToRename.size()];
int i = 0;
for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); i++) {
IMethod method = iter.next();
ICompilationUnit newCu = RenameAnalyzeUtil.findWorkingCopyForCu(newDeclarationWCs, method.getCompilationUnit());
IType typeWc = (IType) JavaModelUtil.findInCompilationUnit(newCu, method.getDeclaringType());
if (typeWc == null) {
// should not happen
i--;
wcOldMethods = CollectionsUtil.toArray(Arrays.asList(wcOldMethods).subList(0, wcOldMethods.length - 1), IMethod.class);
wcNewMethods = CollectionsUtil.toArray(Arrays.asList(wcNewMethods).subList(0, wcNewMethods.length - 1), IMethod.class);
continue;
}
wcOldMethods[i] = getMethodInWorkingCopy(method, getCurrentElementName(), typeWc);
wcNewMethods[i] = getMethodInWorkingCopy(method, getNewElementName(), typeWc);
}
// SearchResultGroup[] newOccurrences= findNewOccurrences(newMethods, newDeclarationWCs, new SubProgressMonitor(pm, 3));
SearchResultGroup[] newOccurrences = batchFindNewOccurrences(wcNewMethods, wcOldMethods, newDeclarationWCs, new SubProgressMonitor(pm, 3), result);
result.merge(RenameAnalyzeUtil.analyzeRenameChanges2(fChangeManager, fOccurrences, newOccurrences, getNewElementName()));
return result;
} finally {
pm.done();
if (newDeclarationWCs != null) {
for (int i = 0; i < newDeclarationWCs.length; i++) {
newDeclarationWCs[i].discardWorkingCopy();
}
}
}
}
use of org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup in project che by eclipse.
the class MoveCuUpdateCreator method getReferences.
private static SearchResultGroup[] getReferences(ICompilationUnit unit, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
final SearchPattern pattern = RefactoringSearchEngine.createOrPattern(unit.getTypes(), IJavaSearchConstants.REFERENCES);
if (pattern != null) {
String binaryRefsDescription = Messages.format(RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description, BasicElementLabels.getFileName(unit));
ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
Collector requestor = new Collector(((IPackageFragment) unit.getParent()), binaryRefs);
IJavaSearchScope scope = RefactoringScopeFactory.create(unit, true, false);
SearchResultGroup[] result = RefactoringSearchEngine.search(pattern, scope, requestor, new SubProgressMonitor(pm, 1), status);
binaryRefs.addErrorIfNecessary(status);
return result;
}
return new SearchResultGroup[] {};
}
use of org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup in project che by eclipse.
the class IntroduceFactoryRefactoring method excludeBinaryUnits.
/**
* @param groups
* @return an array of <code>SearchResultGroup</code>'s like the argument,
* but omitting those groups that have no corresponding compilation unit
* (i.e. are binary and therefore can't be modified).
*/
private SearchResultGroup[] excludeBinaryUnits(SearchResultGroup[] groups) {
Collection<SearchResultGroup> result = new ArrayList<SearchResultGroup>();
for (int i = 0; i < groups.length; i++) {
SearchResultGroup rg = groups[i];
ICompilationUnit unit = rg.getCompilationUnit();
if (// ignore hits within a binary unit
unit != null)
result.add(rg);
else
fCallSitesInBinaryUnits = true;
}
return result.toArray(new SearchResultGroup[result.size()]);
}
Aggregations