From 549b6c9d85c4e574b0a2829ba978b40fb41e78e5 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Wed, 14 Dec 2022 12:32:18 +0100 Subject: [PATCH] UsePropertyAccessSyntaxIntention: minor bundle string cleanup Because "getter" and "setter" UI strings shouldn't be hardcoded into code In scope of KTIJ-23892 Review: https://jetbrains.team/p/ij/reviews/100206 GitOrigin-RevId: c9026ae449cd1c87d27fde0cee7b0fe9318446af --- .../resources-en/messages/KotlinBundle.properties | 3 ++- .../idea/intentions/UsePropertyAccessSyntaxIntention.kt | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties index 783044b6a56a..b209413a1ee3 100644 --- a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties +++ b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties @@ -1843,7 +1843,8 @@ to.raw.string.literal=To raw string literal remove.underscores=Remove underscores add.underscores=Add underscores excluded.methods=Excluded methods -use.of.0.method.instead.of.property.access.syntax=Use of {0} method instead of property access syntax +use.of.getter.method.instead.of.property.access.syntax=Use of getter method instead of property access syntax +use.of.setter.method.instead.of.property.access.syntax=Use of setter method instead of property access syntax use.property.access.syntax=Use property access syntax convert.to.object.declaration=Convert to object declaration comment=Comment diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 88b32fe4c610..458c1476afac 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -94,12 +94,11 @@ class UsePropertyAccessSyntaxInspection : IntentionBasedInspection "getter" - 1 -> "setter" - else -> null + return when (element.valueArguments.size) { + 0 -> KotlinBundle.message("use.of.getter.method.instead.of.property.access.syntax") + 1 -> KotlinBundle.message("use.of.setter.method.instead.of.property.access.syntax") + else -> error("getter or setter arg length can't be !in 0..1") } - return KotlinBundle.message("use.of.0.method.instead.of.property.access.syntax", accessor.toString()) } }