Bug 60795 Error while saving dirty text editor of deleted file.
When focus is restored to a dirty text editor of a file that has been deleted, the user will be prompted to save or close that editor. If the choose save and then attempt to save the file with the same name as it had before, an error log is generated. Steps to reproduce: 1) Create a new file (i.e. Simple>File) in the project. 2) Modify the contents of the file so the editor is dirty. 3) Delete the file using the Navigator View. 4) Set Focus to the dirty editor. 5) Click "Save" on the dialog that appears. 6) Attempt to save the file as is with the same file name. When you click the "OK" button, the following error appears in the Error Log View: java.lang.IllegalArgumentException: Attempted to beginRule: P/org.eclipse.examples.wizard, does not match outer scope rule: L/org.eclipse.examples.wizard/Sample File at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java:58) at org.eclipse.core.internal.jobs.ImplicitJobs$ThreadJob.illegalPush(ImplicitJobs.java:116) at org.eclipse.core.internal.jobs.ImplicitJobs$ThreadJob.push(ImplicitJobs.java:207) at org.eclipse.core.internal.jobs.ImplicitJobs.begin(ImplicitJobs.java:321) at org.eclipse.core.internal.jobs.JobManager.beginRule(JobManager.java:163) at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:95) at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1603) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1643) at org.eclipse.core.internal.filebuffers.ContainerGenerator.generateContainer(ContainerGenerator.java:115) at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.commitFileBufferContent(ResourceTextFileBuffer.java:254) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer.commit(ResourceFileBuffer.java:275) at org.eclipse.ui.editors.text.TextFileDocumentProvider.commitFileBuffer(TextFileDocumentProvider.java:672) at org.eclipse.ui.editors.text.TextFileDocumentProvider$2.execute(TextFileDocumentProvider.java:634) at org.eclipse.ui.editors.text.TextFileDocumentProvider$DocumentProviderOperation.run(TextFileDocumentProvider.java:96) at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:67) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:91) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1648) at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:105) at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:73) at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:63) at org.eclipse.ui.editors.text.TextFileDocumentProvider.executeOperation(TextFileDocumentProvider.java:395) at org.eclipse.ui.editors.text.TextFileDocumentProvider.saveDocument(TextFileDocumentProvider.java:615) at org.eclipse.ui.editors.text.TextEditor.performSaveAs(TextEditor.java:175) at org.eclipse.ui.texteditor.AbstractTextEditor.handleEditorInputChanged(AbstractTextEditor.java:3042) at org.eclipse.ui.texteditor.AbstractTextEditor.sanityCheckState(AbstractTextEditor.java:3187) at org.eclipse.ui.texteditor.StatusTextEditor.sanityCheckState(StatusTextEditor.java:193) at org.eclipse.ui.texteditor.AbstractTextEditor.safelySanityCheckState(AbstractTextEditor.java:3165) at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.handleActivation(AbstractTextEditor.java:730) at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.partActivated(AbstractTextEditor.java:676) at org.eclipse.ui.internal.PartListenerList$1.run(PartListenerList.java:49) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:599) at org.eclipse.core.runtime.Platform.run(Platform.java:543) at org.eclipse.ui.internal.PartListenerList.firePartActivated(PartListenerList.java:47) at org.eclipse.ui.internal.WWinPartService$1.partActivated(WWinPartService.java:27) at org.eclipse.ui.internal.PartListenerList2$1.run(PartListenerList2.java:45) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:599) at org.eclipse.core.runtime.Platform.run(Platform.java:543) at org.eclipse.ui.internal.PartListenerList2.firePartActivated(PartListenerList2.java:43) at org.eclipse.ui.internal.WorkbenchPage.firePartActivated(WorkbenchPage.java:1297) at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:2595) at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:2290) at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:246) at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:167) at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:226) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:801) at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:913) at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:1452) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2991) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1451) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:1454) at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:77) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3032) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3158) at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:1868) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2264) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java
entry= (Entry) fList.get(i);
					if (entry.fPosition.equals(position)) {
						fAnchor= i;
						return entry.fValue;
					}
				}
				
				
				for (int i= 0; i < fAnchor; i++) {
					entry= (Entry) fList.get(i);
					if (entry.fPosition.equals(position)) {
						fAnchor= i;
						return entry.fValue;
					}
				}
				
				return null;
			}
			
			private int getIndex(Position position) {
				Entry entry;
				int length= fList.size();
				for (int i= 0; i < length; i++) {
					entry= (Entry) fList.get(i);
					if (entry.fPosition.equals(position))
						return i;
				}
				return -1;
			}