2023.3 EAP - IllegalStateException: Should not be called
krasa opened this issue · 15 comments
Editor does not open.
It seems that Markdown fixed it by this: JetBrains/intellij-community@bbcb1d9
java.lang.IllegalStateException: Should not be called
at com.intellij.openapi.fileEditor.AsyncFileEditorProvider.createEditorAsync(AsyncFileEditorProvider.kt:19)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.getBuilderFromEditorProvider(SplitTextEditorProvider.java:134)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.createEditorAsync(SplitTextEditorProvider.java:56)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.createEditor(SplitTextEditorProvider.java:44)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.createComposite(FileEditorManagerImpl.kt:1203)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.doOpenInEdtImpl(FileEditorManagerImpl.kt:1115)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl4$open(FileEditorManagerImpl.kt:1036)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl4$intellij_platform_ide_impl(FileEditorManagerImpl.kt:1047)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.doOpenFile(FileEditorManagerImpl.kt:823)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFile(FileEditorManagerImpl.kt:813)
at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.kt:147)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFileFromTemplate(CreateFileFromTemplateAction.java:115)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFileFromTemplate(CreateFileFromTemplateAction.java:82)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFileFromTemplate(CreateFileFromTemplateAction.java:72)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFileFromTemplate(CreateFileFromTemplateAction.java:63)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFile(CreateFileFromTemplateAction.java:140)
at com.intellij.ide.actions.CreateFileFromTemplateAction.createFile(CreateFileFromTemplateAction.java:45)
at com.intellij.ide.actions.CreateFromTemplateAction$1.createFile(CreateFromTemplateAction.java:79)
at com.intellij.ide.actions.CreateFromTemplateAction$1.createFile(CreateFromTemplateAction.java:74)
at com.intellij.ide.actions.CreateFileFromTemplateDialog$NonBlockingPopupBuilderImpl$1.create(CreateFileFromTemplateDialog.java:300)
at com.intellij.ide.actions.ElementCreator.lambda$tryCreate$0(ElementCreator.java:48)
at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:85)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:964)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:990)
at com.intellij.openapi.application.WriteAction.run(WriteAction.java:84)
at com.intellij.ide.actions.ElementCreator.lambda$executeCommand$1(ElementCreator.java:67)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:224)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:176)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:166)
at com.intellij.ide.actions.ElementCreator.executeCommand(ElementCreator.java:63)
at com.intellij.ide.actions.ElementCreator.tryCreate(ElementCreator.java:47)
at com.intellij.ide.actions.CreateFileFromTemplateDialog$NonBlockingPopupBuilderImpl.createElement(CreateFileFromTemplateDialog.java:361)
at com.intellij.ide.actions.CreateFileFromTemplateDialog$NonBlockingPopupBuilderImpl.lambda$show$2(CreateFileFromTemplateDialog.java:332)
at com.intellij.ide.ui.newItemPopup.NewItemWithTemplatesPopupPanel$1.mouseClicked(NewItemWithTemplatesPopupPanel.java:96)
at java.desktop/java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:278)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6660)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
at java.desktop/java.awt.Component.processEvent(Component.java:6422)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4969)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4592)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4524)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2809)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:794)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:766)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:763)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:677)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:624)
at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:570)
at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:75)
at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:67)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:570)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:70)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:350)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:793)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:349)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:344)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:989)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:989)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:344)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:849)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:386)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Thanks for letting me know. I'm looking at it now.
I am fixing it in my plugin too, this seems to work, better than runBlockingCancellable :
if (provider instanceof AsyncFileEditorProvider asyncFileEditorProvider) {
return CoroutinesKt.runBlockingMaybeCancellable((coroutineScope, continuation) -> {
return asyncFileEditorProvider.createEditorBuilder(project, file, continuation);
});
}
I'm considering dropping the AsyncFileEditorProvider
and implementing a normal FileEditorProvider
instead.
Reason is the non-responsiveness on backporting https://youtrack.jetbrains.com/issue/IDEA-318259
Makes sense, I'll do it too, my editors take ~1ms to create :-)
Sentry issue: ASCIIDOC-INTELLIJ-PLUGIN-5RN
There is now pre-release 0.39.9 which fixes this. Thanks for notifying me about this and discussing the solution. If you see any more problems, please comment here and I'll reopen the issue.
The pre-release of the plugin is available from GitHub releases and the IntelliJ AsciiDoc EAP repository.
Reopening the issue, I now received an error:
java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
at com.intellij.util.SlowOperations.assertSlowOperationsAreAllowed(SlowOperations.java:95)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.convertToNIOFileAndCheck(LocalFileSystemBase.java:152)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.contentsToByteArray(LocalFileSystemBase.java:449)
at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.contentsToByteArray(PersistentFSImpl.java:677)
at com.intellij.openapi.vfs.newvfs.impl.VirtualFileImpl.contentsToByteArray(VirtualFileImpl.java:117)
at com.intellij.openapi.vfs.newvfs.impl.VirtualFileImpl.contentsToByteArray(VirtualFileImpl.java:109)
at com.intellij.openapi.fileEditor.impl.LoadTextUtil.loadText(LoadTextUtil.java:511)
at com.intellij.openapi.fileEditor.impl.LoadTextUtil.loadText(LoadTextUtil.java:491)
at com.intellij.openapi.fileEditor.impl.FileDocumentManagerBase.loadText(FileDocumentManagerBase.java:105)
at com.intellij.openapi.fileEditor.impl.FileDocumentManagerBase.getDocument(FileDocumentManagerBase.java:61)
at com.intellij.openapi.fileEditor.FileDocumentManager.getDocument(FileDocumentManager.java:61)
at com.intellij.openapi.fileEditor.impl.text.TextEditorImpl$Companion.createTextEditor(TextEditorImpl.kt:120)
at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl.<init>(PsiAwareTextEditorImpl.kt:31)
at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider.createEditor(PsiAwareTextEditorProvider.kt:41)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.createEditor(SplitTextEditorProvider.java:43)
at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.createComposite(FileEditorManagerImpl.kt:1203)
@krasa - I'm now going for your solution. Unfortunately the API asyncFileEditorProvider.createEditorBuilder(project, file, continuation)
is only available from 2023.2 onwards only. But I think I don't have any other option.
Pre-release 0.40.1 is now available with the fix you suggested. Keeping my fingers crossed....
The pre-release of the plugin is available from GitHub releases and the IntelliJ AsciiDoc EAP repository.
That seems like IntelliJ bug.
PsiAwareTextEditorProvider.createEditor
is used a lot in FileEditorProvider#createEditor
, for example: org.intellij.images.editor.impl.ImageFileEditorProvider
or com.jetbrains.rest.editor.RestSplitEditorProvider
- as TextEditorProvider.getInstance().createEditor(project, file)
I don't know. I've promoted 0.40.1 just now to a regular release, and will keep my fingers crossed.
Got some "friendly advice" today via the error reporter:
java.lang.IllegalStateException: This method is forbidden on EDT because it does not pump the event queue. Switch to a BGT, or use com.intellij.openapi.progress.TasksKt.runWithModalProgressBlocking.
at com.intellij.openapi.progress.CoroutinesKt.assertBackgroundThreadOrWriteAction(coroutines.kt:413)
at com.intellij.openapi.progress.CoroutinesKt.runBlockingCancellable(coroutines.kt:124)
at com.intellij.openapi.progress.CoroutinesKt.runBlockingMaybeCancellable(coroutines.kt:152)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.getBuilderFromEditorProvider(SplitTextEditorProvider.java:135)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.createEditorAsync(SplitTextEditorProvider.java:57)
at org.asciidoc.intellij.ui.SplitTextEditorProvider.createEditor(SplitTextEditorProvider.java:45)
at com.intellij.ide.impl.StructureViewWrapperImpl$createStructureViewBuilder$editor$1.invokeSuspend(StructureViewWrapperImpl.kt:472)
at com.intellij.ide.impl.StructureViewWrapperImpl$createStructureViewBuilder$editor$1.invoke(StructureViewWrapperImpl.kt)
at com.intellij.ide.impl.StructureViewWrapperImpl$createStructureViewBuilder$editor$1.invoke(StructureViewWrapperImpl.kt)
When opening a file via the project view, it doesn't use the EDT and works as expected. When opening a file from the commit tool window showing the files which have been changed, it uses the EDT, and the first time it logs the message above.
Following the advice. For now I check first if I'm in the EDT, as the method has @RequiresEdt
and @RequiresBlockingContext
annotations. I have to admit I'm lost with those run***
functions.
See commit 2f62e59
There is now version 0.40.3 of the plugin available which includes the change. Let's see if this solves it, or if other reports pop up.
Sentry issue: ASCIIDOC-INTELLIJ-PLUGIN-5SM