AssertionError: commitDocument left PSI inconsistent - why this happens?

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:
java.lang.AssertionError: commitDocument left PSI inconsistent:
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commit(
 at com.intellij.psi.impl.PsiDocumentManagerImpl$
 at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(
 at com.intellij.psi.impl.PsiDocumentManagerImpl.a(
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commitDocument(
 at com.intellij.psi.impl.PsiDocumentManagerImpl.commitAllDocuments(
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.getPasses(
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.createPassesForEditor(
 at com.intellij.codeInsight.daemon.impl.TextEditorBackgroundHighlighter.createPassesForEditor(
 at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl$
 at com.intellij.util.Alarm$Request$
 at com.intellij.openapi.application.impl.LaterInvocator$
 at java.awt.event.InvocationEvent.dispatch(
 at java.awt.EventQueue.dispatchEvent(
 at com.intellij.ide.IdeEventQueue.e(
 at com.intellij.ide.IdeEventQueue._dispatchEvent(
 at com.intellij.ide.IdeEventQueue.b(
 at com.intellij.ide.IdeEventQueue.dispatchEvent(
 at java.awt.EventDispatchThread.pumpOneEventForFilters(
 at java.awt.EventDispatchThread.pumpEventsForFilter(
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(
 at java.awt.EventDispatchThread.pumpEvents(
 at java.awt.EventDispatchThread.pumpEvents(

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.

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.


Please sign in to leave a comment.