Skip to content

Commit

Permalink
Implement cancellation for external system initialization (#83)
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 36c1580 commit e86547e
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 e86547e

Please sign in to comment.