Bug 22624 Rename CU quick fix: Exception when renaming to an existing CU:
20020820 Java Model Exception: Java Model Status [Name collision.] at org.eclipse.jdt.internal.core.MultiOperation.processElements (MultiOperation.java:207) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElements (CopyResourceElementsOperation.java:343) at org.eclipse.jdt.internal.core.MultiOperation.executeOperation (MultiOperation.java:98) at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:305) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:513) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1361) at org.eclipse.jdt.internal.core.JavaModelManager.runOperation (JavaModelManager.java:1207) at org.eclipse.jdt.internal.core.JavaElement.runOperation (JavaElement.java:574) at org.eclipse.jdt.internal.core.JavaModel.rename(JavaModel.java:437) at org.eclipse.jdt.internal.core.CompilationUnit.rename (CompilationUnit.java:819) at org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange. doRename(RenameCompilationUnitChange.java:50) at org.eclipse.jdt.internal.corext.refactoring.AbstractJavaElementRenameChange.perf orm(AbstractJavaElementRenameChange.java:67) at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply (ChangeCorrectionProposal.java:59) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal (CompletionProposalPopup.java:232) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposal (CompletionProposalPopup.java:208) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$13 (CompletionProposalPopup.java:204) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.widgetDefaultSele cted(CompletionProposalPopup.java:177) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:94) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1177) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:775) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24) !ENTRY org.eclipse.jdt.core 4 977 Aug 21, 2002 12:18:53.273 !MESSAGE Name collision. !ENTRY org.eclipse.jdt.ui 4 1 Aug 21, 2002 12:18:53.283 !MESSAGE Internal Error !STACK 0 ChangeAbortException: org.eclipse.jdt.internal.corext.refactoring.base.ChangeAbortException at org.eclipse.jdt.internal.ui.refactoring.changes.AbortChangeExceptionHandler.hand le(AbortChangeExceptionHandler.java:22) at org.eclipse.jdt.internal.corext.refactoring.base.Change.handleException (Change.java:99) at org.eclipse.jdt.internal.corext.refactoring.AbstractJavaElementRenameChange.perf orm(AbstractJavaElementRenameChange.java:72) at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply (ChangeCorrectionProposal.java:59) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal (CompletionProposalPopup.java:232) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposal (CompletionProposalPopup.java:208) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$13 (CompletionProposalPopup.java:204) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.widgetDefaultSele cted(CompletionProposalPopup.java:177) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:94) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1177) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:775) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24) Exception wrapped by ChangeAbortException: Java Model Exception: Java Model Status [Name collision.] at org.eclipse.jdt.internal.core.MultiOperation.processElements (MultiOperation.java:207) at org.eclipse.jdt.internal.core.CopyResourceElementsOperation.processElements (CopyResourceElementsOperation.java:343) at org.eclipse.jdt.internal.core.MultiOperation.executeOperation (MultiOperation.java:98) at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:305) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:513) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1361) at org.eclipse.jdt.internal.core.JavaModelManager.runOperation (JavaModelManager.java:1207) at org.eclipse.jdt.internal.core.JavaElement.runOperation (JavaElement.java:574) at org.eclipse.jdt.internal.core.JavaModel.rename(JavaModel.java:437) at org.eclipse.jdt.internal.core.CompilationUnit.rename (CompilationUnit.java:819) at org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange. doRename(RenameCompilationUnitChange.java:50) at org.eclipse.jdt.internal.corext.refactoring.AbstractJavaElementRenameChange.perf orm(AbstractJavaElementRenameChange.java:67) at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply (ChangeCorrectionProposal.java:59) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal (CompletionProposalPopup.java:232) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposal (CompletionProposalPopup.java:208) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$13 (CompletionProposalPopup.java:204) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.widgetDefaultSele cted(CompletionProposalPopup.java:177) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:94) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1177) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:775) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java
int line= buffer.getLineOfOffset(problemPos.getOffset());
			if (line != -1) {
				TextRegion region= buffer.getLineInformation(line);
				int start= region.getOffset();
				int end= start + region.getLength();
				if (line > 0) {
					region= buffer.getLineInformation(line - 1);
					start= region.getOffset() + region.getLength();
				} 
				String label= CorrectionMessages.getString("ReorgCorrectionsSubProcessor.unusedimport.description"); 
				ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, problemPos.getCompilationUnit(), start, end - start, "", 0); 
				proposal.setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_DELETE_IMPORT));
				proposals.add(proposal); 
			}
		} finally {
			if (buffer != null) {
				TextBuffer.release(buffer);
			}
		 }
	}
		
	private static TextBuffer aquireTextBuffer(ICompilationUnit cu) throws CoreException {
		if (cu.isWorkingCopy()) {
			cu= (ICompilationUnit) cu.getOriginalElement();
		}		
		IFile file= (IFile) cu.getUnderlyingResource();
		return TextBuffer.acquire(file);
	}		
}