Code completion throws ArrayIndexOutOfBounds
Eclipse 3.5.2, scala-ide latest trunk
Note that there cannot be any whitespace after "f" at the end. Type ctr+space at the end and whoala:
I will create a patch when I find some spare time.
package foo
class Bar {
val fff = 12
}
class Z extends Bar {
val z = f
Note that there cannot be any whitespace after "f" at the end. Type ctr+space at the end and whoala:
!MESSAGE The 'org.eclipse.jdt.ui.TemplateProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension has thrown a runtime exception.
!STACK 0
java.lang.ArrayIndexOutOfBoundsException
at org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter.getChar(DocumentAdapter.java:360)
at scala.tools.eclipse.ScalaWordFinder$$anon$2.apply(ScalaWordFinder.scala:26)
at scala.tools.eclipse.ScalaWordFinder$$anon$2.apply(ScalaWordFinder.scala:25)
at scala.tools.eclipse.ScalaWordFinder$.findCompletionPoint(ScalaWordFinder.scala:94)
at scala.tools.eclipse.ScalaWordFinder$.findCompletionPoint(ScalaWordFinder.scala:83)
at scala.tools.eclipse.javaelements.ScalaCompletionEngine$$anonfun$complete$1.apply(ScalaCompletionEngine.scala:69)
at scala.tools.eclipse.javaelements.ScalaCompletionEngine$$anonfun$complete$1.apply(ScalaCompletionEngine.scala:37)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply$mcV$sp(Cached.scala:22)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply(Cached.scala:21)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply(Cached.scala:21)
at scala.tools.eclipse.util.Cached$class.locked(Cached.scala:83)
at scala.tools.eclipse.util.Cached$class.apply(Cached.scala:20)
at scala.tools.eclipse.ScalaPresentationCompiler$CachedCompilerResult.apply(ScalaPresentationCompiler.scala:67)
at scala.tools.eclipse.ScalaPresentationCompiler.withCompilerResult(ScalaPresentationCompiler.scala:90)
at scala.tools.eclipse.ScalaProject$$anonfun$withCompilerResult$1.apply(ScalaProject.scala:369)
at scala.tools.eclipse.ScalaProject$$anonfun$withCompilerResult$1.apply(ScalaProject.scala:368)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply$mcV$sp(Cached.scala:22)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply(Cached.scala:21)
at scala.tools.eclipse.util.Cached$$anonfun$apply$1.apply(Cached.scala:21)
at scala.tools.eclipse.util.Cached$class.locked(Cached.scala:83)
at scala.tools.eclipse.util.Cached$class.apply(Cached.scala:20)
at scala.tools.eclipse.ScalaProject$$anon$1.apply(ScalaProject.scala:39)
at scala.tools.eclipse.ScalaProject.withPresentationCompiler(ScalaProject.scala:364)
at scala.tools.eclipse.ScalaProject.withCompilerResult(ScalaProject.scala:368)
at scala.tools.eclipse.javaelements.ScalaCompilationUnit$$anonfun$withCompilerResult$1.apply(ScalaCompilationUnit.scala:49)
at scala.tools.eclipse.javaelements.ScalaCompilationUnit$class.withDocument(ScalaCompilationUnit.scala:41)
at scala.tools.eclipse.javaelements.ScalaSourceFile.withDocument(ScalaSourceFile.scala:40)
at scala.tools.eclipse.javaelements.ScalaCompilationUnit$class.withCompilerResult(ScalaCompilationUnit.scala:49)
at scala.tools.eclipse.javaelements.ScalaSourceFile.withCompilerResult(ScalaSourceFile.scala:40)
at scala.tools.eclipse.javaelements.ScalaCompletionEngine.complete(ScalaCompletionEngine.scala:37)
at scala.tools.eclipse.javaelements.ScalaCompilationUnit$class.codeComplete(ScalaCompilationUnit.scala:166)
at scala.tools.eclipse.javaelements.ScalaSourceFile.codeComplete(ScalaSourceFile.scala:40)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:351)
at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:339)
at org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext.computeKeywordsAndContext(JavaContentAssistInvocationContext.java:279)
at org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext.getCoreContext(JavaContentAssistInvocationContext.java:155)
at org.eclipse.jdt.internal.ui.text.java.TemplateCompletionProposalComputer.computeCompletionEngine(TemplateCompletionProposalComputer.java:68)
at org.eclipse.jdt.internal.ui.text.java.AbstractTemplateCompletionProposalComputer.computeCompletionProposals(AbstractTemplateCompletionProposalComputer.java:58)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:316)
at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:264)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:286)
at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:246)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1832)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1660)
at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:182)
at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
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:1467)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1175)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1200)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1185)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1212)
at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:706)
at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2837)
at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:703)
at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1570)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4594)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4191)
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:7603)
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1185)
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:1860)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3110)
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:597)
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)
I will create a patch when I find some spare time.
Leave a comment
on 2010-08-23 11:31 *
By Hubert Plociniczak
The patch to fix the actual index is easy. However there seems to be an underlying issue with presentation compiler. For the scenario above it will return "no context". I remember Aemon had a similar problem with ENSIME for his code completion.
Surprisingly it works ok (with the patch) if we try to complete "ff" instead of "f". So I will have to dig in the compiler itself.
Surprisingly it works ok (with the patch) if we try to complete "ff" instead of "f". So I will have to dig in the compiler itself.
on 2010-08-24 08:52 *
By Hubert Plociniczak
Along with the commit r22832 in the scala compiler, this patch fixes the problem.
--- a/org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaWordFinder.scala
+++ b/org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaWordFinder.scala
@@ -82,14 +82,15 @@ object ScalaWordFinder extends IScalaWordFinder {
def findCompletionPoint(buffer : IBuffer, offset : Int) : IRegion =
findCompletionPoint(bufferToSeq(buffer), offset)
- def findCompletionPoint(document : Seq[Char], offset : Int) : IRegion = {
+ def findCompletionPoint(document : Seq[Char], offset0 : Int) : IRegion = {
def isWordPart(ch : Char) = isIdentifierPart(ch) || isOperatorPart(ch)
def isWhitespace(ch : Char) =
ch match {
case ' ' | '\t' | CR | LF | FF => true
case _ => false
}
-
+
+ val offset = if (offset0 >= document.length) (document.length - 1) else offset0
val ch = document(offset)
if (isWordPart(ch))
findWord(document, offset)
on 2010-08-24 09:12 *
By
Thanks ... what's EPFLs current take on backporting things like r22832 to the 2.8.x branch?
on 2010-08-26 04:48 *
By Hubert Plociniczak
I will make it happen when we do it.
Applied patch above. Commit 222cbc67018ef0f2dd52403cdb472d169ad037ae, wip_experiment.
Updating tickets (#3255, #3262, #3271, #3277, #3279, #3287, #3313, #3317, #3318, #3320, #3329, #1000000, #1000002, #1000004, #1000005, #1000007, #1000011, #1000013, #1000018, #1000019, #1000020, #1000022, #1000023, #1000024, #1000025, #1000026, #1000028, #1000031, #1000033, #1000034, #1000037, #1000039, #1000040, #1000041, #1000057, #1000058, #1000060, #1000061, #1000063, #1000064, #1000065, #1000067, #1000070, #1000073, #1000076, #1000080, #1000082, #1000083, #1000084, #1000085, #1000087, #1000088, #1000089, #1000090, #1000092, #1000093, #1000094, #1000095, #1000097, #1000102, #1000104, #1000106, #1000108, #1000110, #1000111, #1000116, #1000124, #1000126, #1000127, #1000129, #1000132, #1000133, #1000136, #1000139, #1000143, #1000144, #1000145, #1000148, #1000149, #1000152, #1000154, #1000155, #1000157, #1000158, #1000159, #1000161, #1000169, #1000170, #1000172, #1000174, #1000176, #1000178, #1000179, #1000183, #1000185, #1000188, #1000189, #1000192, #1000196, #1000198)