diff --git a/CHANGELOG.md b/CHANGELOG.md index 9726c5a..d5ff906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ # diff-coverage-idea-plugin Changelog ## [Unreleased] +### Fixed +- fixed error on project open + +## [1.0.0] ### Added - Keep diff coverage configuration settings per IDE session - Added option to set up min coverage in run configuration diff --git a/gradle.properties b/gradle.properties index f4ea91f..2ba7e5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = com.github.surpsg.diffcoverage pluginName = Diff Coverage -pluginVersion = 1.0.0 +pluginVersion = 1.0.1 pluginSinceBuild = 203 pluginUntilBuild = 211.* pluginVerifierIdeVersions = 2020.3.2, 2020.3.3, 2021.1 diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/domain/CoverageSuiteBundleWithStat.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/domain/CoverageSuiteBundleWithStat.kt index 8048a2f..8ebd7a5 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/domain/CoverageSuiteBundleWithStat.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/domain/CoverageSuiteBundleWithStat.kt @@ -10,11 +10,11 @@ class CoverageSuiteBundleWithStat(suite: CoverageSuite) : CoverageSuitesBundle(s .map { it.getCoverageData(null) } .map { it as? ProjectDataWithStat } .filterNotNull() - .first() - .apply { + .firstOrNull() + ?.apply { super.getCoverageData()?.let { merge(it) } - } + } ?: ProjectDataWithStat(CoverageStat(emptyMap())) } } diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/listeners/ProjectOpenListener.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/listeners/ProjectOpenListener.kt index 515d1d7..312f2de 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/listeners/ProjectOpenListener.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/listeners/ProjectOpenListener.kt @@ -38,7 +38,7 @@ class ProjectOpenListener : ProjectManagerListener { super.onSuccess(id) if (id.type == ExternalSystemTaskType.RESOLVE_PROJECT) { BACKGROUND_SCOPE.launch { - project.service().reloadSettings() + project.service().reloadSettings(true) } } } diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/services/PersistentDiffCoverageSettingsService.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/services/PersistentDiffCoverageSettingsService.kt index f6e3860..06652df 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/services/PersistentDiffCoverageSettingsService.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/services/PersistentDiffCoverageSettingsService.kt @@ -29,27 +29,31 @@ class PersistentDiffCoverageSettingsService(private val project: Project) { } } - suspend fun reloadSettings(): Pair { + suspend fun reloadSettings( + silent: Boolean = false + ): Pair { return suspendCoroutine { - reloadSettingsWhenProjectInitialized(it) + reloadSettingsWhenProjectInitialized(silent, it) } } private fun reloadSettingsWhenProjectInitialized( + silent: Boolean, continuation: Continuation> ) { DumbService.getInstance(project).runWhenSmart { ExternalProjectsManager.getInstance(project).runWhenInitialized { - loadSettingsAsync(continuation) + loadSettingsAsync(silent, continuation) } } } private fun loadSettingsAsync( + silent: Boolean, continuation: Continuation> ) = BACKGROUND_SCOPE.launch { val configurationProvider = PersistentDiffCoverageConfigurationSettings.getInstance() - val diffCoverageSettings = project.service().obtainDiffCoverageSettings() + val diffCoverageSettings = project.service().obtainDiffCoverageSettings(silent) val result = if (diffCoverageSettings == null) { configurationProvider.setInitializationStatus(DiffPluginInitializationStatus.FAILED) DiffPluginInitializationStatus.FAILED to DiffCoverageConfiguration() diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/DiffCoverageSettingsService.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/DiffCoverageSettingsService.kt index 5d24254..c742b3d 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/DiffCoverageSettingsService.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/DiffCoverageSettingsService.kt @@ -20,9 +20,9 @@ import java.io.File @Service class DiffCoverageSettingsService(private val project: Project) { - suspend fun obtainDiffCoverageSettings(): DiffCoverageConfiguration? { + suspend fun obtainDiffCoverageSettings(silent: Boolean = false): DiffCoverageConfiguration? { val gradleModule: GradleModule? = project.service() - .lookupDiffCoveragePluginModule() + .lookupDiffCoveragePluginModule(silent) return if (gradleModule == null) { null } else { diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/GradleDiffCoverageModuleService.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/GradleDiffCoverageModuleService.kt index ae40aa5..a29b4cc 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/GradleDiffCoverageModuleService.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/services/gradle/GradleDiffCoverageModuleService.kt @@ -21,8 +21,8 @@ import java.nio.file.Paths @Service class GradleDiffCoverageModuleService(private val project: Project) { - fun lookupDiffCoveragePluginModule(): GradleModule? { - val diffCoverageModule = getDiffCoverageModule() ?: return null + fun lookupDiffCoveragePluginModule(silent: Boolean = false): GradleModule? { + val diffCoverageModule = getDiffCoverageModule(silent) ?: return null val rootModulePath = getRootModulePath() val diffCoverageModuleKey = normalizeModuleKey(rootModulePath, diffCoverageModule) @@ -34,10 +34,11 @@ class GradleDiffCoverageModuleService(private val project: Project) { ?.let { GradleModule(diffCoverageModule, it.linkedExternalProjectPath) } } - private fun getDiffCoverageModule(): String? { + private fun getDiffCoverageModule(silent: Boolean): String? { val diffPluginAppliedTo: Map> = lookupDiffCoveragePluginModules() if (diffPluginAppliedTo.isEmpty() || diffPluginAppliedTo.first().value.isEmpty()) { project.service().notify( + silent = silent, notificationType = NotificationType.ERROR, notificationListener = NotificationListener.URL_OPENING_LISTENER, message = DiffCoverageBundle.message("no.diff.coverage.entries") @@ -46,6 +47,7 @@ class GradleDiffCoverageModuleService(private val project: Project) { } if (diffPluginAppliedTo.size > 1 || diffPluginAppliedTo.first().value.size > 1) { project.service().notify( + silent = silent, notificationType = NotificationType.ERROR, message = DiffCoverageBundle.message( "multiple.diff.coverage.entries", diff --git a/src/main/kotlin/com/github/surpsg/diffcoverage/services/notifications/BalloonNotificationService.kt b/src/main/kotlin/com/github/surpsg/diffcoverage/services/notifications/BalloonNotificationService.kt index 2067d9b..808a206 100644 --- a/src/main/kotlin/com/github/surpsg/diffcoverage/services/notifications/BalloonNotificationService.kt +++ b/src/main/kotlin/com/github/surpsg/diffcoverage/services/notifications/BalloonNotificationService.kt @@ -17,8 +17,12 @@ class BalloonNotificationService(private val project: Project) { title: String = DiffCoverageBundle.message(PLUGIN_NAME), notificationType: NotificationType = NotificationType.INFORMATION, notificationListener: NotificationListener? = null, - message: String + message: String, + silent: Boolean = false ) { + if (silent) { + return + } Notifications.Bus.notify( getNotificationGroup().createNotification( title, diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index ca4fb1c..f62fb3b 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -13,7 +13,7 @@ ]]> Initial release of the plugin. - 1.0.0 + 1.0.1