Move property to constructor: minor refactoring
Related to KT-26015
This commit is contained in:
@@ -129,16 +129,19 @@ class MovePropertyToConstructorIntention :
|
|||||||
private fun KtAnnotationEntry.getTextWithUseSite(context: BindingContext): String {
|
private fun KtAnnotationEntry.getTextWithUseSite(context: BindingContext): String {
|
||||||
if (useSiteTarget != null) return text
|
if (useSiteTarget != null) return text
|
||||||
val typeReference = this.typeReference?.text ?: 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 descriptor = context[BindingContext.ANNOTATION, this] ?: return text
|
||||||
val applicableTargets = AnnotationChecker.applicableTargetSet(descriptor)
|
val applicableTargets = AnnotationChecker.applicableTargetSet(descriptor)
|
||||||
val valueArgumentList = valueArgumentList?.text.orEmpty()
|
|
||||||
return when {
|
return when {
|
||||||
KotlinTarget.VALUE_PARAMETER !in applicableTargets ->
|
KotlinTarget.VALUE_PARAMETER !in applicableTargets ->
|
||||||
text
|
text
|
||||||
KotlinTarget.PROPERTY in applicableTargets ->
|
KotlinTarget.PROPERTY in applicableTargets ->
|
||||||
"@${AnnotationUseSiteTarget.PROPERTY.renderName}:$typeReference$valueArgumentList"
|
AnnotationUseSiteTarget.PROPERTY.textWithMe()
|
||||||
KotlinTarget.FIELD in applicableTargets ->
|
KotlinTarget.FIELD in applicableTargets ->
|
||||||
"@${AnnotationUseSiteTarget.FIELD.renderName}:$typeReference$valueArgumentList"
|
AnnotationUseSiteTarget.FIELD.textWithMe()
|
||||||
else ->
|
else ->
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user