mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[actions] IJPL-219402: Replace usages of currentThreadCoroutineScope in actions with AnActionEvent#coroutineScope
GitOrigin-RevId: cbb2f4b5242e04fcfeb2d623424e35cbbf91481b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
17deb35edb
commit
e2dbec90c6
@@ -6,13 +6,9 @@ import com.intellij.execution.configurations.GeneralCommandLine
|
||||
import com.intellij.execution.util.ExecUtil
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.progress.currentThreadCoroutineScope
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.Disposer
|
||||
@@ -120,7 +116,7 @@ internal class EditExternallyAction : DumbAwareAction() {
|
||||
private fun performActionWithBackingFile(e: AnActionEvent, imageFile: VirtualFile) {
|
||||
try {
|
||||
val disposable = e.getDisposable()
|
||||
currentThreadCoroutineScope().launch {
|
||||
e.coroutineScope.launch {
|
||||
try {
|
||||
val backingFile = imageFile.copyToBackingFile(disposable)
|
||||
actionPerformed(e, backingFile)
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecificat
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx
|
||||
import com.intellij.openapi.diagnostic.thisLogger
|
||||
import com.intellij.openapi.progress.currentThreadCoroutineScope
|
||||
import com.intellij.openapi.project.DumbAwareToggleAction
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
@@ -38,7 +37,7 @@ internal class SwitchServiceViewImplementationAction : DumbAwareToggleAction(),
|
||||
}
|
||||
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
currentThreadCoroutineScope().launch {
|
||||
e.coroutineScope.launch {
|
||||
val app = ApplicationManagerEx.getApplicationEx()
|
||||
val restartAllowed = withContext(Dispatchers.EDT) {
|
||||
if (app == null) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.progress.currentThreadCoroutineScope
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.wm.ToolWindowId
|
||||
import com.intellij.platform.execution.serviceView.splitApi.ServiceViewRpc
|
||||
@@ -37,7 +36,7 @@ internal class ConfigureServicesAction : DumbAwareAction(), ActionRemoteBehavior
|
||||
(ServiceViewManager.getInstance(project) as ServiceViewManagerImpl).includeToolWindow(toolWindow.id)
|
||||
}
|
||||
else {
|
||||
currentThreadCoroutineScope().launch {
|
||||
e.coroutineScope.launch {
|
||||
val settings = ServiceViewRpc.getInstance().loadConfigurationTypes(project.projectId()) ?: return@launch
|
||||
withContext(Dispatchers.EDT) {
|
||||
ConfigureServicesDialog(project, settings).show()
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.progress.currentThreadCoroutineScope
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.roots.ProjectFileIndex
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
@@ -37,7 +36,7 @@ internal class CountVfsFileChildrenAction : AnAction(), DumbAware {
|
||||
val root = VIRTUAL_FILE.getData(e.dataContext) ?: return
|
||||
val project = e.project ?: return
|
||||
|
||||
currentThreadCoroutineScope().launch(Dispatchers.Default) {
|
||||
e.coroutineScope.launch(Dispatchers.Default) {
|
||||
withBackgroundProgress(project, "Counting children on disk recursively...") {
|
||||
reportRawProgress { reporter ->
|
||||
var filesOnDiskCount = 0
|
||||
@@ -61,7 +60,7 @@ internal class CountVfsFileChildrenAction : AnAction(), DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
currentThreadCoroutineScope().launch(Dispatchers.Default) {
|
||||
e.coroutineScope.launch(Dispatchers.Default) {
|
||||
val fileIndex = ProjectFileIndex.getInstance(project)
|
||||
val workspaceFileIndex = WorkspaceFileIndex.getInstance(project)
|
||||
withBackgroundProgress(project, "Counting children in VFS recursively...") {
|
||||
|
||||
+7
-7
@@ -7,12 +7,12 @@ import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.currentThreadCoroutineScope
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.ui.InputValidator
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.application
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
@@ -34,23 +34,23 @@ internal abstract class SimulateFreezeBase : DumbAwareAction() {
|
||||
override fun checkInput(inputString: String?): Boolean = StringUtil.parseInt(inputString, -1) > 0
|
||||
override fun canClose(inputString: String?): Boolean = StringUtil.parseInt(inputString, -1) > 0
|
||||
}) ?: return
|
||||
simulatedFreeze(durationString.toLong())
|
||||
simulatedFreeze(e.coroutineScope, durationString.toLong())
|
||||
}
|
||||
|
||||
protected abstract fun simulatedFreeze(ms: Long)
|
||||
protected abstract fun simulatedFreeze(scope: CoroutineScope, ms: Long)
|
||||
}
|
||||
|
||||
internal class SimulateFreeze : SimulateFreezeBase() {
|
||||
override fun simulatedFreeze(ms: Long) {
|
||||
override fun simulatedFreeze(scope: CoroutineScope, ms: Long) {
|
||||
Thread.sleep(ms)
|
||||
}
|
||||
}
|
||||
|
||||
internal class SimulateRWFreeze : SimulateFreezeBase() {
|
||||
override fun simulatedFreeze(ms: Long) {
|
||||
override fun simulatedFreeze(scope: CoroutineScope, ms: Long) {
|
||||
val semaphore = Semaphore(1, 1)
|
||||
|
||||
currentThreadCoroutineScope().launch {
|
||||
scope.launch {
|
||||
val counter = AtomicInteger(0)
|
||||
readAction {
|
||||
semaphore.release()
|
||||
@@ -70,7 +70,7 @@ internal class SimulateRWFreeze : SimulateFreezeBase() {
|
||||
}
|
||||
}
|
||||
|
||||
currentThreadCoroutineScope().launch {
|
||||
scope.launch {
|
||||
semaphore.acquire()
|
||||
logger<SimulateRWFreeze>().info("start write-action")
|
||||
withContext(Dispatchers.EDT) {
|
||||
|
||||
Reference in New Issue
Block a user