User: kyle wood Date: 18 Aug 22 00:56 Revision: fe75ec4fcca11966c31f47e24dac4100a63206a1 Summary: Don't use EDT coroutine scope TeamCity URL: https://ci.denwav.dev/viewModification.html?tab=vcsModificationFiles&modId=8086&personal=false Index: src/main/kotlin/util/utils.kt =================================================================== --- src/main/kotlin/util/utils.kt (revision 53a0fd1771158e85867783c44dbb6c5e5b080923) +++ src/main/kotlin/util/utils.kt (revision fe75ec4fcca11966c31f47e24dac4100a63206a1) @@ -16,7 +16,6 @@ import com.intellij.openapi.application.AppUIExecutor import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.impl.coroutineDispatchingContext import com.intellij.openapi.application.runReadAction import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.module.Module @@ -33,8 +32,6 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFile import java.util.Locale -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking inline fun runWriteTask(crossinline func: () -> T): T { return invokeAndWait { @@ -92,8 +89,8 @@ ApplicationManager.getApplication().invokeLater(func, ModalityState.any()) } -fun edtCoroutineScope(block: suspend CoroutineScope.() -> T): T { - return runBlocking(AppUIExecutor.onUiThread().coroutineDispatchingContext(), block) +fun invokeEdt(block: () -> T): T { + return AppUIExecutor.onUiThread().submit(block).get() } inline fun PsiFile.runWriteAction(crossinline func: () -> T) = Index: src/test/kotlin/framework/EdtInterceptor.kt =================================================================== --- src/test/kotlin/framework/EdtInterceptor.kt (revision 53a0fd1771158e85867783c44dbb6c5e5b080923) +++ src/test/kotlin/framework/EdtInterceptor.kt (revision fe75ec4fcca11966c31f47e24dac4100a63206a1) @@ -10,7 +10,7 @@ package com.demonwav.mcdev.framework -import com.demonwav.mcdev.util.edtCoroutineScope +import com.demonwav.mcdev.util.invokeEdt import java.lang.reflect.Method import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.api.extension.InvocationInterceptor @@ -50,7 +50,7 @@ return } - val thrown = edtCoroutineScope { + val thrown = invokeEdt { runCatching { invocation.proceed() }.exceptionOrNull()