From 8a5dbe1c6b5b089eecf3029735177c098f75ef26 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 6 Sep 2018 16:32:16 +0300 Subject: [PATCH] Move property to constructor: minor refactoring Related to KT-26015 --- .../intentions/MovePropertyToConstructorIntention.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt index 55d26094a7a..0186c483377 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MovePropertyToConstructorIntention.kt @@ -129,16 +129,19 @@ class MovePropertyToConstructorIntention : private fun KtAnnotationEntry.getTextWithUseSite(context: BindingContext): String { if (useSiteTarget != null) return text val typeReference = this.typeReference?.text ?: return text + val valueArgumentList = valueArgumentList?.text.orEmpty() + + fun AnnotationUseSiteTarget.textWithMe() = "@$renderName:$typeReference$valueArgumentList" + val descriptor = context[BindingContext.ANNOTATION, this] ?: return text val applicableTargets = AnnotationChecker.applicableTargetSet(descriptor) - val valueArgumentList = valueArgumentList?.text.orEmpty() return when { KotlinTarget.VALUE_PARAMETER !in applicableTargets -> text KotlinTarget.PROPERTY in applicableTargets -> - "@${AnnotationUseSiteTarget.PROPERTY.renderName}:$typeReference$valueArgumentList" + AnnotationUseSiteTarget.PROPERTY.textWithMe() KotlinTarget.FIELD in applicableTargets -> - "@${AnnotationUseSiteTarget.FIELD.renderName}:$typeReference$valueArgumentList" + AnnotationUseSiteTarget.FIELD.textWithMe() else -> text }