Extract shouldConfigureInProject to AbstractChangeFeatureSupportLevelFix
This commit is contained in:
@@ -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
|
||||
|
||||
+1
-7
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user