Allow to suppress "Kotlin not configured" notification per-module
This commit is contained in:
Generated
+7
-1
@@ -52,7 +52,13 @@
|
|||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SuppressABINotification">
|
<component name="SuppressABINotification">
|
||||||
<option name="isSuppressed" value="true" />
|
<option name="modulesWithSuppressedNotConfigured">
|
||||||
|
<set>
|
||||||
|
<option value="kotlin-stdlib-common" />
|
||||||
|
<option value="kotlin-stdlib-js" />
|
||||||
|
<option value="kotlin-test-common" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="WebServicesPlugin" addRequiredLibraries="true" />
|
<component name="WebServicesPlugin" addRequiredLibraries="true" />
|
||||||
<component name="com.sixrr.metrics.MetricsReloaded">
|
<component name="com.sixrr.metrics.MetricsReloaded">
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinN
|
|||||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||||
|
import org.jetbrains.kotlin.idea.versions.SuppressNotificationState
|
||||||
import org.jetbrains.kotlin.idea.versions.getKotlinJvmRuntimeMarkerClass
|
import org.jetbrains.kotlin.idea.versions.getKotlinJvmRuntimeMarkerClass
|
||||||
import org.jetbrains.kotlin.idea.versions.hasKotlinJsKjsmFile
|
import org.jetbrains.kotlin.idea.versions.hasKotlinJsKjsmFile
|
||||||
import org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinder
|
import org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinder
|
||||||
@@ -132,7 +133,7 @@ fun getConfigurableModulesWithKotlinFiles(project: Project): List<ModuleSourceRo
|
|||||||
|
|
||||||
fun showConfigureKotlinNotificationIfNeeded(module: Module) {
|
fun showConfigureKotlinNotificationIfNeeded(module: Module) {
|
||||||
val moduleGroup = ModuleSourceRootMap(module.project).toModuleGroup(module)
|
val moduleGroup = ModuleSourceRootMap(module.project).toModuleGroup(module)
|
||||||
if (isModuleConfigured(moduleGroup)) return
|
if (isNotConfiguredNotificationRequired(moduleGroup)) return
|
||||||
|
|
||||||
ConfigureKotlinNotificationManager.notify(module.project)
|
ConfigureKotlinNotificationManager.notify(module.project)
|
||||||
}
|
}
|
||||||
@@ -140,7 +141,7 @@ fun showConfigureKotlinNotificationIfNeeded(module: Module) {
|
|||||||
fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: List<Module> = emptyList()) {
|
fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: List<Module> = emptyList()) {
|
||||||
val notificationString = DumbService.getInstance(project).runReadActionInSmartMode(Computable {
|
val notificationString = DumbService.getInstance(project).runReadActionInSmartMode(Computable {
|
||||||
val modules = getConfigurableModulesWithKotlinFiles(project).exclude(excludeModules)
|
val modules = getConfigurableModulesWithKotlinFiles(project).exclude(excludeModules)
|
||||||
if (modules.all(::isModuleConfigured))
|
if (modules.all(::isNotConfiguredNotificationRequired))
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
ConfigureKotlinNotification.getNotificationString(project, excludeModules)
|
ConfigureKotlinNotification.getNotificationString(project, excludeModules)
|
||||||
@@ -153,6 +154,10 @@ fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: Li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isNotConfiguredNotificationRequired(moduleGroup: ModuleSourceRootGroup): Boolean {
|
||||||
|
return !SuppressNotificationState.isKotlinNotConfiguredSuppressed(moduleGroup) && isModuleConfigured(moduleGroup)
|
||||||
|
}
|
||||||
|
|
||||||
fun getAbleToRunConfigurators(project: Project): Collection<KotlinProjectConfigurator> {
|
fun getAbleToRunConfigurators(project: Project): Collection<KotlinProjectConfigurator> {
|
||||||
val modules = getConfigurableModules(project)
|
val modules = getConfigurableModules(project)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ fun checkHideNonConfiguredNotifications(project: Project) {
|
|||||||
if (!checkInProgress.compareAndSet(false, true)) return@executeOnPooledThread
|
if (!checkInProgress.compareAndSet(false, true)) return@executeOnPooledThread
|
||||||
|
|
||||||
DumbService.getInstance(project).waitForSmartMode()
|
DumbService.getInstance(project).waitForSmartMode()
|
||||||
if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) {
|
if (getConfigurableModulesWithKotlinFiles(project).all(::isNotConfiguredNotificationRequired)) {
|
||||||
ApplicationManager.getApplication().invokeLater {
|
ApplicationManager.getApplication().invokeLater {
|
||||||
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
ConfigureKotlinNotificationManager.expireOldNotifications(project)
|
||||||
checkInProgress.set(false)
|
checkInProgress.set(false)
|
||||||
|
|||||||
+9
-1
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
|
|||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent
|
import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
|
import org.jetbrains.kotlin.idea.versions.SuppressNotificationState
|
||||||
import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider
|
import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider
|
||||||
import org.jetbrains.kotlin.idea.versions.createComponentActionLabel
|
import org.jetbrains.kotlin.idea.versions.createComponentActionLabel
|
||||||
|
|
||||||
@@ -79,8 +80,10 @@ class KotlinSetupEnvironmentNotificationProvider(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!KotlinConfigurationCheckerComponent.getInstance(module.project).isSyncing &&
|
if (!KotlinConfigurationCheckerComponent.getInstance(module.project).isSyncing &&
|
||||||
|
!SuppressNotificationState.isKotlinNotConfiguredSuppressed(module.toModuleGroup()) &&
|
||||||
!hasAnyKotlinRuntimeInScope(module) &&
|
!hasAnyKotlinRuntimeInScope(module) &&
|
||||||
UnsupportedAbiVersionNotificationPanelProvider.collectBadRoots(module).isEmpty()) {
|
UnsupportedAbiVersionNotificationPanelProvider.collectBadRoots(module).isEmpty()
|
||||||
|
) {
|
||||||
return createKotlinNotConfiguredPanel(module)
|
return createKotlinNotConfiguredPanel(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +124,11 @@ class KotlinSetupEnvironmentNotificationProvider(
|
|||||||
configuratorsPopup.showUnderneathOf(label)
|
configuratorsPopup.showUnderneathOf(label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createComponentActionLabel("Ignore") {
|
||||||
|
SuppressNotificationState.suppressKotlinNotConfigured(module)
|
||||||
|
EditorNotifications.getInstance(module.project).updateAllNotifications()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,34 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.versions
|
package org.jetbrains.kotlin.idea.versions
|
||||||
|
|
||||||
import com.intellij.openapi.components.PersistentStateComponent
|
import com.intellij.openapi.components.*
|
||||||
import com.intellij.openapi.components.State
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.components.Storage
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.components.StoragePathMacros
|
|
||||||
import com.intellij.util.xmlb.XmlSerializerUtil
|
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.ModuleSourceRootGroup
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.toModuleGroup
|
||||||
|
|
||||||
@State(name = "SuppressABINotification", storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE)))
|
@State(name = "SuppressABINotification", storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE)))
|
||||||
class SuppressNotificationState : PersistentStateComponent<SuppressNotificationState> {
|
class SuppressNotificationState : PersistentStateComponent<SuppressNotificationState> {
|
||||||
var isSuppressed: Boolean = false
|
var isSuppressed: Boolean = false
|
||||||
|
var modulesWithSuppressedNotConfigured = sortedSetOf<String>()
|
||||||
|
|
||||||
override fun getState(): SuppressNotificationState = this
|
override fun getState(): SuppressNotificationState = this
|
||||||
|
|
||||||
override fun loadState(state: SuppressNotificationState) {
|
override fun loadState(state: SuppressNotificationState) {
|
||||||
XmlSerializerUtil.copyBean(state, this)
|
XmlSerializerUtil.copyBean(state, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getInstance(project: Project) = ServiceManager.getService(project, SuppressNotificationState::class.java)
|
||||||
|
|
||||||
|
fun isKotlinNotConfiguredSuppressed(moduleGroup: ModuleSourceRootGroup): Boolean {
|
||||||
|
val baseModule = moduleGroup.baseModule
|
||||||
|
return baseModule.name in getInstance(baseModule.project).modulesWithSuppressedNotConfigured
|
||||||
|
}
|
||||||
|
|
||||||
|
fun suppressKotlinNotConfigured(module: Module) {
|
||||||
|
getInstance(module.project).modulesWithSuppressedNotConfigured.add(module.toModuleGroup().baseModule.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user