FIR IDE: Delete AddAccessorsIntention in favor of

HLAddAccessorIntentions.
This commit is contained in:
Mark Punzalan
2021-06-09 10:05:56 +00:00
committed by TeamCityServer
parent 91e62832ee
commit 43a8299f48
2 changed files with 9 additions and 36 deletions
@@ -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
}
@@ -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()
}
}
}