Skip to content

Commit

Permalink
Fix PluginException: ActionUpdateThread.OLD_EDT
Browse files Browse the repository at this point in the history
  • Loading branch information
alex999990009 committed Jun 19, 2024
1 parent 8825bd4 commit 7229594
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -11,10 +12,12 @@ object ArendNormalizeToggleAction : ToggleAction() {
templatePresentation.icon = ArendIcons.SHOW_NORMALIZED
}

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent) =
e.project?.run { service<ArendProjectSettings>().data.popupNormalize } ?: false

override fun setSelected(e: AnActionEvent, state: Boolean) {
e.project?.run { service<ArendProjectSettings>().data.popupNormalize = state }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import com.intellij.ide.hierarchy.TypeHierarchyBrowserBase
import com.intellij.ide.util.treeView.AlphaComparator
import com.intellij.ide.util.treeView.NodeDescriptor
import com.intellij.ide.util.treeView.SourceComparator
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.components.service
Expand Down Expand Up @@ -149,6 +146,8 @@ class ArendClassHierarchyBrowser(project: Project, method: PsiElement) : TypeHie

inner class ArendShowImplFieldsAction : ToggleAction("Show Implemented Fields", "", ArendIcons.SHOW_FIELDS_IMPL) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent) = myProject.service<ArendProjectSettings>().data.showImplFields

override fun setSelected(e: AnActionEvent, state: Boolean) {
Expand All @@ -159,6 +158,8 @@ class ArendClassHierarchyBrowser(project: Project, method: PsiElement) : TypeHie

inner class ArendShowNonImplFieldsAction : ToggleAction("Show Non-Implemented Fields", "", ArendIcons.SHOW_NON_IMPLEMENTED) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent) = myProject.service<ArendProjectSettings>().data.showNonImplFields

