Don't report when property is multi-line and action is MOVE

This commit is contained in:
Toshiaki Kameyama
2020-09-09 10:10:17 +09:00
committed by Dmitry Gridin
parent 4569b85a16
commit 5c011bc954
6 changed files with 10 additions and 17 deletions
@@ -41,6 +41,7 @@ class MoveVariableDeclarationIntoWhenInspection : AbstractKotlinInspection(), Cl
val action = property.action(expression)
if (action == Action.NOTHING) return
if (action == Action.MOVE && !property.isOneLiner()) return
holder.registerProblem(
property,
@@ -1,9 +0,0 @@
fun test() = 42
fun foo() {
when (val a =
test()) {
1 -> a
else -> 24
}
}
@@ -6885,14 +6885,9 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/inUnaryAndProperty.kt");
}
@TestMetadata("multiLinePropertywithSingleLineInitializer.kt")
public void testMultiLinePropertywithSingleLineInitializer() throws Exception {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLinePropertywithSingleLineInitializer.kt");
}
@TestMetadata("multiLinePropertywithSingleLineInitializer2.kt")
public void testMultiLinePropertywithSingleLineInitializer2() throws Exception {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLinePropertywithSingleLineInitializer2.kt");
@TestMetadata("multiLineWithOneLineInitializer.kt")
public void testMultiLineWithOneLineInitializer() throws Exception {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLineWithOneLineInitializer.kt");
}
@TestMetadata("notApplicableInBinaryExpression.kt")
@@ -6900,6 +6895,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableInBinaryExpression.kt");
}
@TestMetadata("notApplicableMultiLineWithOneLineInitializer.kt")
public void testNotApplicableMultiLineWithOneLineInitializer() throws Exception {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableMultiLineWithOneLineInitializer.kt");
}
@TestMetadata("notApplicableMultyLine.kt")
public void testNotApplicableMultyLine() throws Exception {
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableMultyLine.kt");