Don't report when property is multi-line and action is MOVE
This commit is contained in:
committed by
Dmitry Gridin
parent
4569b85a16
commit
5c011bc954
+1
@@ -41,6 +41,7 @@ class MoveVariableDeclarationIntoWhenInspection : AbstractKotlinInspection(), Cl
|
|||||||
|
|
||||||
val action = property.action(expression)
|
val action = property.action(expression)
|
||||||
if (action == Action.NOTHING) return
|
if (action == Action.NOTHING) return
|
||||||
|
if (action == Action.MOVE && !property.isOneLiner()) return
|
||||||
|
|
||||||
holder.registerProblem(
|
holder.registerProblem(
|
||||||
property,
|
property,
|
||||||
|
|||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
fun test() = 42
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
when (val a =
|
|
||||||
test()) {
|
|
||||||
1 -> a
|
|
||||||
else -> 24
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// PROBLEM: none
|
||||||
fun test() = 42
|
fun test() = 42
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
+8
-8
@@ -6885,14 +6885,9 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/inUnaryAndProperty.kt");
|
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/inUnaryAndProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("multiLinePropertywithSingleLineInitializer.kt")
|
@TestMetadata("multiLineWithOneLineInitializer.kt")
|
||||||
public void testMultiLinePropertywithSingleLineInitializer() throws Exception {
|
public void testMultiLineWithOneLineInitializer() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLinePropertywithSingleLineInitializer.kt");
|
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLineWithOneLineInitializer.kt");
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("multiLinePropertywithSingleLineInitializer2.kt")
|
|
||||||
public void testMultiLinePropertywithSingleLineInitializer2() throws Exception {
|
|
||||||
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/multiLinePropertywithSingleLineInitializer2.kt");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("notApplicableInBinaryExpression.kt")
|
@TestMetadata("notApplicableInBinaryExpression.kt")
|
||||||
@@ -6900,6 +6895,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableInBinaryExpression.kt");
|
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")
|
@TestMetadata("notApplicableMultyLine.kt")
|
||||||
public void testNotApplicableMultyLine() throws Exception {
|
public void testNotApplicableMultyLine() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableMultyLine.kt");
|
runTest("idea/testData/inspectionsLocal/moveVariableDeclarationIntoWhen/notApplicableMultyLine.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user