KT-9664 Add quickfix to convert a piece of code to pretty look SAM-style
#KT-9664 Fixed
This commit is contained in:
+33
-17
@@ -3,7 +3,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>9</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -11,7 +11,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>11</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WEAK_WARNING">Redundant SAM-constructors</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -19,7 +19,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>22</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -27,7 +27,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>25</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -35,7 +35,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>27</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -43,7 +43,7 @@
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>38</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructor.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -51,7 +51,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>9</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -59,7 +59,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>11</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WEAK_WARNING">Redundant SAM-constructors</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -67,7 +67,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>15</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -75,7 +75,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>18</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -83,7 +83,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>20</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -91,7 +91,7 @@
|
||||
<file>redundantSamConstructorWithGenericsInReturnType.kt</file>
|
||||
<line>24</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructorWithGenericsInReturnType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -99,7 +99,7 @@
|
||||
<file>otherGenericsInParams.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/otherGenericsInParams.kt" />
|
||||
<entry_point TYPE="file" FQNAME="otherGenericsInParams.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -107,7 +107,7 @@
|
||||
<file>otherGenericsInParams.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/otherGenericsInParams.kt" />
|
||||
<entry_point TYPE="file" FQNAME="otherGenericsInParams.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -115,7 +115,7 @@
|
||||
<file>otherGenericsInParams.kt</file>
|
||||
<line>11</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/otherGenericsInParams.kt" />
|
||||
<entry_point TYPE="file" FQNAME="otherGenericsInParams.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM-constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -123,7 +123,7 @@
|
||||
<file>expectedType.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/expectedType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="expectedType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
@@ -131,7 +131,23 @@
|
||||
<file>expectedType.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/expectedType.kt" />
|
||||
<entry_point TYPE="file" FQNAME="expectedType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>41</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>redundantSamConstructor.kt</file>
|
||||
<line>42</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="redundantSamConstructor.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Redundant SAM constructor</problem_class>
|
||||
<description>Redundant SAM-constructor</description>
|
||||
</problem>
|
||||
|
||||
Vendored
+3
@@ -37,4 +37,7 @@ fun test() {
|
||||
|
||||
klass.memberFunWithOtherParam(1, { })
|
||||
klass.memberFunWithOtherParam(1, runnable)
|
||||
|
||||
MyJavaClass.staticFunWithOtherParam(1, { })
|
||||
klass.memberFun1({ })
|
||||
}
|
||||
@@ -37,4 +37,7 @@ fun test() {
|
||||
|
||||
klass.memberFunWithOtherParam(1, Runnable { })
|
||||
klass.memberFunWithOtherParam(1, runnable)
|
||||
|
||||
MyJavaClass.staticFunWithOtherParam(1, java.lang.Runnable { })
|
||||
klass.memberFun1(java.lang.Runnable { })
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ObjectLiteralToLambdaIntention
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : Runnable {
|
||||
override fun run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(Runnable { })
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FileFilter {
|
||||
override fun accept(file: File) = file.name.startsWith("a")
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FileFilter { file -> file.name.startsWith("a") })
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : Runnable {
|
||||
val v = "a".hashCode()
|
||||
|
||||
override fun run() {
|
||||
print(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface I
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : Runnable, I {
|
||||
override fun run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FilenameFilter {
|
||||
override fun accept(file: File, name: String) = name == "x"
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FilenameFilter { file, name -> name == "x" })
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
fun bar() {
|
||||
SwingUtilities.invokeLater(<caret>object: Runnable {
|
||||
override fun run() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
fun bar() {
|
||||
SwingUtilities.invokeLater({ throw UnsupportedOperationException() })
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(object : Runnable <caret>{
|
||||
override fun run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo<caret>(object : Runnable {
|
||||
override fun run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
interface MyRunnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
fun foo(runnable: MyRunnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : MyRunnable {
|
||||
override fun run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FilenameFilter {
|
||||
override fun accept(file: File, name: String) = true
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FilenameFilter { true })
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar(list: List<String>) {
|
||||
foo(<caret>object : Runnable {
|
||||
override fun run() {
|
||||
list.filter(fun (element: String): Boolean {
|
||||
if (element == "a") return false
|
||||
if (element == "b") return@run
|
||||
return true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar(list: List<String>) {
|
||||
foo(Runnable {
|
||||
list.filter(fun (element: String): Boolean {
|
||||
if (element == "a") return false
|
||||
if (element == "b") return@Runnable
|
||||
return true
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar(p: Int) {
|
||||
foo(<caret>object : Runnable {
|
||||
override fun run() {
|
||||
if (p < 0) return
|
||||
println("a")
|
||||
println("b")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar(p: Int) {
|
||||
foo(Runnable {
|
||||
if (p < 0) return@Runnable
|
||||
println("a")
|
||||
println("b")
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FilenameFilter {
|
||||
override fun accept(file: File, name: String): Boolean {
|
||||
if (file.isDirectory) return true
|
||||
return name == "x"
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FilenameFilter
|
||||
|
||||
fun foo(filter: FilenameFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FilenameFilter { file, name ->
|
||||
if (file.isDirectory) return@FilenameFilter true
|
||||
name == "x"
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FileFilter {
|
||||
override fun accept(file: File): Boolean {
|
||||
val name = file.name
|
||||
if (name.startsWith("a")) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
if (name.endsWith("b"))
|
||||
return true
|
||||
else {
|
||||
val l = name.length
|
||||
return l > 10
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FileFilter { file ->
|
||||
val name = file.name
|
||||
if (name.startsWith("a")) {
|
||||
false
|
||||
}
|
||||
else {
|
||||
if (name.endsWith("b"))
|
||||
true
|
||||
else {
|
||||
val l = name.length
|
||||
l > 10
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FileFilter {
|
||||
override fun accept(file: File): Boolean {
|
||||
val name = file.name
|
||||
when (name) {
|
||||
"foo" -> return true
|
||||
|
||||
"bar" -> return false
|
||||
|
||||
else -> {
|
||||
if (name.startsWith("a")) return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FileFilter { file ->
|
||||
val name = file.name
|
||||
when (name) {
|
||||
"foo" -> true
|
||||
|
||||
"bar" -> false
|
||||
|
||||
else -> {
|
||||
if (name.startsWith("a")) return@FileFilter true
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : Runnable {
|
||||
override fun run() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(Runnable { throw UnsupportedOperationException() })
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FileFilter {
|
||||
override fun accept(file: File): Boolean {
|
||||
return file.name.startsWith("a")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FileFilter { file -> file.name.startsWith("a") })
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object: FileFilter {
|
||||
override fun accept(file: File): Boolean {
|
||||
val name = file.name
|
||||
return name.startsWith("a")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
fun foo(filter: FileFilter) {}
|
||||
|
||||
fun bar() {
|
||||
foo(FileFilter { file ->
|
||||
val name = file.name
|
||||
name.startsWith("a")
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(runnable: Runnable) {}
|
||||
|
||||
fun bar() {
|
||||
foo(<caret>object : Runnable {
|
||||
override fun run() {
|
||||
f()
|
||||
}
|
||||
|
||||
fun f() {}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>StatementAndReturn.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="StatementAndReturn.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>SingleReturn.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="SingleReturn.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Simple.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="Simple.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ReturnNoValue.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ReturnNoValue.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ReturnNotLast.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ReturnNotLast.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ParametersNotUsed.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ParametersNotUsed.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NoSamAdapterNeeded.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NoSamAdapterNeeded.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>MultipleParameters.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="MultipleParameters.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ExpressionBody.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ExpressionBody.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>EmptyBody.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="EmptyBody.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ReturnsInWhen.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ReturnsInWhen.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ReturnsInIf.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ReturnsInIf.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NotInRange2.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NotInRange2.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NotInRange1.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NotInRange1.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>QualifiedReturn.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="QualifiedReturn.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.ObjectLiteralToLambdaInspection
|
||||
Reference in New Issue
Block a user