FIR IDE: Delete AddAccessorsIntention in favor of
HLAddAccessorIntentions.
This commit is contained in:
committed by
TeamCityServer
parent
91e62832ee
commit
43a8299f48
@@ -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
|
||||
}
|
||||
+9
-11
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user