Skip to content

Commit 33cb7ed

Browse files
authored
Deprecate plugin scope tracking (#4295)
Plugin intersection scopes may cause plugin leaks https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#do-not-use-intersection-scopes
1 parent db0fdea commit 33cb7ed

File tree

1 file changed

+10
-0
lines changed
  • plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/coroutines

1 file changed

+10
-0
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/coroutines/scopes.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import java.util.concurrent.CancellationException
1919
*
2020
* Use this if the coroutine needs to live past a project being closed or across projects such as an Application Service
2121
*/
22+
@Deprecated("Application x plugin intersection scope should not be used https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes")
2223
fun applicationCoroutineScope(coroutineName: String): CoroutineScope =
2324
PluginCoroutineScopeTracker.getInstance().applicationThreadPoolScope(coroutineName)
2425

@@ -27,6 +28,7 @@ fun applicationCoroutineScope(coroutineName: String): CoroutineScope =
2728
*
2829
* Use this if the coroutine needs to live past a UI being closed, or tied to a project's life cycle such as a Project Service.
2930
*/
31+
@Deprecated("Project x plugin intersection scope should not be used https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes")
3032
fun projectCoroutineScope(project: Project, coroutineName: String): CoroutineScope =
3133
PluginCoroutineScopeTracker.getInstance(project).applicationThreadPoolScope(coroutineName)
3234

@@ -38,6 +40,9 @@ fun projectCoroutineScope(project: Project, coroutineName: String): CoroutineSco
3840
* **Note: If a call lives past the closing of a UI such as kicking off a resource creation, use [projectCoroutineScope].
3941
* Otherwise, the coroutine will be canceled when the UI is closed!**
4042
*/
43+
@Deprecated(
44+
"Coroutine scope should not be shared across entire plugin lifecycle https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes"
45+
)
4146
fun disposableCoroutineScope(disposable: Disposable, coroutineName: String): CoroutineScope {
4247
check(disposable !is Project && disposable !is Application) { "disposable should not be a project or application" }
4348
return PluginCoroutineScopeTracker.getInstance().applicationThreadPoolScope(coroutineName).also {
@@ -50,18 +55,23 @@ fun disposableCoroutineScope(disposable: Disposable, coroutineName: String): Cor
5055
/**
5156
* Version of [applicationCoroutineScope] the class name as the coroutine name.
5257
*/
58+
@Deprecated("Application x plugin intersection scope should not be used https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes")
5359
inline fun <reified T : Any> T.applicationCoroutineScope(): CoroutineScope =
5460
applicationCoroutineScope(T::class.java.name)
5561

5662
/**
5763
* Version of [projectCoroutineScope] the class name as the coroutine name.
5864
*/
65+
@Deprecated("Project x plugin intersection scope should not be used https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes")
5966
inline fun <reified T : Any> T.projectCoroutineScope(project: Project): CoroutineScope =
6067
projectCoroutineScope(project, T::class.java.name)
6168

6269
/**
6370
* Version of [disposableCoroutineScope] the class name as the coroutine name.
6471
*/
72+
@Deprecated(
73+
"Coroutine scope should not be shared across entire plugin lifecycle https://plugins.jetbrains.com/docs/intellij/coroutine-scopes.html#use-service-scopes"
74+
)
6575
inline fun <reified T : Any> T.disposableCoroutineScope(disposable: Disposable): CoroutineScope =
6676
disposableCoroutineScope(disposable, T::class.java.name)
6777

0 commit comments

Comments
 (0)