Source:
private void addReferenceUpdates(IProgressMonitor pm) throws CoreException { pm.beginTask("", fOccurrences.length + fReferencesToTypesInPackage.size() + fReferencesToTypesInNamesakes.size()); for (SearchResultGroup fOccurrence : fOccurrences) { ICompilationUnit cu= fOccurrence.getCompilationUnit(); if (cu == null) continue; for (SearchMatch result : fOccurrence.getSearchResults()) { IJavaElement enclosingElement= SearchUtils.getEnclosingJavaElement(result); if (enclosingElement instanceof IImportDeclaration) { IImportDeclaration importDeclaration= (IImportDeclaration) enclosingElement; String updatedImport= getUpdatedImport(importDeclaration); updateImport(cu, importDeclaration, updatedImport); } else { TextChangeCompatibility.addTextEdit(fTextChangeManager.get(cu), RefactoringCoreMessages.RenamePackageRefactoring_update_reference, createTextChange(result)); } } if (fReferencesToTypesInNamesakes.size() != 0) { SearchResultGroup typeRefsRequiringOldNameImport= extractGroupFor(cu, fReferencesToTypesInNamesakes); if (typeRefsRequiringOldNameImport != null) addTypeImports(typeRefsRequiringOldNameImport); } if (fReferencesToTypesInPackage.size() != 0) { SearchResultGroup typeRefsRequiringNewNameImport= extractGroupFor(cu, fReferencesToTypesInPackage); if (typeRefsRequiringNewNameImport != null) updateTypeImports(typeRefsRequiringNewNameImport); } pm.worked(1); } if (fReferencesToTypesInNamesakes.size() != 0) { for (SearchResultGroup referencesToTypesInNamesakes : fReferencesToTypesInNamesakes) { addTypeImports(referencesToTypesInNamesakes); pm.worked(1); } } if (fReferencesToTypesInPackage.size() != 0) { for (SearchResultGroup namesakeReferencesToPackage : fReferencesToTypesInPackage) { updateTypeImports(namesakeReferencesToPackage); pm.worked(1); } } pm.done(); }

Target:
private void addReferenceUpdates(IProgressMonitor pm) throws CoreException { pm.beginTask("", fOccurrences.length + fReferencesToTypesInPackage.size() + fReferencesToTypesInNamesakes.size()); for (SearchResultGroup occurrence : fOccurrences) { ICompilationUnit cu= occurrence.getCompilationUnit(); if (cu == null) continue; for (SearchMatch result : occurrence.getSearchResults()) { IJavaElement enclosingElement= SearchUtils.getEnclosingJavaElement(result); if (enclosingElement instanceof IImportDeclaration) { IImportDeclaration importDeclaration= (IImportDeclaration) enclosingElement; String updatedImport= getUpdatedImport(importDeclaration); updateImport(cu, importDeclaration, updatedImport); } else { TextChangeCompatibility.addTextEdit(fTextChangeManager.get(cu), RefactoringCoreMessages.RenamePackageRefactoring_update_reference, createTextChange(result)); } } if (fReferencesToTypesInNamesakes.size() != 0) { SearchResultGroup typeRefsRequiringOldNameImport= extractGroupFor(cu, fReferencesToTypesInNamesakes); if (typeRefsRequiringOldNameImport != null) addTypeImports(typeRefsRequiringOldNameImport); } if (fReferencesToTypesInPackage.size() != 0) { SearchResultGroup typeRefsRequiringNewNameImport= extractGroupFor(cu, fReferencesToTypesInPackage); if (typeRefsRequiringNewNameImport != null) updateTypeImports(typeRefsRequiringNewNameImport); } pm.worked(1); } if (fReferencesToTypesInNamesakes.size() != 0) { for (SearchResultGroup referencesToTypesInNamesakes : fReferencesToTypesInNamesakes) { addTypeImports(referencesToTypesInNamesakes); pm.worked(1); } } if (fReferencesToTypesInPackage.size() != 0) { for (SearchResultGroup namesakeReferencesToPackage : fReferencesToTypesInPackage) { updateTypeImports(namesakeReferencesToPackage); pm.worked(1); } } pm.done(); }