override fun setSelected(e: AnActionEvent, state: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.search.proof

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.LangDataKeys
Expand All @@ -8,6 +9,8 @@ import org.arend.ArendIcons
import org.arend.ArendLanguage

class ArendProofSearchAction : AnAction(ArendIcons.AREND) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = e.getData(LangDataKeys.LANGUAGE) == ArendLanguage.INSTANCE
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/org/arend/search/proof/GearActionGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ private abstract class ProofSearchToggleSettingsAction(
val settingsProperty: KMutableProperty1<ArendProjectSettingsState, Boolean>,
actionText: @Nls String
) : ToggleAction(actionText) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
settingsProperty.invoke(project.service<ArendProjectSettings>().data)

Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/org/arend/search/proof/ShowHelpAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.arend.search.proof

import com.intellij.icons.AllIcons
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import org.arend.util.ArendBundle
Expand All @@ -10,6 +11,9 @@ class ShowHelpAction(private val ui: ProofSearchUI) : DumbAwareAction(
ArendBundle.getLazyMessage("arend.proof.search.show.help"),
ArendBundle.getLazyMessage("arend.proof.search.show.help.description"), AllIcons.General.ContextHelp
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun actionPerformed(e: AnActionEvent) {
ui.close()
BrowserUtil.browse("https://arend-lang.github.io/documentation/proof-search")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.arend.search.proof
import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter
import com.intellij.icons.AllIcons
import com.intellij.ide.IdeBundle
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.progress.ProgressIndicator
Expand All @@ -22,6 +23,9 @@ class ShowInFindWindowAction(private val ui: ProofSearchUI, private val project:
IdeBundle.messagePointer("show.in.find.window.button.name"),
IdeBundle.messagePointer("show.in.find.window.button.description"), AllIcons.General.Pin_tab
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun actionPerformed(e: AnActionEvent) {
ui.close()
val searchText: String = ui.editorSearchField.text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.toolWindow.errors

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -10,6 +11,8 @@ import org.arend.settings.ArendProjectSettings
class ArendMessagesFilterAction(private val project: Project, private val type: MessageType, private val group: ArendMessagesFilterActionGroup)
: ToggleAction("Show ${type.toText()}s", null, null), DumbAware {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

val isSelected: Boolean
get() {
val filterSet = project.service<ArendProjectSettings>().messagesFilterSet
Expand All @@ -32,4 +35,4 @@ class ArendMessagesFilterAction(private val project: Project, private val type:
group.setSelected(type, state)
project.service<ArendMessagesService>().update()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.toolWindow.errors

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -11,6 +12,9 @@ class ArendPinErrorAction : ToggleAction(
ArendBundle.message("arend.pin.error.action.description"),
ArendIcons.PIN
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
e.project?.service<ArendMessagesService>()?.isErrorTextPinned ?: false

Expand All @@ -25,4 +29,4 @@ class ArendPinErrorAction : ToggleAction(
companion object {
const val ID = "Arend.PinError"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.toolWindow.errors

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -11,6 +12,9 @@ class ArendPinGoalAction : ToggleAction(
ArendBundle.message("arend.pin.goal.action.description"),
ArendIcons.PIN
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
e.project?.service<ArendMessagesService>()?.isGoalTextPinned ?: false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.toolWindow.errors

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -15,6 +16,8 @@ class ArendPrintOptionsFilterAction(
private val callback: Runnable?
) : ToggleAction(flagToString(flag), null, null), DumbAware {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean = isSelected

private val isSelected: Boolean
Expand Down Expand Up @@ -70,4 +73,4 @@ enum class PrintOptionKind(val kindName: String) {
POPUP_PRINT_OPTIONS("Pop-up"),
REPL_PRINT_OPTIONS("REPL"),
ERROR_PRINT_OPTIONS("Error")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.arend.toolWindow.errors

import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -11,10 +12,12 @@ class ArendShowErrorsPanelAction : ToggleAction(
ArendBundle.message("arend.show.errors.panel.action.description"),
AllIcons.Actions.PreviewDetails
) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
e.project?.service<ArendMessagesService>()?.isShowErrorsPanel?.get() ?: true

override fun setSelected(e: AnActionEvent, state: Boolean) {
e.project?.service<ArendMessagesService>()?.isShowErrorsPanel?.set(state)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.arend.toolWindow.errors

import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -12,6 +13,9 @@ class ArendShowGoalsInErrorsPanelAction : ToggleAction(
ArendBundle.message("arend.show.goals.in.errors.panel.action.description"),
ICON
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
e.project?.service<ArendMessagesService>()?.isShowGoalsInErrorsPanel?.get() ?: true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.toolWindow.errors

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.components.service
Expand All @@ -11,10 +12,13 @@ class ArendShowImplicitGoalsAction : ToggleAction(
ArendBundle.message("arend.show.implicit.goals.action.description"),
ArendIcons.IMPLICIT_GOAL
) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean =
e.project?.service<ArendMessagesService>()?.isShowImplicitGoals?.get() ?: false

override fun setSelected(e: AnActionEvent, state: Boolean) {
e.project?.service<ArendMessagesService>()?.isShowImplicitGoals?.set(state)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.arend.toolWindow.errors.tree

import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.ToggleAction
Expand Down Expand Up @@ -86,6 +87,9 @@ class ArendErrorTreeAutoScrollFromSource(private val project: Project, private v
}

private inner class MyAction(private val type: MessageType) : ToggleAction("Autoscroll from ${type.toText()}s", null, null), DumbAware {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun isSelected(e: AnActionEvent): Boolean {
val settings = project.service<ArendProjectSettings>()
return settings.autoScrollFromSource.contains(type) && settings.messagesFilterSet.contains(type) &&
Expand Down Expand Up @@ -127,4 +131,4 @@ class ArendErrorTreeAutoScrollFromSource(private val project: Project, private v
}
}
}
}
}

0 comments on commit 7229594

Please sign in to comment.