Introduce "Function with = { ... }" inspection
#KT-17119 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
301b3aad06
commit
538a746df9
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify explicit lambda signature
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify explicit lambda signature
|
||||
fun test(a: Int, b: Int) = { -> a + b }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify explicit lambda signature
|
||||
val test get() = <caret>{ "" }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify explicit lambda signature
|
||||
val test get() = { -> "" }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun test(a: Int, b: Int) = <caret>{ -> a + b }
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// PROBLEM: none
|
||||
fun test(a: Int, b: Int) = label@<caret>{
|
||||
return@label
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun test(a: Int, b: Int) <caret>{ { a + b } }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun test(a: Int, b: Int) = <caret>a + b
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
fun test(a: Int, b: Int): () -> Int = <caret>{ a + b }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
val test get() = <caret>{ -> "" }
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: none
|
||||
val test
|
||||
get() = label@<caret>{
|
||||
return@label
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
val test get() = <caret>""
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
val test: () -> String get() = <caret>{ "" }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// PROBLEM: none
|
||||
val test get(): () -> String = <caret>{ "" }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Remove braces
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Remove braces
|
||||
fun test(a: Int, b: Int) = a + b
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Remove braces
|
||||
// WITH_RUNTIME
|
||||
fun test() = <caret>{ error("") }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Remove braces
|
||||
// WITH_RUNTIME
|
||||
fun test(): Nothing = error("")
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Remove braces
|
||||
val test get() = <caret>{ "" }
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Remove braces
|
||||
val test get() = ""
|
||||
idea/testData/inspectionsLocal/functionWithLambdaExpressionBody/removeBraces/getterReturnsNothing.kt
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Remove braces
|
||||
// WITH_RUNTIME
|
||||
val test get() = <caret>{ error("") }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Remove braces
|
||||
// WITH_RUNTIME
|
||||
val test: Nothing get() = error("")
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify return type explicitly
|
||||
fun test(a: Int, b: Int): () -> Int = { a + b }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify type explicitly
|
||||
val test get() = <caret>{ "" }
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// FIX: Specify type explicitly
|
||||
val test: () -> String get() = { "" }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
fun test(a: Int, b: Int) = run { a + b }
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
fun test() = <caret>{ error("") }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
fun test(): Nothing = run { error("") }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
val test get() = <caret>{ "" }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
val test get() = run { "" }
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
val test get() = <caret>{ error("") }
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// FIX: Convert to run { ... }
|
||||
// WITH_RUNTIME
|
||||
val test: Nothing get() = run { error("") }
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{
|
||||
// comment
|
||||
""
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{
|
||||
foo()
|
||||
foo()
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
|
||||
val foo = test(1, 2)()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert property getter to initializer
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify type explicitly
|
||||
// ACTION: Specify type explicitly
|
||||
val test get() = <caret>{
|
||||
// comment
|
||||
""
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert property getter to initializer
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify type explicitly
|
||||
// ACTION: Specify type explicitly
|
||||
val test get() = <caret>{
|
||||
foo()
|
||||
foo()
|
||||
}
|
||||
|
||||
fun foo() {}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert property getter to initializer
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Convert to run { ... }
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify type explicitly
|
||||
// ACTION: Specify type explicitly
|
||||
val test get() = <caret>{}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Remove braces" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert property getter to initializer
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify type explicitly
|
||||
// ACTION: Specify type explicitly
|
||||
val test get() = <caret>{ "" }
|
||||
|
||||
fun foo() {
|
||||
test()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Convert to run { ... }" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify return type explicitly
|
||||
fun test(a: Int, b: Int) = <caret>{ a + b }
|
||||
|
||||
val foo = test(1, 2)()
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Convert to run { ... }" "false"
|
||||
// TOOL: org.jetbrains.kotlin.idea.inspections.FunctionWithLambdaExpressionBodyInspection
|
||||
// ACTION: Convert property getter to initializer
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify explicit lambda signature
|
||||
// ACTION: Specify type explicitly
|
||||
// ACTION: Specify type explicitly
|
||||
val test get() = <caret>{ "" }
|
||||
|
||||
fun foo() {
|
||||
test()
|
||||
}
|
||||
Reference in New Issue
Block a user