Extract shouldConfigureInProject to AbstractChangeFeatureSupportLevelFix

This commit is contained in:
Mikhail Glukhikh
2018-09-20 14:47:47 +03:00
parent 7030a485be
commit c5a81c4e8b
3 changed files with 12 additions and 14 deletions
@@ -64,15 +64,9 @@ sealed class ChangeCoroutineSupportFix(
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
val module = ModuleUtilCore.findModuleForPsiElement(diagnostic.psiElement) ?: return emptyList()
fun shouldConfigureInProject(): Boolean {
val facetSettings = KotlinFacet.get(module)?.configuration?.settings
return (facetSettings == null || facetSettings.useProjectSettings) &&
module.getBuildSystemType() == BuildSystemType.JPS
}
return doCreateActions(
diagnostic, LanguageFeature.Coroutines, allowWarningAndErrorMode = true,
quickFixConstructor = if (shouldConfigureInProject()) { element, _, coroutineSupport ->
quickFixConstructor = if (shouldConfigureInProject(module)) { element, _, coroutineSupport ->
InProject(
element,
coroutineSupport
@@ -71,16 +71,10 @@ sealed class ChangeGeneralLanguageFeatureSupportFix(
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
val module = ModuleUtilCore.findModuleForPsiElement(diagnostic.psiElement) ?: return emptyList()
fun shouldConfigureInProject(): Boolean {
val facetSettings = KotlinFacet.get(module)?.configuration?.settings
return (facetSettings == null || facetSettings.useProjectSettings) &&
module.getBuildSystemType() == BuildSystemType.JPS
}
return supportedFeatures.flatMap { feature ->
doCreateActions(
diagnostic, feature, allowWarningAndErrorMode = false,
quickFixConstructor = if (shouldConfigureInProject()) ::InProject else ::InModule
quickFixConstructor = if (shouldConfigureInProject(module)) ::InProject else ::InModule
)
}
}