diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java index d69c4c916237..ba1225639122 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractionTestGenerated.java @@ -747,6 +747,11 @@ public abstract class ExtractionTestGenerated extends AbstractExtractionTest { runTest("testData/refactoring/introduceVariable/dynamicType.kt"); } + @TestMetadata("enumEntry.kt") + public void testEnumEntry() throws Exception { + runTest("testData/refactoring/introduceVariable/enumEntry.kt"); + } + @TestMetadata("expressionBodyErrorType.kt") public void testExpressionBodyErrorType() throws Exception { runTest("testData/refactoring/introduceVariable/expressionBodyErrorType.kt"); diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt new file mode 100644 index 000000000000..0db267d0e299 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt @@ -0,0 +1,5 @@ +enum class Color(val rgb: Int) { + RED(0xFF0000), + GREEN(0x00FF00), + BLUE(0x0000FF) +} diff --git a/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt.after b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt.after new file mode 100644 index 000000000000..745c95086c7e --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/refactoring/introduceVariable/enumEntry.kt.after @@ -0,0 +1,7 @@ +val rgb1 = 0xFF0000 + +enum class Color(val rgb: Int) { + RED(rgb1), + GREEN(0x00FF00), + BLUE(0x0000FF) +} diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt index b5e0cbacefcc..5d5b80f61b79 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/introduce/KotlinIntroduceVariableHandler.kt @@ -226,7 +226,7 @@ abstract class KotlinIntroduceVariableHandler : RefactoringActionHandler { is KtBlockExpression -> true is KtWhenEntry -> place == parent.expression is KtDeclarationWithBody -> parent.bodyExpression == place - is KtClassBody -> true + is KtClassBody -> place !is KtEnumEntry is KtFile -> true else -> false } diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.tests.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableTestGenerated.java b/plugins/kotlin/refactorings/kotlin.refactorings.tests.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableTestGenerated.java index 2133204f239d..3231833534d1 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.tests.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableTestGenerated.java +++ b/plugins/kotlin/refactorings/kotlin.refactorings.tests.k2/test/org/jetbrains/kotlin/idea/k2/refactoring/introduce/introduceVariable/K2IntroduceVariableTestGenerated.java @@ -745,6 +745,11 @@ public abstract class K2IntroduceVariableTestGenerated extends AbstractK2Introdu runTest("../../idea/tests/testData/refactoring/introduceVariable/dynamicType.kt"); } + @TestMetadata("enumEntry.kt") + public void testEnumEntry() throws Exception { + runTest("../../idea/tests/testData/refactoring/introduceVariable/enumEntry.kt"); + } + @TestMetadata("expressionBodyErrorType.kt") public void testExpressionBodyErrorType() throws Exception { runTest("../../idea/tests/testData/refactoring/introduceVariable/expressionBodyErrorType.kt");