Don't show "Configure Kotlin" notification with an empty list of configurators (context: KT-16070)

This commit is contained in:
Dmitry Jemerov
2017-03-10 19:24:00 +01:00
parent 9f8af1feea
commit 95bc0813f8
2 changed files with 8 additions and 6 deletions
@@ -24,7 +24,10 @@ import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinN
object ConfigureKotlinNotificationManager: KotlinSingleNotificationManager<ConfigureKotlinNotification> {
fun notify(project: Project, excludeModules: List<Module> = emptyList()) {
notify(project, ConfigureKotlinNotification(project, excludeModules))
val notificationString = ConfigureKotlinNotification.getNotificationString(project, excludeModules)
if (notificationString != null) {
notify(project, ConfigureKotlinNotification(project, excludeModules, notificationString))
}
}
}
@@ -42,9 +42,6 @@ class ConfigureKotlinNotification(
}
}) {
constructor(project: Project, excludeModules: List<Module>)
: this(project, excludeModules, getNotificationString(project, excludeModules))
override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o !is ConfigureKotlinNotification) return false
@@ -59,13 +56,15 @@ class ConfigureKotlinNotification(
}
companion object {
fun getNotificationString(project: Project, excludeModules: Collection<Module>): String {
fun getNotificationString(project: Project, excludeModules: Collection<Module>): String? {
val modules = getNonConfiguredModulesWithKotlinFiles(project, excludeModules)
val isOnlyOneModule = modules.size == 1
val modulesString = if (isOnlyOneModule) "'${modules.first().name}' module" else "modules"
val links = getAbleToRunConfigurators(project).joinToString(separator = "<br/>") {
val ableToRunConfigurators = getAbleToRunConfigurators(project)
if (ableToRunConfigurators.isEmpty()) return null
val links = ableToRunConfigurators.joinToString(separator = "<br/>") {
configurator -> getLink(configurator, isOnlyOneModule)
}