[api] NotificationGroupManagerImpl is not part of platform API

GitOrigin-RevId: 7b8409537fd307a841f8d2b03ff600271d8478d4
This commit is contained in:
Yuriy Artamonov
2024-09-29 12:19:42 +02:00
committed by intellij-monorepo-bot
parent 0db65f1144
commit beecfea203
2 changed files with 21 additions and 21 deletions

View File

@@ -329,12 +329,6 @@ f:com.intellij.notification.impl.NotificationGroupEP
- getDisplayName(com.intellij.openapi.extensions.PluginDescriptor):java.lang.String
- getDisplayType():com.intellij.notification.NotificationDisplayType
- setPluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor):V
f:com.intellij.notification.impl.NotificationGroupManagerImpl
- com.intellij.notification.NotificationGroupManager
- getNotificationGroup(java.lang.String):com.intellij.notification.NotificationGroup
- getRegisteredNotificationGroups():java.util.Collection
- isGroupRegistered(java.lang.String):Z
- isRegisteredNotificationId(java.lang.String):Z
f:com.intellij.notification.impl.NotificationParentGroupBean
- id:java.lang.String
- parentId:java.lang.String

View File

@@ -7,30 +7,22 @@ import com.intellij.notification.NotificationGroupManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.ExtensionPointListener
import com.intellij.openapi.extensions.PluginDescriptor
import com.intellij.util.concurrency.SynchronizedClearableLazy
import java.util.concurrent.ConcurrentHashMap
private val LOG = logger<NotificationGroupManagerImpl>()
class NotificationGroupManagerImpl private constructor() : NotificationGroupManager {
private val registeredGroups = computeGroups()
internal class NotificationGroupManagerImpl() : NotificationGroupManager {
private val registeredGroups: MutableMap<String, NotificationGroup> = computeGroups()
private val registeredNotificationIds = SynchronizedClearableLazy<Set<String>> {
val result = HashSet<String>()
NotificationGroupEP.EP_NAME.processWithPluginDescriptor { extension, pluginDescriptor ->
if (extension.notificationIds != null && PluginManagerCore.isDevelopedByJetBrains(pluginDescriptor)) {
result.addAll(extension.notificationIds!!)
}
}
result
}
@Volatile
private var registeredNotificationIds: Set<String>? = null
init {
NotificationGroupEP.EP_NAME.addExtensionPointListener(object : ExtensionPointListener<NotificationGroupEP> {
override fun extensionAdded(extension: NotificationGroupEP, pluginDescriptor: PluginDescriptor) {
registerNotificationGroup(extension, pluginDescriptor, registeredGroups)
if (extension.notificationIds != null) {
registeredNotificationIds.drop()
registeredNotificationIds = null
}
}
@@ -40,19 +32,33 @@ class NotificationGroupManagerImpl private constructor() : NotificationGroupMana
registeredGroups.remove(extension.id)
}
if (extension.notificationIds != null) {
registeredNotificationIds.drop()
registeredNotificationIds = null
}
}
}, null)
}
private fun getNotificationIds(): Set<String> {
val existing = registeredNotificationIds
if (existing != null) return existing
val result = HashSet<String>()
NotificationGroupEP.EP_NAME.processWithPluginDescriptor { extension, pluginDescriptor ->
if (extension.notificationIds != null && PluginManagerCore.isDevelopedByJetBrains(pluginDescriptor)) {
result.addAll(extension.notificationIds!!)
}
}
registeredNotificationIds = result
return result
}
override fun getNotificationGroup(groupId: String): NotificationGroup? = registeredGroups[groupId]
override fun isGroupRegistered(groupId: String): Boolean = registeredGroups.containsKey(groupId)
override fun getRegisteredNotificationGroups(): MutableCollection<NotificationGroup> = registeredGroups.values
override fun isRegisteredNotificationId(notificationId: String): Boolean = registeredNotificationIds.value.contains(notificationId)
override fun isRegisteredNotificationId(notificationId: String): Boolean = getNotificationIds().contains(notificationId)
}
private fun computeGroups(): MutableMap<String, NotificationGroup> {