Source:
<code>protected void registerChanges(final TextEditBasedChangeManager manager) throws CoreException { try { final ICompilationUnit extractedUnit= getExtractedType().getCompilationUnit(); ICompilationUnit unit= null; CompilationUnitRewrite rewrite= null; for (final Iterator<ICompilationUnit> iterator= fCompilationUnitRewrites.keySet().iterator(); iterator.hasNext();) { unit= iterator.next(); if (unit.equals(extractedUnit)) { rewrite= fCompilationUnitRewrites.get(unit); if (rewrite != null) { CompilationUnitChange change= rewrite.createChange(true); if (change != null) { final TextEdit edit= ((TextChange) change).getEdit(); if (edit != null) { final IDocument document= new Document(fSuperSource); try { edit.apply(document, TextEdit.UPDATE_REGIONS); } catch (MalformedTreeException exception) { JavaPlugin.log(exception); } catch (BadLocationException exception) { JavaPlugin.log(exception); } fSuperSource= document.get(); manager.remove(extractedUnit); } } } } else { rewrite= fCompilationUnitRewrites.get(unit); if (rewrite != null) { final CompilationUnitChange layerChange= fLayerChanges.get(unit.getPrimary()); final CompilationUnitChange rewriteChange= rewrite.createChange(true); if (rewriteChange != null && layerChange != null) { final MultiStateCompilationUnitChange change= new MultiStateCompilationUnitChange(rewriteChange.getName(), unit); change.addChange(layerChange); change.addChange(rewriteChange); fLayerChanges.remove(unit.getPrimary()); manager.manage(unit, change); } else if (layerChange != null) { manager.manage(unit, layerChange); fLayerChanges.remove(unit.getPrimary()); } else if (rewriteChange != null) { manager.manage(unit, rewriteChange); } } } } for (Entry<ICompilationUnit, CompilationUnitChange> entry : fLayerChanges.entrySet()) { manager.manage(entry.getKey(), entry.getValue()); } for (ICompilationUnit <START> u : <END> manager.getAllCompilationUnits()) { if (u.getPath().equals(extractedUnit.getPath())) { manager.remove(u); } } } finally { fLayerChanges.clear(); } }</code><technical_language>rename cu</technical_language>

Target:
protected void registerChanges(final TextEditBasedChangeManager manager) throws CoreException { try { final ICompilationUnit extractedUnit= getExtractedType().getCompilationUnit(); ICompilationUnit unit= null; CompilationUnitRewrite rewrite= null; for (final Iterator<ICompilationUnit> iterator= fCompilationUnitRewrites.keySet().iterator(); iterator.hasNext();) { unit= iterator.next(); if (unit.equals(extractedUnit)) { rewrite= fCompilationUnitRewrites.get(unit); if (rewrite != null) { CompilationUnitChange change= rewrite.createChange(true); if (change != null) { final TextEdit edit= ((TextChange) change).getEdit(); if (edit != null) { final IDocument document= new Document(fSuperSource); try { edit.apply(document, TextEdit.UPDATE_REGIONS); } catch (MalformedTreeException exception) { JavaPlugin.log(exception); } catch (BadLocationException exception) { JavaPlugin.log(exception); } fSuperSource= document.get(); manager.remove(extractedUnit); } } } } else { rewrite= fCompilationUnitRewrites.get(unit); if (rewrite != null) { final CompilationUnitChange layerChange= fLayerChanges.get(unit.getPrimary()); final CompilationUnitChange rewriteChange= rewrite.createChange(true); if (rewriteChange != null && layerChange != null) { final MultiStateCompilationUnitChange change= new MultiStateCompilationUnitChange(rewriteChange.getName(), unit); change.addChange(layerChange); change.addChange(rewriteChange); fLayerChanges.remove(unit.getPrimary()); manager.manage(unit, change); } else if (layerChange != null) { manager.manage(unit, layerChange); fLayerChanges.remove(unit.getPrimary()); } else if (rewriteChange != null) { manager.manage(unit, rewriteChange); } } } } for (Entry<ICompilationUnit, CompilationUnitChange> entry : fLayerChanges.entrySet()) { manager.manage(entry.getKey(), entry.getValue()); } for (ICompilationUnit cu : manager.getAllCompilationUnits()) { if (cu.getPath().equals(extractedUnit.getPath())) { manager.remove(cu); } } } finally { fLayerChanges.clear(); } }