From a8589105b026db030b004dc98e684b5133095cc8 Mon Sep 17 00:00:00 2001 From: "Victoria.Petrakovich" Date: Thu, 26 Jun 2025 17:41:42 +0200 Subject: [PATCH] [kotlin] Add test showing that "Use property access syntax" inspection/intention is not proposed for Java enums ^KTIJ-33953 Fixed GitOrigin-RevId: 80fad1a90a6748b00608dba798082550ec90a453 --- .../tests/K2LocalInspectionTestGenerated.java | 5 +++++ .../inspections/LocalInspectionTestGenerated.java | 5 +++++ .../idea/intentions/K1IntentionTestGenerated.java | 5 +++++ .../dontReplaceForEnum.1.java | 12 ++++++++++++ .../dontReplaceForEnum.kt | 5 +++++ .../dontReplaceForEnum.1.java | 12 ++++++++++++ .../usePropertyAccessSyntax/dontReplaceForEnum.kt | 5 +++++ 7 files changed, 49 insertions(+) create mode 100644 plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.1.java create mode 100644 plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt create mode 100644 plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.1.java create mode 100644 plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.kt diff --git a/plugins/kotlin/code-insight/inspections-k2/tests/test/org/jetbrains/kotlin/idea/k2/inspections/tests/K2LocalInspectionTestGenerated.java b/plugins/kotlin/code-insight/inspections-k2/tests/test/org/jetbrains/kotlin/idea/k2/inspections/tests/K2LocalInspectionTestGenerated.java index f42c4a7da9ea..cf04bac11028 100644 --- a/plugins/kotlin/code-insight/inspections-k2/tests/test/org/jetbrains/kotlin/idea/k2/inspections/tests/K2LocalInspectionTestGenerated.java +++ b/plugins/kotlin/code-insight/inspections-k2/tests/test/org/jetbrains/kotlin/idea/k2/inspections/tests/K2LocalInspectionTestGenerated.java @@ -8029,6 +8029,11 @@ public abstract class K2LocalInspectionTestGenerated extends AbstractK2LocalInsp runTest("../../../idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceCallableReferenceGetterIn1dot9.kt"); } + @TestMetadata("dontReplaceForEnum.kt") + public void testDontReplaceForEnum() throws Exception { + runTest("../../../idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt"); + } + @TestMetadata("dontReplaceGetterNotBuiltInFunctionType.kt") public void testDontReplaceGetterNotBuiltInFunctionType() throws Exception { runTest("../../../idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceGetterNotBuiltInFunctionType.kt"); diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 61810a60bff8..a81dae312fa3 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -18746,6 +18746,11 @@ public abstract class LocalInspectionTestGenerated extends AbstractLocalInspecti runTest("testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceCallableReferenceGetterIn1dot9.kt"); } + @TestMetadata("dontReplaceForEnum.kt") + public void testDontReplaceForEnum() throws Exception { + runTest("testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt"); + } + @TestMetadata("dontReplaceGetterNotBuiltInFunctionType.kt") public void testDontReplaceGetterNotBuiltInFunctionType() throws Exception { runTest("testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceGetterNotBuiltInFunctionType.kt"); diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java index 56c95acb254c..90b5fdec76c5 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/intentions/K1IntentionTestGenerated.java @@ -18363,6 +18363,11 @@ public abstract class K1IntentionTestGenerated extends AbstractK1IntentionTest { runTest("testData/intentions/usePropertyAccessSyntax/conflict2.kt"); } + @TestMetadata("dontReplaceForEnum.kt") + public void testDontReplaceForEnum() throws Exception { + runTest("testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.kt"); + } + @TestMetadata("genericClassMethod.kt") public void testGenericClassMethod() throws Exception { runTest("testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt"); diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.1.java b/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.1.java new file mode 100644 index 000000000000..da763020da3d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.1.java @@ -0,0 +1,12 @@ +public enum TestEnum { + TEST_ENUM_ENTRY("test enum entry"); + private final String name; + + TestEnum(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt b/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt new file mode 100644 index 000000000000..c8567e93018f --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/usePropertyAccessSyntax/callableReferenceExpressions/dontReplaceForEnum.kt @@ -0,0 +1,5 @@ +// PROBLEM: none +fun main() { + val entry = TestEnum.TEST_ENUM_ENTRY + entry.getName() +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.1.java b/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.1.java new file mode 100644 index 000000000000..da763020da3d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.1.java @@ -0,0 +1,12 @@ +public enum TestEnum { + TEST_ENUM_ENTRY("test enum entry"); + private final String name; + + TestEnum(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.kt b/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.kt new file mode 100644 index 000000000000..5d76d6c456ce --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/intentions/usePropertyAccessSyntax/dontReplaceForEnum.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false +fun main() { + val entry = TestEnum.TEST_ENUM_ENTRY + entry.getName() +} \ No newline at end of file