Test extractsuperclass.T04 throws the following exception because the refactoring changes the buffer. Therefore, the selection start and length that CodingSpectator captures fail to extract the selection text from the buffer of the type root. Essentially, the problem is that the buffer for which the selection start and length are recorded for is different from the one that CodingSpectator tries to extract the selection text from.
java.lang.StringIndexOutOfBoundsException: String index out of range: 324
at java.lang.String.(String.java:211)
at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:178)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.TextSelectionCodeSnippetInformationExtractor.getSelectedText(TextSelectionCodeSnippetInformationExtractor.java:43)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.TextSelectionCodeSnippetInformationExtractor.extractCodeSnippetInformation(TextSelectionCodeSnippetInformationExtractor.java:36)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.CodeSnippetInformationFactory.extractCodeSnippetInformation(CodeSnippetInformationFactory.java:41)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.CodeSnippetInformationFactory.extractCodeSnippetInformation(CodeSnippetInformationFactory.java:45)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.WatchedProcessorDelegate.getCodeSnippetInformation(WatchedProcessorDelegate.java:65)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.WatchedProcessorDelegate.populateInstrumentationData(WatchedProcessorDelegate.java:39)
at org.eclipse.jdt.internal.corext.refactoring.codingspectator.WatchedProcessorDelegate.getSimpleRefactoringDescriptor(WatchedProcessorDelegate.java:31)
at org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor.getSimpleRefactoringDescriptor(PullUpRefactoringProcessor.java:2096)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.getSimpleRefactoringDescriptor(ProcessorBasedRefactoring.java:466)
at org.eclipse.ltk.core.refactoring.codingspectator.Logger.createRefactoringDescriptor(Logger.java:45)
at org.eclipse.ltk.core.refactoring.codingspectator.Logger.logRefactoringEvent(Logger.java:83)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performCancel(RefactoringWizard.java:666)
at org.eclipse.jface.wizard.WizardDialog.okToClose(WizardDialog.java:933)
at org.eclipse.jface.wizard.WizardDialog.close(WizardDialog.java:483)
at org.eclipse.jface.wizard.WizardDialog.cancelPressed(WizardDialog.java:471)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog.cancelPressed(RefactoringWizardDialog.java:110)
at org.eclipse.jface.wizard.WizardDialog$1.widgetSelected(WizardDialog.java:321)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot$2.run(AbstractSWTBot.java:159)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$5.doRun(UIThreadRunnable.java:221)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run(UIThreadRunnable.java:89)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:186)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:199)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:117)
at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:38)
at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startExtractSupertypeRefactoring(RefactoringExecutionStarter.java:307)
at org.eclipse.jdt.internal.ui.actions.ExtractSuperClassAction.run(ExtractSuperClassAction.java:165)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:230)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:234)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot$2.run(AbstractSWTBot.java:159)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$5.doRun(UIThreadRunnable.java:221)
at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run(UIThreadRunnable.java:89)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3515)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3164)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.swtbot.eclipse.core.UITestApplication.start(UITestApplication.java:54)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Test
extractsuperclass.T04
throws the following exception because the refactoring changes the buffer. Therefore, the selection start and length that CodingSpectator captures fail to extract the selection text from the buffer of the type root. Essentially, the problem is that the buffer for which the selection start and length are recorded for is different from the one that CodingSpectator tries to extract the selection text from.