Bug 117468 [misc] BadLocationException when moving type
I20051116-1332 + plugin-export 20051122_1135 Have a type in a non-default package. Open the type in the editor, put the caret into the last line. Now move the compilation unit into the default package (drag&drop or select Move... on the file in the package explorer). Move it back. Both move operations give the following result: org.eclipse.jface.text.BadLocationException at org.eclipse.jface.text.AbstractLineTracker.fail(AbstractLineTracker.java:1006) at org.eclipse.jface.text.AbstractLineTracker.nodeByOffset(AbstractLineTracker.java:252) at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:1100) at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:873) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$RememberedOffset.setOffset(CompilationUnitEditor.java:940) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$RememberedSelection.remember(CompilationUnitEditor.java:821) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.rememberSelection(CompilationUnitEditor.java:1946) at org.eclipse.ui.texteditor.AbstractTextEditor$7.run(AbstractTextEditor.java:393) at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.execute(AbstractTextEditor.java:464) at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.elementMoved(AbstractTextEditor.java:425) at org.eclipse.ui.editors.text.TextFileDocumentProvider$FileBufferListener.underlyingFileMoved(TextFileDocumentProvider.java:311) at org.eclipse.core.internal.filebuffers.TextFileBufferManager$6.run(TextFileBufferManager.java:458) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.core.internal.filebuffers.TextFileBufferManager.fireUnderlyingFileMoved(TextFileBufferManager.java:456) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer.handleFileMoved(ResourceFileBuffer.java:432) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer$3.execute(ResourceFileBuffer.java:155) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer$SafeFileChange.run(ResourceFileBuffer.java:80) at org.eclipse.ui.internal.editors.text.UISynchronizationContext.run(UISynchronizationContext.java:34) at org.eclipse.core.internal.filebuffers.TextFileBufferManager.execute(TextFileBufferManager.java:396) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer$FileSynchronizer.resourceChanged(ResourceFileBuffer.java:172) at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:276) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:270) at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:144) at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:186) at org.eclipse.core.internal.resources.Workspace.checkpoint(Workspace.java:249) at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:237) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1705) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1725) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:280) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.access$1(UIPerformChangeOperation.java:1) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$1.run(UIPerformChangeOperation.java:63) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044) at org.eclipse.core.runtime.Platform.run(Platform.java:783) at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation$2.run(UIPerformChangeOperation.java:81) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3217) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2863) at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:153) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:303) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:308) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:544) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveWizard$MoveInputPage.performFinish(ReorgMoveWizard.java:113) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:610) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:432) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:460) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:607) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:896) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3240) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2860) at org.eclipse.jface.window.Window.runEventLoop(Window.java:808) at org.eclipse.jface.window.Window.open(Window.java:786) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:131) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:144) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startRefactoring(RefactoringExecutionStarter.java:326) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:108) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:245) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:221) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:127) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:245) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:221) at org.eclipse.jface.action.Action.runWithEvent(Action.java:1000) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:530) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:480) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:392) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:896) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3240) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2860) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1789) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1753) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:378) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:106) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:165) 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:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338) at org.eclipse.core.launcher.Main.basicRun(Main.java:282) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
}
				});
			}
		}
		/*
		 * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
		 */
		public void suspend(LinkedModeModel environment) {
		}
		/*
		 * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
		 */
		public void resume(LinkedModeModel environment, int flags) {
		}
	}
	/**
	 * Remembers data related to the current selection to be able to
	 * restore it later.
	 *
	 * @since 3.0
	 */
	private class RememberedSelection {
		
		private RememberedOffset fStartOffset= new RememberedOffset();
		
		private RememberedOffset fEndOffset= new RememberedOffset();
		/**
		 * Remember current selection.
		 */
		public void remember() {