Overlapping text edits on code completion
If one tries to complete at the cursor position in the following example:
one gets an exception:
object X {
def f(is: InputStream
}
class X
one gets an exception:
org.eclipse.text.edits.MalformedTreeException: Overlapping text edits
at org.eclipse.text.edits.TextEdit$InsertionComparator.compare(TextEdit.java:121)
at java.util.Collections.indexedBinarySearch(Collections.java:332)
at java.util.Collections.binarySearch(Collections.java:320)
at org.eclipse.text.edits.TextEdit.computeInsertionIndex(TextEdit.java:796)
at org.eclipse.text.edits.TextEdit.internalAdd(TextEdit.java:781)
at org.eclipse.text.edits.TextEdit.addChild(TextEdit.java:335)
at org.scalaide.util.internal.eclipse.TextEditUtils$$anon$1$$anonfun$3.apply(TextEditUtils.scala:37)
at org.scalaide.util.internal.eclipse.TextEditUtils$$anon$1$$anonfun$3.apply(TextEditUtils.scala:37)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalaide.util.internal.eclipse.TextEditUtils$$anon$1.<init>(TextEditUtils.scala:37)
at org.scalaide.util.internal.eclipse.TextEditUtils$.createTextFileChange(TextEditUtils.scala:31)
at org.scalaide.util.internal.eclipse.TextEditUtils$$anonfun$applyChangesToFile$1.apply(TextEditUtils.scala:68)
at org.scalaide.util.internal.eclipse.TextEditUtils$$anonfun$applyChangesToFile$1.apply(TextEditUtils.scala:67)
at scala.Option.map(Option.scala:146)
at org.scalaide.util.internal.eclipse.TextEditUtils$.applyChangesToFile(TextEditUtils.scala:67)
at org.scalaide.core.completion.CompletionProposal$$anonfun$applyCompletionToDocument$1.apply(CompletionProposal.scala:238)
at org.scalaide.core.completion.CompletionProposal$$anonfun$applyCompletionToDocument$1.apply(CompletionProposal.scala:211)
at org.scalaide.core.compiler.InteractiveCompilationUnit$$anonfun$withSourceFile$1.apply(InteractiveCompilationUnit.scala:202)
at org.scalaide.core.compiler.InteractiveCompilationUnit$$anonfun$withSourceFile$1.apply(InteractiveCompilationUnit.scala:202)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy$$anonfun$internal$1.apply(PresentationCompilerProxy.scala:105)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy$$anonfun$internal$1.apply(PresentationCompilerProxy.scala:104)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.internal(PresentationCompilerProxy.scala:104)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.apply(PresentationCompilerProxy.scala:62)
at org.scalaide.core.compiler.InteractiveCompilationUnit$class.withSourceFile(InteractiveCompilationUnit.scala:202)
at org.scalaide.core.internal.jdt.model.ScalaSourceFile.withSourceFile(ScalaSourceFile.scala:73)
at org.scalaide.core.completion.CompletionProposal.applyCompletionToDocument(CompletionProposal.scala:211)
at org.scalaide.ui.internal.completion.ScalaCompletionProposalImpl$$anonfun$apply$1.apply(ScalaCompletionProposalImpl.scala:133)
at org.scalaide.ui.internal.completion.ScalaCompletionProposalImpl$$anonfun$apply$1.apply(ScalaCompletionProposalImpl.scala:132)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1$$anonfun$apply$14$$anonfun$apply$15.apply(EditorUtils.scala:185)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1$$anonfun$apply$14$$anonfun$apply$15.apply(EditorUtils.scala:184)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1$$anonfun$apply$14.apply(EditorUtils.scala:184)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1$$anonfun$apply$14.apply(EditorUtils.scala:183)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1.apply(EditorUtils.scala:183)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withScalaFileAndSelection$1.apply(EditorUtils.scala:182)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9$$anonfun$apply$10$$anonfun$apply$11.apply(EditorUtils.scala:166)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9$$anonfun$apply$10$$anonfun$apply$11.apply(EditorUtils.scala:165)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9$$anonfun$apply$10.apply(EditorUtils.scala:165)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9$$anonfun$apply$10.apply(EditorUtils.scala:164)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9.apply(EditorUtils.scala:164)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1$$anonfun$apply$9.apply(EditorUtils.scala:163)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1.apply(EditorUtils.scala:163)
at org.scalaide.util.eclipse.EditorUtils$$anonfun$withCurrentEditor$1.apply(EditorUtils.scala:162)
at scala.Option.flatMap(Option.scala:171)
at org.scalaide.util.eclipse.EditorUtils$.withCurrentEditor(EditorUtils.scala:162)
at org.scalaide.util.eclipse.EditorUtils$.withScalaFileAndSelection(EditorUtils.scala:182)
at org.scalaide.ui.internal.completion.ScalaCompletionProposalImpl.apply(ScalaCompletionProposalImpl.scala:132)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:963)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:914)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1358)
at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:814)
at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:492)
at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:66)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1182)
at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5981)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5663)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1424)
at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:824)
at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3293)
at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:769)
at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2098)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:5534)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4668)
at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9106)
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1253)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2477)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3407)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:832)
at org.eclipse.jface.window.Window.open(Window.java:808)
at org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:181)
at org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:98)
at org.eclipse.ui.internal.views.log.LogView$15.doubleClick(LogView.java:537)
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:831)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:828)
at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1472)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1237)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Leave a comment
on 2015-12-21 07:56 *
By Simon Schäfer
Discussion on the mailing list: https://groups.google.com/forum/#!topic/scala-ide-user/PEg8NCD5unU
on 2015-12-22 17:40 *
By Simon Schäfer
Description changed from If one tries to complete at... to If one tries to complete at...
Do not call balanceBracketsInLayout for erroneous trees
This function can only handle syntactical valid documents.
Fixes #1002619
Branch: master
Commit: scala-ide:712b7bc948
This function can only handle syntactical valid documents.
Fixes #1002619
Branch: master
Commit: scala-ide:712b7bc948