diff --git a/src/main/kotlin/org/arend/actions/ArendNormalizeToggleAction.kt b/src/main/kotlin/org/arend/actions/ArendNormalizeToggleAction.kt index b69b8b95d..0649aba86 100644 --- a/src/main/kotlin/org/arend/actions/ArendNormalizeToggleAction.kt +++ b/src/main/kotlin/org/arend/actions/ArendNormalizeToggleAction.kt @@ -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 @@ -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().data.popupNormalize } ?: false override fun setSelected(e: AnActionEvent, state: Boolean) { e.project?.run { service().data.popupNormalize = state } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/hierarchy/clazz/ArendClassHierarchyBrowser.kt b/src/main/kotlin/org/arend/hierarchy/clazz/ArendClassHierarchyBrowser.kt index af5f92211..b82e9b2ea 100644 --- a/src/main/kotlin/org/arend/hierarchy/clazz/ArendClassHierarchyBrowser.kt +++ b/src/main/kotlin/org/arend/hierarchy/clazz/ArendClassHierarchyBrowser.kt @@ -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 @@ -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().data.showImplFields override fun setSelected(e: AnActionEvent, state: Boolean) { @@ -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().data.showNonImplFields override fun setSelected(e: AnActionEvent, state: Boolean) { diff --git a/src/main/kotlin/org/arend/navigation/Utils.kt b/src/main/kotlin/org/arend/navigation/Utils.kt index 021fad5d8..0a250edfc 100644 --- a/src/main/kotlin/org/arend/navigation/Utils.kt +++ b/src/main/kotlin/org/arend/navigation/Utils.kt @@ -2,10 +2,12 @@ package org.arend.navigation import com.intellij.ide.projectView.PresentationData import com.intellij.navigation.ItemPresentation +import com.intellij.openapi.application.ApplicationManager import com.intellij.psi.PsiElement import org.arend.psi.ArendFile import org.arend.psi.ext.ArendCompositeElement import org.arend.psi.ext.PsiReferable +import javax.swing.Icon fun getPresentation(psi: ArendCompositeElement): ItemPresentation { val location = run { @@ -14,7 +16,16 @@ fun getPresentation(psi: ArendCompositeElement): ItemPresentation { } val name = presentableName(psi) - return PresentationData(name, location, psi.getIcon(0), null) + var icon: Icon? = null + ApplicationManager.getApplication().run { + executeOnPooledThread { + runReadAction { + icon = psi.getIcon(0) + } + }.get() + } + + return PresentationData(name, location, icon, null) } fun getPresentationForStructure(psi: ArendCompositeElement): ItemPresentation = diff --git a/src/main/kotlin/org/arend/search/proof/ArendProofSearchAction.kt b/src/main/kotlin/org/arend/search/proof/ArendProofSearchAction.kt index 839425acb..93f7367f5 100644 --- a/src/main/kotlin/org/arend/search/proof/ArendProofSearchAction.kt +++ b/src/main/kotlin/org/arend/search/proof/ArendProofSearchAction.kt @@ -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 @@ -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 } diff --git a/src/main/kotlin/org/arend/search/proof/GearActionGroup.kt b/src/main/kotlin/org/arend/search/proof/GearActionGroup.kt index eb2b0281e..dedc2d488 100644 --- a/src/main/kotlin/org/arend/search/proof/GearActionGroup.kt +++ b/src/main/kotlin/org/arend/search/proof/GearActionGroup.kt @@ -48,6 +48,9 @@ private abstract class ProofSearchToggleSettingsAction( val settingsProperty: KMutableProperty1, actionText: @Nls String ) : ToggleAction(actionText) { + + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT + override fun isSelected(e: AnActionEvent): Boolean = settingsProperty.invoke(project.service().data) diff --git a/src/main/kotlin/org/arend/search/proof/ProofSearchUtils.kt b/src/main/kotlin/org/arend/search/proof/ProofSearchUtils.kt index 0e9430db2..2265e68cd 100644 --- a/src/main/kotlin/org/arend/search/proof/ProofSearchUtils.kt +++ b/src/main/kotlin/org/arend/search/proof/ProofSearchUtils.kt @@ -1,5 +1,6 @@ package org.arend.search.proof +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.runReadAction import com.intellij.openapi.components.service import com.intellij.openapi.project.DumbService @@ -258,7 +259,18 @@ class ProofSearchUISettings(private val project: Project) { } fun getCompleteModuleLocation(def: ReferableBase<*>): String? { - val file = def.location?.toString() ?: return null + var file: String? = null + ApplicationManager.getApplication().run { + executeOnPooledThread { + runReadAction { + file = def.location?.toString() + } + }.get() + } + if (file == null) { + return null + } + val module = def.parentsOfType(false).toList().reversed().drop(1).map { it.name } return (listOf(file) + module).joinToString(".") } \ No newline at end of file diff --git a/src/main/kotlin/org/arend/search/proof/ShowHelpAction.kt b/src/main/kotlin/org/arend/search/proof/ShowHelpAction.kt index 16a68ee0e..727dc9343 100644 --- a/src/main/kotlin/org/arend/search/proof/ShowHelpAction.kt +++ b/src/main/kotlin/org/arend/search/proof/ShowHelpAction.kt @@ -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 @@ -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") diff --git a/src/main/kotlin/org/arend/search/proof/ShowInFindWindowAction.kt b/src/main/kotlin/org/arend/search/proof/ShowInFindWindowAction.kt index 9461303ee..bdb5eb246 100644 --- a/src/main/kotlin/org/arend/search/proof/ShowInFindWindowAction.kt +++ b/src/main/kotlin/org/arend/search/proof/ShowInFindWindowAction.kt @@ -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 @@ -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 diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendMessagesFilterAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendMessagesFilterAction.kt index bd627b611..1b02f67a8 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendMessagesFilterAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendMessagesFilterAction.kt @@ -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 @@ -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().messagesFilterSet @@ -32,4 +35,4 @@ class ArendMessagesFilterAction(private val project: Project, private val type: group.setSelected(type, state) project.service().update() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendPinErrorAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendPinErrorAction.kt index 75805f813..9072cd291 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendPinErrorAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendPinErrorAction.kt @@ -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 @@ -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()?.isErrorTextPinned ?: false @@ -25,4 +29,4 @@ class ArendPinErrorAction : ToggleAction( companion object { const val ID = "Arend.PinError" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendPinGoalAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendPinGoalAction.kt index 90d2e23f9..948a03ed6 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendPinGoalAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendPinGoalAction.kt @@ -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 @@ -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()?.isGoalTextPinned ?: false diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendPrintOptionsFilterAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendPrintOptionsFilterAction.kt index 3dad5f450..c5c9ae3d5 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendPrintOptionsFilterAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendPrintOptionsFilterAction.kt @@ -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 @@ -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 @@ -70,4 +73,4 @@ enum class PrintOptionKind(val kindName: String) { POPUP_PRINT_OPTIONS("Pop-up"), REPL_PRINT_OPTIONS("REPL"), ERROR_PRINT_OPTIONS("Error") -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowErrorsPanelAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowErrorsPanelAction.kt index 1decd8091..7a2545a0d 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowErrorsPanelAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowErrorsPanelAction.kt @@ -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 @@ -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()?.isShowErrorsPanel?.get() ?: true override fun setSelected(e: AnActionEvent, state: Boolean) { e.project?.service()?.isShowErrorsPanel?.set(state) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowGoalsInErrorsPanelAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowGoalsInErrorsPanelAction.kt index f3e48a9a6..69850be9e 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowGoalsInErrorsPanelAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowGoalsInErrorsPanelAction.kt @@ -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 @@ -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()?.isShowGoalsInErrorsPanel?.get() ?: true diff --git a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowImplicitGoalsAction.kt b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowImplicitGoalsAction.kt index e8f5a1b4a..05c976163 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/ArendShowImplicitGoalsAction.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/ArendShowImplicitGoalsAction.kt @@ -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 @@ -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()?.isShowImplicitGoals?.get() ?: false override fun setSelected(e: AnActionEvent, state: Boolean) { e.project?.service()?.isShowImplicitGoals?.set(state) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/org/arend/toolWindow/errors/tree/ArendErrorTreeAutoScrollFromSource.kt b/src/main/kotlin/org/arend/toolWindow/errors/tree/ArendErrorTreeAutoScrollFromSource.kt index 7ae350ded..5a5da534e 100644 --- a/src/main/kotlin/org/arend/toolWindow/errors/tree/ArendErrorTreeAutoScrollFromSource.kt +++ b/src/main/kotlin/org/arend/toolWindow/errors/tree/ArendErrorTreeAutoScrollFromSource.kt @@ -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 @@ -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() return settings.autoScrollFromSource.contains(type) && settings.messagesFilterSet.contains(type) && @@ -127,4 +131,4 @@ class ArendErrorTreeAutoScrollFromSource(private val project: Project, private v } } } -} \ No newline at end of file +}