Skip to content

Commit

Permalink
Override update thread functions - #513
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbosch committed Apr 15, 2024
1 parent 070b8d0 commit 31e25cb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class AutoCorrectAction : AnAction(PluginUtils.pluginIcon()) {

private val logger = logger<AutoCorrectAction>()

override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun update(event: AnActionEvent) {
val file: VirtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return
val project = event.getData(CommonDataKeys.PROJECT) ?: return
Expand Down Expand Up @@ -69,6 +71,4 @@ class AutoCorrectAction : AnAction(PluginUtils.pluginIcon()) {
}
}
}

override fun getActionUpdateThread() = ActionUpdateThread.EDT
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.gitlab.arturbosch.detekt.idea.action

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 @@ -9,6 +10,8 @@ import io.gitlab.arturbosch.detekt.idea.util.PluginUtils

class EnableBackgroundAnalysisAction : ToggleAction(null, null, PluginUtils.pluginIcon()), DumbAware {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT

override fun isSelected(e: AnActionEvent): Boolean {
val project = e.project ?: return false
return project.service<DetektPluginSettings>().enableDetekt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.gitlab.arturbosch.detekt.idea.action

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.PlatformDataKeys
Expand All @@ -19,6 +20,8 @@ import org.jetbrains.kotlin.idea.KotlinLanguage

class RunAnalysisAction : AnAction(PluginUtils.pluginIcon()) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun update(event: AnActionEvent) {
val selectedFiles = event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY) ?: return
val isDirectoryOrKotlinFile = selectedFiles.any { it.isDirectory || it.extension in KOTLIN_FILE_EXTENSIONS }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.gitlab.arturbosch.detekt.idea.action

import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.fileEditor.FileEditorManager
import io.gitlab.arturbosch.detekt.idea.util.PluginUtils

class RunDetektMenuGroup : DefaultActionGroup(null, null, PluginUtils.pluginIcon()) {

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
val project = e.project
val presentation = e.presentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.gitlab.arturbosch.detekt.idea.util

import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
Expand Down Expand Up @@ -66,6 +67,7 @@ fun showNotification(title: String, content: String, project: Project) {
)

notification.addAction(object : AnAction(DetektBundle.message("detekt.notifications.actions.openSettings")) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun actionPerformed(e: AnActionEvent) {
val dialog = SettingsDialog(
project,
Expand Down

0 comments on commit 31e25cb

Please sign in to comment.