From 43a8299f48b8792bc2553d5576be19e54fc481d3 Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Wed, 9 Jun 2021 10:05:56 +0000 Subject: [PATCH] FIR IDE: Delete AddAccessorsIntention in favor of HLAddAccessorIntentions. --- .../intentions/fir/AddAccessorsIntention.kt | 25 ------------------- .../quickfix/fixes/AddAccessorsFactories.kt | 20 +++++++-------- 2 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/intentions/fir/AddAccessorsIntention.kt diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/intentions/fir/AddAccessorsIntention.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/intentions/fir/AddAccessorsIntention.kt deleted file mode 100644 index 2d83c057785..00000000000 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/intentions/fir/AddAccessorsIntention.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.idea.intentions.fir - -import com.intellij.codeInsight.intention.PriorityAction -import com.intellij.openapi.util.TextRange -import org.jetbrains.kotlin.idea.intentions.AbstractAddAccessorsIntention -import org.jetbrains.kotlin.psi.KtProperty - -class AddAccessorsIntention( - addGetter: Boolean, addSetter: Boolean, - private val priority: PriorityAction.Priority -) : - AbstractAddAccessorsIntention(addGetter, addSetter), PriorityAction { - // FE1.0 logic in org.jetbrains.kotlin.idea.intentions.AddAccessorsIntention has additional defensive checks to ensure the - // intention only shows up if the property in question indeed needs initialization or accessors. Those checks are unnecessary - // since this factory is coupled with MUST_BE_INITIALIZED_OR_BE_ABSTRACT diagnostic, which has already checked the applicability - // of this intention. - override fun applicabilityRange(element: KtProperty): TextRange? = element.textRange - - override fun getPriority(): PriorityAction.Priority = priority -} \ No newline at end of file diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/AddAccessorsFactories.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/AddAccessorsFactories.kt index 6533c30fcc1..a1f29cdd2d2 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/AddAccessorsFactories.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/AddAccessorsFactories.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.idea.quickfix.fixes -import com.intellij.codeInsight.intention.PriorityAction import org.jetbrains.kotlin.idea.fir.api.fixes.diagnosticFixFactory +import org.jetbrains.kotlin.idea.fir.intentions.HLAddGetterAndSetterIntention +import org.jetbrains.kotlin.idea.fir.intentions.HLAddGetterIntention +import org.jetbrains.kotlin.idea.fir.intentions.HLAddSetterIntention import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic -import org.jetbrains.kotlin.idea.intentions.fir.AddAccessorsIntention import org.jetbrains.kotlin.psi.KtProperty object AddAccessorsFactories { @@ -16,14 +17,11 @@ object AddAccessorsFactories { val property: KtProperty = diagnostic.psi val addGetter = property.getter == null val addSetter = property.isVar && property.setter == null - if (!addGetter && !addSetter) return@diagnosticFixFactory emptyList() - - listOf( - AddAccessorsIntention( - addGetter, - addSetter, - if (addGetter && addSetter) PriorityAction.Priority.LOW else PriorityAction.Priority.NORMAL - ) - ) + when { + addGetter && addSetter -> listOf(HLAddGetterAndSetterIntention()) + addGetter -> listOf(HLAddGetterIntention()) + addSetter -> listOf(HLAddSetterIntention()) + else -> emptyList() + } } } \ No newline at end of file