Lexer advance() called before start()? Threading issues?

In my lexer start() method I set the input stream for my lexer to feed off of the text sent in by intellij.  Somehow, advance() is being called before the input is set up, which implies that it's been called before start() which doesn't make any sense. THEN, I noticed the following output:

[  12231]  ERROR - currency.PrioritizedFutureTask - IntelliJ IDEA (Community Edition) IC-132.SNAPSHOT  Build #IC-132.SNAPSHOT
[  12232]  ERROR - currency.PrioritizedFutureTask - IntelliJ IDEA (Community Edition) IC-132.SNAPSHOT  Build #IC-132.SNAPSHOT
[  12232]  ERROR - currency.PrioritizedFutureTask - JDK: 1.7.0_21
[  12232]  ERROR - currency.PrioritizedFutureTask - VM: Java HotSpot(TM) 64-Bit Server VM
[  12232]  ERROR - currency.PrioritizedFutureTask - JDK: 1.7.0_21
[  12232]  ERROR - currency.PrioritizedFutureTask - VM: Java HotSpot(TM) 64-Bit Server VM
[  12232]  ERROR - currency.PrioritizedFutureTask - Vendor: Oracle Corporation
[  12232]  ERROR - currency.PrioritizedFutureTask - OS: Mac OS X
[  12232]  ERROR - currency.PrioritizedFutureTask - Last Action:  
[  12232]  ERROR - currency.PrioritizedFutureTask - Vendor: Oracle Corporation
[  12233]  ERROR - currency.PrioritizedFutureTask - OS: Mac OS X
[  12233]  ERROR - currency.PrioritizedFutureTask - Last Action:  


I somehow convinced it to launch two versions when I hit debug?  I don't think it does that when I hit just run to launch the plug-in in a new intellij. However, I do see something suspicious about  threads when I just run and not debug:

[  45315]   WARN - tellij.ide.HackyRepaintManager - Access to realized (ever shown) UI components should be done only from the AWT event dispatch thread, revalidate(), invalidate() & repaint() is ok from any thread
java.lang.Exception
 at com.intellij.ide.IdeRepaintManager.checkThreadViolations(IdeRepaintManager.java:135)
 at com.intellij.ide.IdeRepaintManager.addDirtyRegion(IdeRepaintManager.java:125)
 at javax.swing.JComponent.repaint(JComponent.java:4795)
 at java.awt.Component.repaint(Component.java:3286)
 at javax.swing.JTree.treeDidChange(JTree.java:2933)
 at javax.swing.plaf.basic.BasicTreeUI.updateSize(BasicTreeUI.java:1848)


Sorry for all of the questions. All I did was add a structure view element (3 classes) from this page:

http://confluence.jetbrains.com/display/IntelliJIDEA/Structure+View+Factory

and then add the extension

    <lang.psiStructureViewFactory language="Simple"
        implementationClass="com.simpleplugin.structview.SimpleStructureViewFactory"/>


Oh! Perhaps the structure viewer is launching another thread to parse the file in order to create the PSI tree from which it creates its structure tree. That brings us to the real question: what are the rules regarding thread safety? I currently share a lexer for all purposes. Do I need to create a new lexer object from the createLexer() method in the parser definition class?

Ter
2 comments

Yes! Lexers / parsers are used from different threads.

On 9/26/2013 5:39 AM, Terence Parr wrote:

In my lexer start() method I set the input stream for my lexer to feed off of the text sent in by intellij.  Somehow, advance() is being called before the input is set up, which implies that it's been called before start() which doesn't make any sense. THEN, I noticed the following output:

>

  ERROR - currency.PrioritizedFutureTask - IntelliJ IDEA (Community Edition) IC-132.SNAPSHOT  Build #IC-132.SNAPSHOT
  ERROR - currency.PrioritizedFutureTask - IntelliJ IDEA (Community Edition) IC-132.SNAPSHOT  Build #IC-132.SNAPSHOT
  ERROR - currency.PrioritizedFutureTask - JDK: 1.7.0_21
  ERROR - currency.PrioritizedFutureTask - VM: Java HotSpot(TM) 64-Bit Server VM
  ERROR - currency.PrioritizedFutureTask - JDK: 1.7.0_21
  ERROR - currency.PrioritizedFutureTask - VM: Java HotSpot(TM) 64-Bit Server VM
  ERROR - currency.PrioritizedFutureTask - Vendor: Oracle Corporation
  ERROR - currency.PrioritizedFutureTask - OS: Mac OS X
  ERROR - currency.PrioritizedFutureTask - Last Action:
  ERROR - currency.PrioritizedFutureTask - Vendor: Oracle Corporation
  ERROR - currency.PrioritizedFutureTask - OS: Mac OS X
  ERROR - currency.PrioritizedFutureTask - Last Action:

