Project: JDT
Bug 280123 [typing] BadLocationException when pasting word "default" outside of class
Reported: 2009-06-12 14:44:58 | Status: resolved fixed

- copy the word "default" (without the quotes) to the clipboard - create a new class, it will look like public class Test2 { } - put the caret on the line following the class' closing brace and press Ctrl+V -> an internal error is logged with the stack below org.eclipse.jface.text.BadLocationException at org.eclipse.jface.text.TreeLineTracker.fail(TreeLineTracker.java:1061) at org.eclipse.jface.text.TreeLineTracker.getLineInformationOfOffset(TreeLineTracker.java:1157) at org.eclipse.jface.text.AbstractLineTracker.getLineInformationOfOffset(AbstractLineTracker.java:145) at org.eclipse.jface.text.AbstractDocument.getLineInformationOfOffset(AbstractDocument.java:902) at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineInformationOfOffset(SynchronizableDocument.java:353) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.smartPaste(JavaAutoIndentStrategy.java:663) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.customizeDocumentCommand(JavaAutoIndentStrategy.java:1224) at org.eclipse.jface.text.TextViewer.customizeDocumentCommand(TextViewer.java:3734) at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:3764) at org.eclipse.jface.text.source.projection.ProjectionViewer.handleVerifyEvent(ProjectionViewer.java:1276) at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:433) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:828) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:849) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:835) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:607) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:6602) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:7442) at org.eclipse.swt.custom.StyledText.paste(StyledText.java:6690) at org.eclipse.jface.text.TextViewer.paste(TextViewer.java:4026) at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3970) at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:921) at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1533) at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:186) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:199) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.doPasteWithImportsOperation(ClipboardOperationAction.java:501) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.internalDoOperation(ClipboardOperationAction.java:287) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction$1.run(ClipboardOperationAction.java:258) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.run(ClipboardOperationAction.java:256) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:125) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:904) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:849) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:835) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:941) at org.eclipse.swt.widgets.Widget.XKeyPress(Widget.java:1166) at org.eclipse.swt.widgets.Composite.XKeyPress(Composite.java:1437) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1112) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3773) at org.eclipse.swt.internal.motif.OS._XtDispatchEvent(Native Method) at org.eclipse.swt.internal.motif.OS.XtDispatchEvent(OS.java:5099) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2829) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194) 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:368) 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:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514) at org.eclipse.equinox.launcher.Main.run(Main.java:1311) at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

Files changed in fix:
org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java