[BLUEJ-1176] Exception during editing / Scope highlighting fails
Enter the following code in a class (important: the last line is followed by a newline): {code:java} class PRIME_NUMBER { static void main() { int i,j,count=0,c=0;{ for (i=1;count<=50;i++) { for(j=1;j<=i;j++) { if(i%j==0) c++; } System.out.println(c); if(c==2) System.out.println(i+" "); count++; } } }} {code} Position the cursor on the first line inside the body of the main method, between "c=0;" and the following "{" and press enter.
Scope highlighting is drawn incorrectly, and the following exception is generated:
{code:java}
Apr 05, 2018 11:39:20 AM javafx.beans.binding.Bindings$6 computeValue
WARNING: Exception while evaluating binding
java.lang.IndexOutOfBoundsException: -9, 0
at com.sun.prism.Image$BaseAccessor.getIndex(Image.java:933)
at com.sun.prism.Image$BaseAccessor.setArgb(Image.java:978)
at com.sun.prism.Image.setArgb(Image.java:647)
at javafx.scene.image.WritableImage$2.setArgb(WritableImage.java:170)
at javafx.scene.image.WritableImage$2.setColor(WritableImage.java:181)
at bluej.editor.moe.BlueJSyntaxView.drawImageFor(BlueJSyntaxView.java:374)
at bluej.editor.moe.BlueJSyntaxView.lambda$new$0(BlueJSyntaxView.java:185)
at java.util.HashMap.computeIfAbsent(HashMap.java:1126)
at bluej.utility.javafx.FXCache.get(FXCache.java:73)
at bluej.editor.moe.BlueJSyntaxView.getImageFor(BlueJSyntaxView.java:290)
at bluej.editor.moe.MoeEditorPane.lambda$null$0(MoeEditorPane.java:107)
at javafx.beans.binding.Bindings$6.computeValue(Bindings.java:338)
at javafx.beans.binding.ObjectBinding.get(ObjectBinding.java:153)
at javafx.beans.binding.ObjectExpression.getValue(ObjectExpression.java:50)
at javafx.beans.property.ObjectPropertyBase.get(ObjectPropertyBase.java:132)
at javafx.scene.layout.Region$3.invalidated(Region.java:578)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
at javafx.beans.property.ObjectPropertyBase.access$000(ObjectPropertyBase.java:51)
at javafx.beans.property.ObjectPropertyBase$Listener.invalidated(ObjectPropertyBase.java:233)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
at javafx.beans.binding.ObjectBinding.invalidate(ObjectBinding.java:172)
at com.sun.javafx.binding.BindingHelperObserver.invalidated(BindingHelperObserver.java:51)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
at javafx.beans.property.ReadOnlyDoublePropertyBase.fireValueChangedEvent(ReadOnlyDoublePropertyBase.java:72)
at javafx.beans.property.ReadOnlyDoubleWrapper.fireValueChangedEvent(ReadOnlyDoubleWrapper.java:103)
at javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113)
at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:147)
at javafx.scene.layout.Region.setHeight(Region.java:917)
at javafx.scene.layout.Region.resize(Region.java:1365)
at javafx.scene.Node.resizeRelocate(Node.java:2943)
at org.fxmisc.richtext.ParagraphBox.layoutChildren(ParagraphBox.java:217)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at org.fxmisc.flowless.VirtualFlow.layoutChildren(VirtualFlow.java:165)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at bluej.editor.moe.MoeSyntaxDocument.applyPendingScopeBackgrounds(MoeSyntaxDocument.java:618)
at bluej.editor.moe.ReparseRunner.run(ReparseRunner.java:68)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)
{code}
Issue metadata
- Issue type: Bug
- Priority: Medium
- Fix versions: 4.5.0