Fix MoveProperty intention: better property placement
Property is placed now before first property, or at the beginning of class body if no properties found. #KT-18044 Fixed
This commit is contained in:
@@ -39,7 +39,8 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtP
|
||||
val propertyDeclaration = KtPsiFactory(element)
|
||||
.createProperty("${element.valOrVarKeyword?.text} ${element.name} = ${element.name}")
|
||||
|
||||
parentClass.addDeclaration(propertyDeclaration).apply {
|
||||
val firstProperty = parentClass.getProperties().firstOrNull()
|
||||
parentClass.addDeclarationBefore(propertyDeclaration, firstProperty).apply {
|
||||
val propertyModifierList = element.modifierList?.copy() as? KtModifierList
|
||||
propertyModifierList?.let { modifierList?.replace(it) ?: addBefore(it, firstChild) }
|
||||
modifierList?.annotationEntries?.forEach {
|
||||
|
||||
Reference in New Issue
Block a user