>

I somehow convinced it to launch two versions when I hit debug?  I don't think it does that when I hit just run to launch the plug-in in a new intellij. However, I do see something suspicious about  threads when I just run and not debug:

>

   WARN - tellij.ide.HackyRepaintManager - Access to realized (ever shown) UI components should be done only from the AWT event dispatch thread, revalidate(), invalidate() & repaint() is ok from any thread
java.lang.Exception
  at com.intellij.ide.IdeRepaintManager.checkThreadViolations(IdeRepaintManager.java:135)
  at com.intellij.ide.IdeRepaintManager.addDirtyRegion(IdeRepaintManager.java:125)
  at javax.swing.JComponent.repaint(JComponent.java:4795)
  at java.awt.Component.repaint(Component.java:3286)
  at javax.swing.JTree.treeDidChange(JTree.java:2933)
  at javax.swing.plaf.basic.BasicTreeUI.updateSize(BasicTreeUI.java:1848)

>

Sorry for all of the questions. All I did was add a structure view element (3 classes) from this page:

>

http://confluence.jetbrains.com/display/IntelliJIDEA/StructureViewFactory

>

and then add the extension

>

     <lang.psiStructureViewFactory language="Simple"
         implementationClass="com.simpleplugin.structview.SimpleStructureViewFactory"/>

>

Oh! Perhaps the structure viewer is launching another thread to parse the file in order to create the PSI tree from which it creates its structure tree. That brings us to the real question: what are the rules regarding thread safety? I currently share a lexer for all purposes. Do I need to create a new lexer object from the createLexer() method in the parser definition class?

>

Ter

>

---
Original message URL: http://devnet.jetbrains.net/message/5499765#5499765

>

0

Ok, rebuilt to create new lexer and parser for each createLexer etc... request.  Still getting thread weirdness.

[  11004]   WARN - tellij.ide.HackyRepaintManager - Access to realized (ever shown) UI components should be done only from the AWT event dispatch thread, revalidate(), invalidate() & repaint() is ok from any thread
java.lang.Exception
 at com.intellij.ide.IdeRepaintManager.checkThreadViolations(IdeRepaintManager.java:135)
 at com.intellij.ide.IdeRepaintManager.addDirtyRegion(IdeRepaintManager.java:125)
 at javax.swing.JComponent.repaint(JComponent.java:4742)
 at java.awt.Component.repaint(Component.java:3207)
 at javax.swing.JTree.treeDidChange(JTree.java:2834)
 at javax.swing.plaf.basic.BasicTreeUI.updateSize(BasicTreeUI.java:1796)
 at javax.swing.plaf.basic.BasicTreeUI$Handler.treeNodesRemoved(BasicTreeUI.java:3818)
 at javax.swing.tree.DefaultTreeModel.fireTreeNodesRemoved(DefaultTreeModel.java:530)

...

and

[  11007]  ERROR - l.treeView.AbstractTreeBuilder - Must be in event-dispatch thread
java.lang.Throwable
 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:113)
 at com.intellij.ide.util.treeView.AbstractTreeUi.assertIsDispatchThread(AbstractTreeUi.java:957)
 at com.intellij.ide.util.treeView.AbstractTreeUi.maybeReady(AbstractTreeUi.java:2106)
 at com.intellij.ide.util.treeView.UpdaterTreeState.setProcessingNow(UpdaterTreeState.java:384)
 at com.intellij.ide.util.treeView.UpdaterTreeState.process(UpdaterTreeState.java:125)
 at com.intellij.ide.util.treeView.AbstractTreeUi.processInnerChange(AbstractTreeUi.java:3287)
 at com.intellij.ide.util.treeView.AbstractTreeUi.removeNodeFromParent(AbstractTreeUi.java:3237)
...


What other safety issues do I face?

thanks
0

Please sign in to leave a comment.