scijava / script-editor

Script Editor and Interpreter for SciJava script languages
http://imagej.net/Script_Editor
BSD 2-Clause "Simplified" License
12 stars 11 forks source link

Random syntax parsing errors when opening scripts #14

Closed AVHon closed 2 years ago

AVHon commented 6 years ago

Sometimes, when I open a script, an error message pops up. This only happens some times when I open a sript. I have not been able to find any pattern. If I open and close the same file several times, some times I will get an error, and some times I won't.

Here is an example from opening a Python script:

Exception in thread "Thread-5" java.lang.Error: Error: could not match input
    at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.zzScanError(PythonTokenMaker.java:881)
    at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.yylex(PythonTokenMaker.java:1081)
    at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.getTokenList(PythonTokenMaker.java:705)
    at org.fife.ui.rsyntaxtextarea.TokenMakerBase.getLastTokenTypeOnLine(TokenMakerBase.java:225)
    at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.updateSyntaxHighlightingInformation(RSyntaxDocument.java:666)
    at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.setSyntaxStyle(RSyntaxDocument.java:548)
    at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.setSyntaxEditingStyle(RSyntaxTextArea.java:2909)
    at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:501)
    at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:445)
    at org.scijava.ui.swing.script.EditorPane.setLanguageByFileName(EditorPane.java:433)
    at org.scijava.ui.swing.script.TextEditor.stateChanged(TextEditor.java:1221)
    at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:416)
    at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:270)
    at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:132)
    at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:67)
    at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:616)
    at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:591)
    at org.scijava.ui.swing.script.TextEditor.switchTo(TextEditor.java:2155)
    at org.scijava.ui.swing.script.TextEditor.open(TextEditor.java:1382)
    at org.scijava.ui.swing.script.TextEditor$15.run(TextEditor.java:1045)

Here is another example from opening an IJ1 macro:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Error: could not match input
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.zzScanError(ImageJMacroTokenMaker.java:2619)
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.yylex(ImageJMacroTokenMaker.java:2878)
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.getTokenList(ImageJMacroTokenMaker.java:2469)
    at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.getTokenListForLine(RSyntaxDocument.java:431)
    at org.fife.ui.rsyntaxtextarea.SyntaxView.paint(SyntaxView.java:728)
    at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1434)
    at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:737)
    at org.fife.ui.rtextarea.RTextAreaUI.paintSafely(RTextAreaUI.java:539)
    at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:881)
    at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:860)
    at org.fife.ui.rtextarea.RTextAreaBase.paintComponent(RTextAreaBase.java:735)
    at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.paintComponent(RSyntaxTextArea.java:2072)
    at javax.swing.JComponent.paint(JComponent.java:1056)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at javax.swing.JViewport.paint(JViewport.java:728)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at javax.swing.JComponent.paintChildren(JComponent.java:889)
    at javax.swing.JComponent.paint(JComponent.java:1065)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:306)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
    at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
    at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
    at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Here is another example, form opening the same IJ1 macro. (exactly the same)

Exception in thread "Thread-9" java.lang.Error: Error: could not match input
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.zzScanError(ImageJMacroTokenMaker.java:2619)
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.yylex(ImageJMacroTokenMaker.java:2878)
    at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.getTokenList(ImageJMacroTokenMaker.java:2469)
    at org.fife.ui.rsyntaxtextarea.TokenMakerBase.getLastTokenTypeOnLine(TokenMakerBase.java:225)
    at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.updateSyntaxHighlightingInformation(RSyntaxDocument.java:666)
    at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.setSyntaxStyle(RSyntaxDocument.java:548)
    at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.setSyntaxEditingStyle(RSyntaxTextArea.java:2909)
    at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:501)
    at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:445)
    at org.scijava.ui.swing.script.EditorPane.setLanguageByFileName(EditorPane.java:433)
    at org.scijava.ui.swing.script.EditorPane.setFileName(EditorPane.java:379)
    at org.scijava.ui.swing.script.TextEditor.setEditorPaneFileName(TextEditor.java:1683)
    at org.scijava.ui.swing.script.TextEditor.open(TextEditor.java:1386)
    at org.scijava.ui.swing.script.TextEditor$15.run(TextEditor.java:1045)

Most of the time, these errors don't seem to represent any actual problem -- the only unexpected behavior is that an error popped up. Sometimes, however, the syntax parser actually fails. For me, this always manifests itself in the same way: starting from some line in the middle of the file, every line below it is highlighted as a comment. I can fix this by going to the last line that isn't highlighted as a comment, commenting it out, and then uncommenting it. This always corrects the syntax highlighting for the rest of the file.

ImageJ 1.51t, Fiji Distribution, Java 1.8.0_66 (64-bit)

imagesc-bot commented 2 years ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/shiny-new-script-editor/64160/16

imagesc-bot commented 2 years ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/shiny-new-script-editor/64160/23

tferr commented 2 years ago

This seems to be fixed now (or at least there is a workaround)