diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/HLDiagnosticFixFactory.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/HLDiagnosticFixFactory.kt index ef36a337c85..7ff07601b84 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/HLDiagnosticFixFactory.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/HLDiagnosticFixFactory.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi sealed class HLDiagnosticFixFactory> { - abstract fun KtAnalysisSession.createQuickFixes(diagnostic: DIAGNOSTIC): List> + abstract fun KtAnalysisSession.createQuickFixes(diagnostic: DIAGNOSTIC): List } private class HLDiagnosticFixFactoryWithFixedApplicator, TARGET_PSI : PsiElement, INPUT : HLApplicatorInput>( @@ -25,9 +25,9 @@ private class HLDiagnosticFixFactoryWithFixedApplicator>( - private val createQuickFixes: KtAnalysisSession.(DIAGNOSTIC) -> List> + private val createQuickFixes: KtAnalysisSession.(DIAGNOSTIC) -> List ) : HLDiagnosticFixFactory() { - override fun KtAnalysisSession.createQuickFixes(diagnostic: DIAGNOSTIC): List> = + override fun KtAnalysisSession.createQuickFixes(diagnostic: DIAGNOSTIC): List = createQuickFixes.invoke(this, diagnostic) } @@ -50,6 +50,6 @@ fun , TARGET_PSI : PsiElement, INPUT : HLApp * Returns a [HLDiagnosticFixFactory] that creates [HLQuickFix]es from a diagnostic. */ fun > diagnosticFixFactory( - createQuickFixes: KtAnalysisSession.(DIAGNOSTIC) -> List> + createQuickFixes: KtAnalysisSession.(DIAGNOSTIC) -> List ): HLDiagnosticFixFactory = HLDiagnosticFixFactoryWithVariableApplicator(createQuickFixes) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ReplaceCallFixFactories.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ReplaceCallFixFactories.kt index c714354c609..725e6dbd0e7 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ReplaceCallFixFactories.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ReplaceCallFixFactories.kt @@ -5,15 +5,10 @@ package org.jetbrains.kotlin.idea.quickfix.fixes -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicatorInput -import org.jetbrains.kotlin.idea.fir.api.applicator.applicatorByQuickFix -import org.jetbrains.kotlin.idea.fir.api.fixes.HLQuickFix import org.jetbrains.kotlin.idea.fir.api.fixes.diagnosticFixFactory import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeNullability import org.jetbrains.kotlin.idea.frontend.api.types.KtTypeWithNullability -import org.jetbrains.kotlin.idea.quickfix.ReplaceCallFix import org.jetbrains.kotlin.idea.quickfix.ReplaceImplicitReceiverCallFix import org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix import org.jetbrains.kotlin.psi.KtDotQualifiedExpression @@ -21,23 +16,6 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtNameReferenceExpression object ReplaceCallFixFactories { - private val replaceWithSafeCallFixApplicator = - applicatorByQuickFix( - getFamilyName = KotlinBundle.lazyMessage("replace.with.safe.call"), - isApplicableByPsi = { psi -> psi is KtDotQualifiedExpression } - ) { psi, input -> - ReplaceWithSafeCallFix(psi as KtDotQualifiedExpression, input.notNullNeeded) - } - - private val replaceImplicitReceiverCallFixApplicator = - applicatorByQuickFix( - getFamilyName = KotlinBundle.lazyMessage("replace.with.safe.this.call") - ) { psi, input -> - ReplaceImplicitReceiverCallFix(psi, input.notNullNeeded) - } - - class Input(val notNullNeeded: Boolean) : HLApplicatorInput - val unsafeCallFactory = diagnosticFixFactory { diagnostic -> fun KtExpression.shouldHaveNotNullType(): Boolean { @@ -48,13 +26,13 @@ object ReplaceCallFixFactories { } when (val psi = diagnostic.psi) { - is KtDotQualifiedExpression -> listOf(HLQuickFix(psi, Input(psi.shouldHaveNotNullType()), replaceWithSafeCallFixApplicator)) + is KtDotQualifiedExpression -> listOf(ReplaceWithSafeCallFix(psi, psi.shouldHaveNotNullType())) is KtNameReferenceExpression -> { // TODO: As a safety precaution, resolve the expression to determine if it is a call with an implicit receiver. // This is a defensive check to ensure that the diagnostic was reported on such a call and not some other name reference. // This isn't strictly needed because FIR checkers aren't reporting on wrong elements, but ReplaceWithSafeCallFixFactory // in FE1.0 does so. - listOf(HLQuickFix(psi, Input(psi.shouldHaveNotNullType()), replaceImplicitReceiverCallFixApplicator)) + listOf(ReplaceImplicitReceiverCallFix(psi, psi.shouldHaveNotNullType())) } else -> emptyList() }