Getting document write error(assert error)

please suggest.

I get following error when I try to do :

Editor editor = (Editor) e.getDataContext().getData(DataConstants.EDITOR);
Document document = editor.getDocument();
document.replaceString(startIndex,endIndex,"ABCDEFG");

com.intellij.rt.execution.application.AppMain com.intellij.idea.Main
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.application.impl.ApplicationImpl.assertWriteAccessAllowed(ApplicationImpl.java:246)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:282)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:313)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - plication.impl.ApplicationImpl - Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction())
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.application.impl.ApplicationImpl.assertWriteAccessAllowed(ApplicationImpl.java:246)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:282)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:313)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - plication.impl.ApplicationImpl - IntelliJ IDEA 6.0 Beta Build #5661
ERROR - plication.impl.ApplicationImpl - JDK: 1.5.0
ERROR - plication.impl.ApplicationImpl - VM: Java HotSpot(TM) Client VM
ERROR - plication.impl.ApplicationImpl - Vendor: Sun Microsystems Inc.
ERROR - plication.impl.ApplicationImpl - OS: Windows XP
ERROR - plication.impl.ApplicationImpl - Last Action: UpperCase
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.command.impl.DocumentEditingUndoProvider$MyEditorDocumentListener.documentChanged(DocumentEditingUndoProvider.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:72)
at com.intellij.util.EventDispatcher.access$100(EventDispatcher.java:20)
at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:51)
at $Proxy5.documentChanged(Unknown Source)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:118)
at com.intellij.openapi.editor.impl.DocumentImpl.access$300(DocumentImpl.java:249)
at com.intellij.openapi.editor.impl.DocumentImpl$4.afterChangedUpdate(DocumentImpl.java:2)
at com.intellij.openapi.editor.impl.CharArray.replace(CharArray.java:52)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:6)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - pl.DocumentEditingUndoProvider - Assertion failed: Undoable actions allowed inside commands only (see com.intellij.openapi.command.CommandProcessor.executeCommand())
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.command.impl.DocumentEditingUndoProvider$MyEditorDocumentListener.documentChanged(DocumentEditingUndoProvider.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:72)
at com.intellij.util.EventDispatcher.access$100(EventDispatcher.java:20)
at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:51)
at $Proxy5.documentChanged(Unknown Source)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:118)
at com.intellij.openapi.editor.impl.DocumentImpl.access$300(DocumentImpl.java:249)
at com.intellij.openapi.editor.impl.DocumentImpl$4.afterChangedUpdate(DocumentImpl.java:2)
at com.intellij.openapi.editor.impl.CharArray.replace(CharArray.java:52)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:6)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - pl.DocumentEditingUndoProvider - IntelliJ IDEA 6.0 Beta Build #5661
ERROR - pl.DocumentEditingUndoProvider - JDK: 1.5.0
ERROR - pl.DocumentEditingUndoProvider - VM: Java HotSpot(TM) Client VM
ERROR - pl.DocumentEditingUndoProvider - Vendor: Sun Microsystems Inc.
ERROR - pl.DocumentEditingUndoProvider - OS: Windows XP
ERROR - pl.DocumentEditingUndoProvider - Last Action: UpperCase
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.command.impl.DocumentEditingUndoProvider$MyEditorDocumentListener.documentChanged(DocumentEditingUndoProvider.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:72)
at com.intellij.util.EventDispatcher.access$100(EventDispatcher.java:20)
at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:51)
at $Proxy5.documentChanged(Unknown Source)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:118)
at com.intellij.openapi.editor.impl.DocumentImpl.access$300(DocumentImpl.java:249)
at com.intellij.openapi.editor.impl.DocumentImpl$4.afterChangedUpdate(DocumentImpl.java:2)
at com.intellij.openapi.editor.impl.CharArray.replace(CharArray.java:52)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:6)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - pl.DocumentEditingUndoProvider - Assertion failed: Undoable actions allowed inside commands only (see com.intellij.openapi.command.CommandProcessor.executeCommand())
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.command.impl.DocumentEditingUndoProvider$MyEditorDocumentListener.documentChanged(DocumentEditingUndoProvider.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.util.EventDispatcher.dispatch(EventDispatcher.java:72)
at com.intellij.util.EventDispatcher.access$100(EventDispatcher.java:20)
at com.intellij.util.EventDispatcher$1.invoke(EventDispatcher.java:51)
at $Proxy5.documentChanged(Unknown Source)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:118)
at com.intellij.openapi.editor.impl.DocumentImpl.access$300(DocumentImpl.java:249)
at com.intellij.openapi.editor.impl.DocumentImpl$4.afterChangedUpdate(DocumentImpl.java:2)
at com.intellij.openapi.editor.impl.CharArray.replace(CharArray.java:52)
at com.intellij.openapi.editor.impl.DocumentImpl.a(DocumentImpl.java:6)
at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:206)
at org.miscCom.caseMod.UpperCase.actionPerformed(UpperCase.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:34)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:124)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:41)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:27)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - pl.DocumentEditingUndoProvider - IntelliJ IDEA 6.0 Beta Build #5661
ERROR - pl.DocumentEditingUndoProvider - JDK: 1.5.0
ERROR - pl.DocumentEditingUndoProvider - VM: Java HotSpot(TM) Client VM
ERROR - pl.DocumentEditingUndoProvider - Vendor: Sun Microsystems Inc.
ERROR - pl.DocumentEditingUndoProvider - OS: Windows XP
ERROR - pl.DocumentEditingUndoProvider - Last Action: UpperCase

1 comment

You need to do whatever you're doing within a write action, by wrapping in Runnable and passed to ApplicationManager.getApplication().runWriteAction(). (You may also need to run that within an app.invokeLater Runnable, amazingly I don't know a shortcut for this, you'll actually need two Runnables.)

0

Please sign in to leave a comment.