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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,14 @@
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
|
||||
abstract class AbstractChangeFeatureSupportLevelFix(
|
||||
element: PsiElement,
|
||||
@@ -35,6 +39,12 @@ abstract class AbstractChangeFeatureSupportLevelFix(
|
||||
}
|
||||
|
||||
abstract class FeatureSupportIntentionActionsFactory : KotlinIntentionActionsFactory() {
|
||||
protected fun shouldConfigureInProject(module: Module): Boolean {
|
||||
val facetSettings = KotlinFacet.get(module)?.configuration?.settings
|
||||
return (facetSettings == null || facetSettings.useProjectSettings) &&
|
||||
module.getBuildSystemType() == BuildSystemType.JPS
|
||||
}
|
||||
|
||||
protected fun doCreateActions(
|
||||
diagnostic: Diagnostic,
|
||||
feature: LanguageFeature,
|
||||
|
||||
Reference in New Issue
Block a user