Minor: refactoring AddValVarToConstructorParameterAction
This commit is contained in:
+3
-2
@@ -30,11 +30,12 @@ import org.jetbrains.kotlin.idea.refactoring.ValVarExpression
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
|
|
||||||
interface AddValVarToConstructorParameterAction {
|
interface AddValVarToConstructorParameterAction {
|
||||||
companion object {
|
companion object {
|
||||||
val actionFamily = "Add val/var to primary constructor parameter"
|
const val actionFamily = "Add val/var to primary constructor parameter"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getActionText(element: KtParameter) = "Add val/var to parameter '${element.name ?: ""}'"
|
fun getActionText(element: KtParameter) = "Add val/var to parameter '${element.name ?: ""}'"
|
||||||
@@ -69,7 +70,7 @@ interface AddValVarToConstructorParameterAction {
|
|||||||
AddValVarToConstructorParameterAction {
|
AddValVarToConstructorParameterAction {
|
||||||
override fun applicabilityRange(element: KtParameter): TextRange? {
|
override fun applicabilityRange(element: KtParameter): TextRange? {
|
||||||
if (!canInvoke(element)) return null
|
if (!canInvoke(element)) return null
|
||||||
if (element.getStrictParentOfType<KtClass>()?.isData() ?: false) return null
|
if (element.getStrictParentOfType<KtClass>()?.isData() == true) return null
|
||||||
text = getActionText(element)
|
text = getActionText(element)
|
||||||
return element.nameIdentifier?.textRange
|
return element.nameIdentifier?.textRange
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user