riej / lsl

Linden Script (LSL) language plugin for IntelliJ IDEA
MIT License
7 stars 2 forks source link

AssertionError: An action must not request write-action during actions update. #6

Closed mewore closed 1 year ago

mewore commented 1 year ago
2023-05-24 12:46:25,806 [  33955]  ERROR - ctionSystem.impl.ActionUpdater - An action must not request write-action during actions update. See CustomComponentAction.createCustomComponent javadoc, if caused by a custom component. 
java.lang.AssertionError: An action must not request write-action during actions update. See CustomComponentAction.createCustomComponent javadoc, if caused by a custom component.
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.cancelPromise(ActionUpdater.java:685)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$16(ActionUpdater.java:334)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.cancelActionsToBeCancelledBeforeWrite(ProgressIndicatorUtils.java:138)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils$2.beforeWriteActionStart(ProgressIndicatorUtils.java:130)
    at jdk.internal.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.intellij.util.EventDispatcher.dispatchVoidMethod(EventDispatcher.java:120)
    at com.intellij.util.EventDispatcher.lambda$createMulticaster$1(EventDispatcher.java:85)
    at com.sun.proxy.$Proxy67.beforeWriteActionStart(Unknown Source)
    at com.intellij.openapi.application.impl.ApplicationImpl.fireBeforeWriteActionStart(ApplicationImpl.java:1318)
    at com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1133)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:945)
    at com.intellij.util.FileContentUtilCore.reparseFiles(FileContentUtilCore.java:37)
    at com.intellij.util.FileContentUtilCore.reparseFiles(FileContentUtilCore.java:28)
    at io.github.riej.lsl.psi.LslArguments.subtreeChanged(LslArguments.kt:25)
    at com.intellij.psi.impl.source.tree.CompositeElement.subtreeChanged(CompositeElement.java:74)
    at com.intellij.psi.impl.source.tree.TreeElement.invalidate(TreeElement.java:338)
    at com.intellij.psi.impl.source.tree.TreeElement.rawRemove(TreeElement.java:325)
    at com.intellij.psi.impl.source.tree.CompositeElement.applyDeleteOnReparse(CompositeElement.java:747)
    at com.intellij.psi.impl.DiffLog$DeleteEntry.doActualPsiChange(DiffLog.java:146)
    at com.intellij.psi.impl.DiffLog.performActualPsiChange(DiffLog.java:45)
    at com.intellij.pom.core.impl.PomModelImpl$1.runInner(PomModelImpl.java:246)
    at com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:28)
    at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$1(PomModelImpl.java:111)
    at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:481)
    at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$2(PomModelImpl.java:104)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeNonCancelableSection$3(CoreProgressManager.java:222)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:237)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:221)
    at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:93)
    at com.intellij.pom.core.impl.PomModelImpl.lambda$reparseFile$3(PomModelImpl.java:243)
    at com.intellij.codeInsight.completion.OffsetsInFile$replaceInCopy$1.get(OffsetsInFile.kt:57)
    at com.intellij.codeInsight.completion.OffsetsInFile$replaceInCopy$1.get(OffsetsInFile.kt:16)
    at com.intellij.codeInsight.completion.OffsetsInFile.copyWithReplacement(OffsetsInFile.kt:41)
    at com.intellij.codeInsight.template.impl.TemplateManagerImpl.copyWithDummyIdentifier(TemplateManagerImpl.java:641)
    at com.intellij.codeInsight.template.impl.TemplateManagerImpl.lambda$insertDummyIdentifierWithCache$7(TemplateManagerImpl.java:617)
    at com.intellij.util.containers.ConcurrentFactoryMap$2.create(ConcurrentFactoryMap.java:174)
    at com.intellij.util.containers.ConcurrentFactoryMap.get(ConcurrentFactoryMap.java:40)
    at com.intellij.codeInsight.template.impl.TemplateManagerImpl.insertDummyIdentifierWithCache(TemplateManagerImpl.java:619)
    at com.intellij.codeInsight.template.impl.TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(TemplateManagerImpl.java:558)
    at com.intellij.codeInsight.generation.actions.SurroundWithAction.isValidForFile(SurroundWithAction.java:45)
    at com.intellij.codeInsight.actions.CodeInsightAction.update(CodeInsightAction.java:97)
    at com.intellij.codeInsight.actions.CodeInsightAction.update(CodeInsightAction.java:102)
    at com.intellij.codeInsight.actions.CodeInsightAction.update(CodeInsightAction.java:93)
    at com.intellij.codeInsight.actions.BaseCodeInsightAction.update(BaseCodeInsightAction.java:89)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performDumbAwareUpdate$0(ActionUtil.java:131)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.java:145)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.doUpdate(ActionUpdater.java:637)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$updateActionReal$7(ActionUpdater.java:129)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$callAction$9(ActionUpdater.java:200)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:57)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:57)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$callAction$10(ActionUpdater.java:198)
    at com.intellij.openapi.actionSystem.impl.ActionUpdateEdtExecutor.lambda$computeOnEdt$0(ActionUpdateEdtExecutor.java:45)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:199)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
2023-05-24 12:46:25,826 [  33975]  ERROR - ctionSystem.impl.ActionUpdater - IntelliJ IDEA 2021.3.3  Build #IC-213.7172.25 
2023-05-24 12:46:25,828 [  33977]  ERROR - ctionSystem.impl.ActionUpdater - JDK: 11.0.14.1; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. 
2023-05-24 12:46:25,828 [  33977]  ERROR - ctionSystem.impl.ActionUpdater - OS: Linux 
2023-05-24 12:46:25,831 [  33980]  ERROR - ctionSystem.impl.ActionUpdater - Plugin to blame: Linden Script (LSL) version: 0.1.11 
2023-05-24 12:46:25,832 [  33981]  ERROR - ctionSystem.impl.ActionUpdater - Last Action:  
line 18:4 missing ';' at 'mew'

The only relevant part of the stacktrace might be this one:

    at io.github.riej.lsl.psi.LslArguments.subtreeChanged(LslArguments.kt:25)

This is the code:

    override fun subtreeChanged() {
        // There is problem when modification of function arguments doesn't affects to function body.
        // For example:
        // integer meow() { return a + b; }
        // IDE will show errors at `a` and `b` - because they does not exists yet.
        // But if you write arguments (`integer a, integer b`), IDE still will show errors.
        // I really have no idea how to fix this behavior except reparsing whole file.
        // This is slow, but it works.
        // TODO: find proper solution.
        FileContentUtilCore.reparseFiles(this.containingFile.virtualFile)
    }

Actually, this sounds very related to PR #3 - maybe I'll fix this issue with it as a bonus? (I mean maybe I can remove this workaround as a whole, but I need to test it well)

mewore commented 1 year ago

Also, I love how you used meow in your example. Great minds think alike!

mewore commented 1 year ago

...nope. It seems the fix is completely unrelated to #3. (if it actually works)

riej commented 1 year ago

I guess it was fixed within 8e67cc9e5880103714f27bf0e8bfe841150b08e5 and b88b2de45036708cf5366ceb53f033754d727cc5