AssertionError: commitDocument left PSI inconsistent - why this happens?

Hi!
I'm trying to implement a plugin. My parser works somehow, but then i'm trying to edit existing sources, i'e got the exception below.
Could you advise on it, please?

Thanks, Alex

ERROR - pplication.impl.LaterInvocator - commitDocument left PSI inconsistent: com.aav.bb.psi.BbPsiFileImpl@113447f
java.lang.AssertionError: commitDocument left PSI inconsistent: com.aav.bb.psi.BbPsiFileImpl@113447f
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commit(PsiDocumentManagerImpl.java:501)
 at com.intellij.psi.impl.PsiDocumentManagerImpl$1.run(PsiDocumentManagerImpl.java:254)
 at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:844)
 at com.intellij.psi.impl.PsiDocumentManagerImpl.a(PsiDocumentManagerImpl.java:241)
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commitDocument(PsiDocumentManagerImpl.java:235)
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commitAllDocuments(PsiDocumentManagerImpl.java:204)
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.getPasses(TextEditorBackgroundHighlighter.java:83)
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.createPassesForEditor(TextEditorBackgroundHighlighter.java:106)
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.createPassesForEditor(TextEditorBackgroundHighlighter.java:35)
 at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl$6.run(DaemonCodeAnalyzerImpl.java:675)
 at com.intellij.util.Alarm$Request$1.run(Alarm.java:229)
 at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:332)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
 at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:652)
 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:505)
 at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:404)
 at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:368)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

2 comments
Comment actions Permalink

I encountered this same error, and for me it was a bug in my parser. Even though the first parse worked, subsequent parses after edits did not.

0
Comment actions Permalink

Hi Alexander,

After text modification IDEA parses modified text into a new PSI tree and then merges it with an existing one. The exception means that text of the resulting PSI tree (obtained via traversal) doesn't match text in the document.
Try to debug your parser; ...treeToString() methods from com.intellij.psi.impl.DebugUtil may come in help.

Just a note: keep in mind that code being edited may be incomplete or completely invalid, and parser shoud handle it gracefully.

0

Please sign in to leave a comment.