Always remove configure notifications without additional checks in tests (KT-23399)

For some reason there were ~1000 tests that were spontaneously
falling (~20%) because they couldn't find some class. It was mostly
Java classes.

Those failures started after cff88a3f8b.

There were group of commits about notifications right before it:
b4fb0e0305b77a0caa83d34edac3253b7d8e082b..1be33b91fa85e50f5048dc5a12604debfa3c19e8

 #KT-23399 Fixed
This commit is contained in:
Nikolay Krasko
2018-04-06 16:30:30 +03:00
parent a8031cfe86
commit cc14df9e6f
3 changed files with 24 additions and 11 deletions
@@ -70,19 +70,28 @@ fun checkHideNonConfiguredNotifications(project: Project) {
DumbService.getInstance(project).waitForSmartMode()
val moduleSourceRootMap = ModuleSourceRootMap(project)
val hideNotification = try {
val moduleSourceRootGroups = notification.notificationState.notConfiguredModules
.mapNotNull { ModuleManager.getInstance(project).findModuleByName(it) }
.map { moduleSourceRootMap.getWholeModuleGroup(it) }
moduleSourceRootGroups.none(::isNotConfiguredNotificationRequired)
} catch (e: IndexNotReadyException) {
checkInProgress.set(false)
ApplicationManager.getApplication().invokeLater {
checkHideNonConfiguredNotifications(project)
}
return@executeOnPooledThread
if (notification.notificationState.debugProjectName != project.name) {
LOG.error("Bad notification check for project: ${project.name}\n${notification.notificationState}")
}
val hideNotification =
if (!ApplicationManager.getApplication().isUnitTestMode) {
try {
val moduleSourceRootGroups = notification.notificationState.notConfiguredModules
.mapNotNull { ModuleManager.getInstance(project).findModuleByName(it) }
.map { moduleSourceRootMap.getWholeModuleGroup(it) }
moduleSourceRootGroups.none(::isNotConfiguredNotificationRequired)
} catch (e: IndexNotReadyException) {
checkInProgress.set(false)
ApplicationManager.getApplication().invokeLater {
checkHideNonConfiguredNotifications(project)
}
return@executeOnPooledThread
}
} else {
true
}
if (hideNotification) {
ApplicationManager.getApplication().invokeLater {
ConfigureKotlinNotificationManager.expireOldNotifications(project)
@@ -48,6 +48,8 @@ class KotlinConfigurationCheckerComponent(project: Project) : AbstractProjectCom
val connection = project.messageBus.connect()
connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
override fun rootsChanged(event: ModuleRootEvent?) {
if (!project.isInitialized) return
if (notificationPostponed && !isSyncing) {
ApplicationManager.getApplication().executeOnPooledThread {
DumbService.getInstance(myProject).waitForSmartMode()
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComp
import javax.swing.event.HyperlinkEvent
data class ConfigureKotlinNotificationState(
val debugProjectName: String,
val notificationString: String,
val notConfiguredModules: Collection<String>
)
@@ -64,6 +65,7 @@ class ConfigureKotlinNotification(
}
return ConfigureKotlinNotificationState(
project.name,
"Configure $modulesString in '${project.name}' project<br/> $links",
configurableModules.map { it.baseModule.name }
)