IJPL-158881 ability to use coroutine scope instead of disposable

GitOrigin-RevId: 1e7957219dc80de4a80881a5cfc4a7f389b5309a
This commit is contained in:
Vladimir Krivosheev
2024-07-22 19:09:05 +02:00
committed by intellij-monorepo-bot
parent a9c9c65a7d
commit ea9220c042
3 changed files with 9 additions and 2 deletions

View File

@@ -25,5 +25,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.core" exported="" />
<orderEntry type="module" module-name="intellij.java.frontback.psi" exported="" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
</component>
</module>

View File

@@ -123,6 +123,7 @@ f:com.intellij.openapi.extensions.ExtensionPointName
- sf:Companion:com.intellij.openapi.extensions.ExtensionPointName$Companion
- <init>(java.lang.String):V
- f:addChangeListener(java.lang.Runnable,com.intellij.openapi.Disposable):V
- f:addChangeListener(kotlinx.coroutines.CoroutineScope,java.lang.Runnable):V
- f:addExtensionPointListener(com.intellij.openapi.extensions.AreaInstance,com.intellij.openapi.extensions.ExtensionPointListener):V
- f:addExtensionPointListener(com.intellij.openapi.extensions.ExtensionPointListener):V
- f:addExtensionPointListener(com.intellij.openapi.extensions.ExtensionPointListener,com.intellij.openapi.Disposable):V

View File

@@ -34,7 +34,7 @@ import kotlin.streams.asStream
*
* Instances of this class can be safely stored in static final fields.
*
* For project-level and module-level extension points use [ProjectExtensionPointName] instead to make it evident that corresponding
* For project-level and module-level extension points use [ProjectExtensionPointName] instead to make it clear that corresponding
* [AreaInstance] must be passed.
*/
class ExtensionPointName<T : Any>(name: @NonNls String) : BaseExtensionPointName<T>(name) {
@@ -123,7 +123,7 @@ class ExtensionPointName<T : Any>(name: @NonNls String) : BaseExtensionPointName
*
* Use only for interface extension points, not for bean.
*
* Due to internal reasons, there is no easy way to implement hasNext in a reliable manner,
* Due to internal reasons, there is no easy way to implement hasNext reliably,
* so, `next` may return `null` (in this case stop iteration).
*
* Possible use cases:
@@ -163,6 +163,7 @@ class ExtensionPointName<T : Any>(name: @NonNls String) : BaseExtensionPointName
getPointImpl(areaInstance).addExtensionPointListener(listener = listener, invokeForLoadedExtensions = false, parentDisposable = null)
}
@Deprecated("Pass CoroutineScope to addChangeListener")
fun removeExtensionPointListener(listener: ExtensionPointListener<T>) {
getPointImpl(null).removeExtensionPointListener(listener)
}
@@ -171,6 +172,10 @@ class ExtensionPointName<T : Any>(name: @NonNls String) : BaseExtensionPointName
getPointImpl(null).addChangeListener(listener = listener, parentDisposable = parentDisposable)
}
fun addChangeListener(coroutineScope: CoroutineScope, listener: Runnable) {
getPointImpl(null).addChangeListener(listener = listener, coroutineScope = coroutineScope)
}
/**
* Build cache by arbitrary key using provided key to value mapper. Values with the same key merge into a list. Return values by key.
*