From 189c7bd7ed588fbb173f585f175aa851701ccda9 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Sun, 29 Sep 2024 22:03:34 +0200 Subject: [PATCH] [kotlin] Fixed postfix templates for kotlin/*Array #KTIJ-31254 Fixed GitOrigin-RevId: f5a9bfae92387d015d1a464d29a07edd8f60aebd --- .../idea/codeInsight/postfix/KotlinForPostfixTemplate.kt | 8 ++++++++ .../postfix/test/K2PostfixTemplateTestGenerated.java | 5 +++++ .../testData/expansion/for/intArray.after.kt | 5 +++++ .../postfix-templates/testData/expansion/for/intArray.kt | 3 +++ 4 files changed, 21 insertions(+) create mode 100644 plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.after.kt create mode 100644 plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.kt diff --git a/plugins/kotlin/code-insight/postfix-templates/src/org/jetbrains/kotlin/idea/codeInsight/postfix/KotlinForPostfixTemplate.kt b/plugins/kotlin/code-insight/postfix-templates/src/org/jetbrains/kotlin/idea/codeInsight/postfix/KotlinForPostfixTemplate.kt index d191d0b25d00..8116c06f48f2 100644 --- a/plugins/kotlin/code-insight/postfix-templates/src/org/jetbrains/kotlin/idea/codeInsight/postfix/KotlinForPostfixTemplate.kt +++ b/plugins/kotlin/code-insight/postfix-templates/src/org/jetbrains/kotlin/idea/codeInsight/postfix/KotlinForPostfixTemplate.kt @@ -142,6 +142,14 @@ private val INT_CLASS_ID = ClassId.fromString("kotlin/Int") private val ITERABLE_CLASS_IDS: Set = setOf( ClassId.fromString("kotlin/Array"), + ClassId.fromString("kotlin/BooleanArray"), + ClassId.fromString("kotlin/ByteArray"), + ClassId.fromString("kotlin/CharArray"), + ClassId.fromString("kotlin/DoubleArray"), + ClassId.fromString("kotlin/FloatArray"), + ClassId.fromString("kotlin/IntArray"), + ClassId.fromString("kotlin/LongArray"), + ClassId.fromString("kotlin/ShortArray"), ClassId.fromString("kotlin/collections/Iterable"), ClassId.fromString("kotlin/collections/Map"), ClassId.fromString("kotlin/sequences/Sequence"), diff --git a/plugins/kotlin/code-insight/postfix-templates/test/org/jetbrains/kotlin/idea/k2/codeInsight/postfix/test/K2PostfixTemplateTestGenerated.java b/plugins/kotlin/code-insight/postfix-templates/test/org/jetbrains/kotlin/idea/k2/codeInsight/postfix/test/K2PostfixTemplateTestGenerated.java index d8077ef1857d..bdcbd9e2d49d 100644 --- a/plugins/kotlin/code-insight/postfix-templates/test/org/jetbrains/kotlin/idea/k2/codeInsight/postfix/test/K2PostfixTemplateTestGenerated.java +++ b/plugins/kotlin/code-insight/postfix-templates/test/org/jetbrains/kotlin/idea/k2/codeInsight/postfix/test/K2PostfixTemplateTestGenerated.java @@ -136,6 +136,11 @@ public abstract class K2PostfixTemplateTestGenerated extends AbstractK2PostfixTe performTest(); } + @TestMetadata("intArray.kt") + public void testIntArray() throws Exception { + performTest(); + } + @TestMetadata("list.kt") public void testList() throws Exception { performTest(); diff --git a/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.after.kt b/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.after.kt new file mode 100644 index 000000000000..35355baaf4cd --- /dev/null +++ b/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.after.kt @@ -0,0 +1,5 @@ +fun test() { + for (i in intArrayOf(1, 2, 3)) { + + } +} \ No newline at end of file diff --git a/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.kt b/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.kt new file mode 100644 index 000000000000..198876c1bcda --- /dev/null +++ b/plugins/kotlin/code-insight/postfix-templates/testData/expansion/for/intArray.kt @@ -0,0 +1,3 @@ +fun test() { + intArrayOf(1, 2, 3) +} \ No newline at end of file