IllegalStateException during code completion
I believe this could be a regression caused by commit SHA: 1b16c890f1170c2c805fd5a525c5cb5b33d28ed5.
To reproduce the issue
After completing getB you should see the exception in the Error Log view.
java.lang.IllegalStateException: must specify at least one linked position
at org.eclipse.jface.text.link.LinkedModeModel.enforceNotEmpty(LinkedModeModel.java:534)
at org.eclipse.jface.text.link.LinkedModeModel.install(LinkedModeModel.java:487)
at org.eclipse.jface.text.link.LinkedModeModel.forceInstall(LinkedModeModel.java:444)
at scala.tools.eclipse.ui.ScalaCompletionProposal.addArgumentTemplates(ScalaCompletionProposal.scala:190)
at scala.tools.eclipse.ui.ScalaCompletionProposal.apply(ScalaCompletionProposal.scala:142)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:933)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:881)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1307)
at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:807)
at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:491)
at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:65)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270)
at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5936)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5635)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1494)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1490)
at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:493)
at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1060)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5563)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:68)
at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:587)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5473)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2095)
at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2253)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5535)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4989)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5138)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3610)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
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:344)
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:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
To reproduce the issue
// b/B.java
package b;
public class B {
public B getB() { return this; }
}
// A.scala
import b.B
object A {
val b = new B
b.get // ask for code completion and insert `getB()`
}
After completing getB you should see the exception in the Error Log view.
Leave a comment
on 2013-03-12 17:50 *
By Mirco Dotta
Description changed from I believe this is a regress... to I believe this could be a r...
on 2013-03-12 18:15 *
By Mirco Dotta
Description changed from I believe this could be a r... to I believe this could be a r...
on 2013-03-13 00:14 *
By Mirco Dotta
Assigned to set to Mirco Dotta
Status changed from New to Fixed
(In scala-ide:0227cc4b58ecd4f22cd410d7848079993f623431) Don't add arguments templates for parameterless method's completion
When asking for completion on a parameterless method we were trying to install
arguments' templates. This operation in not allowed on parameterless methods,
and it caused a ``java.lang.IllegalStateException: must specify at least one
linked position`` during completion.
``explicitParamNames`` is a ``List[List[String]]`` (because of currying), hence
a parameterless method is represented as ``List(List())``. The arguments'
templates where added only if ``explicitParamNames`` is not empty, however a
``List(List())`` contains exactly one element (the empty list), hence it's
never empty! The fix is really simple, we just need to flatten the
``explicitParamNames`` before checking for emptiness.
Fixes #1001591
backport to release/3.0.x
review by @dragos
(cherry picked from commit d08e999c47f4768179d63c99c7c06268fbea55c7)
Branch: release/scala-ide-3.0.x
When asking for completion on a parameterless method we were trying to install
arguments' templates. This operation in not allowed on parameterless methods,
and it caused a ``java.lang.IllegalStateException: must specify at least one
linked position`` during completion.
``explicitParamNames`` is a ``List[List[String]]`` (because of currying), hence
a parameterless method is represented as ``List(List())``. The arguments'
templates where added only if ``explicitParamNames`` is not empty, however a
``List(List())`` contains exactly one element (the empty list), hence it's
never empty! The fix is really simple, we just need to flatten the
``explicitParamNames`` before checking for emptiness.
Fixes #1001591
backport to release/3.0.x
review by @dragos
(cherry picked from commit d08e999c47f4768179d63c99c7c06268fbea55c7)
Branch: release/scala-ide-3.0.x
on 2013-06-05 17:56 *
By Mirco Dotta
(In scala-ide:d08e999c47f4768179d63c99c7c06268fbea55c7) Don't add arguments templates for parameterless method's completion
When asking for completion on a parameterless method we were trying to install
arguments' templates. This operation in not allowed on parameterless methods,
and it caused a ``java.lang.IllegalStateException: must specify at least one
linked position`` during completion.
``explicitParamNames`` is a ``List[List[String]]`` (because of currying), hence
a parameterless method is represented as ``List(List())``. The arguments'
templates where added only if ``explicitParamNames`` is not empty, however a
``List(List())`` contains exactly one element (the empty list), hence it's
never empty! The fix is really simple, we just need to flatten the
``explicitParamNames`` before checking for emptiness.
Fixes #1001591
backport to release/3.0.x
review by @dragos
Branch: platform/juno
When asking for completion on a parameterless method we were trying to install
arguments' templates. This operation in not allowed on parameterless methods,
and it caused a ``java.lang.IllegalStateException: must specify at least one
linked position`` during completion.
``explicitParamNames`` is a ``List[List[String]]`` (because of currying), hence
a parameterless method is represented as ``List(List())``. The arguments'
templates where added only if ``explicitParamNames`` is not empty, however a
``List(List())`` contains exactly one element (the empty list), hence it's
never empty! The fix is really simple, we just need to flatten the
``explicitParamNames`` before checking for emptiness.
Fixes #1001591
backport to release/3.0.x
review by @dragos
Branch: platform/juno