Skip to content

Commit

Permalink
Implement cancellation for external system initialization (#82)
Browse files Browse the repository at this point in the history
Modified the Project.awaitExternalSystemInitialization() function in Utils.kt to enable cancellation using suspendCancellableCoroutine instead of suspendCoroutine.

Co-authored-by: Lamberto Basti <[email protected]>
  • Loading branch information
lamba92 and Lamberto Basti authored Feb 21, 2024
1 parent c0cefea commit 04442b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.intellij.openapi.project.Project
import com.jetbrains.packagesearch.plugin.core.extensions.DependencyDeclarationIndexes
import com.jetbrains.packagesearch.plugin.gradle.GradleDependencyModel
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.suspendCancellableCoroutine
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.plugins.gradle.util.GradleConstants

Expand All @@ -18,7 +18,7 @@ val Module.isGradleSourceSet: Boolean
return ExternalSystemApiUtil.getExternalModuleType(this) == GradleConstants.GRADLE_SOURCE_SET_MODULE_TYPE_KEY
}

suspend fun Project.awaitExternalSystemInitialization() = suspendCoroutine {
suspend fun Project.awaitExternalSystemInitialization() = suspendCancellableCoroutine {
ExternalProjectsManager.getInstance(this@awaitExternalSystemInitialization)
.runWhenInitialized { it.resume(Unit) }
}
Expand Down

0 comments on commit 04442b4

Please sign in to comment.