[kotlin] Extract variable: fix selection of container for enum entry constructor argument

^KTIJ-27683 Fixed

GitOrigin-RevId: b0ecf01c88c4e45f25b0da2df36951733292fce6
This commit is contained in:
Andrey Cherkasov
2024-10-02 23:35:45 +00:00
committed by intellij-monorepo-bot
parent efd46d0c2e
commit db7ffa9987
5 changed files with 23 additions and 1 deletions
@@ -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");
@@ -0,0 +1,5 @@
enum class Color(val rgb: Int) {
RED(<caret>0xFF0000),
GREEN(0x00FF00),
BLUE(0x0000FF)
}
@@ -0,0 +1,7 @@
val rgb1 = 0xFF0000
enum class Color(val rgb: Int) {
RED(rgb1),
GREEN(0x00FF00),
BLUE(0x0000FF)
}
@@ -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
}
@@ -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");