Lambda to callable reference: inspection is optional depending on text length

(cherry picked from commit ce0c43c)
This commit is contained in:
Mikhail Glukhikh
2016-07-15 19:56:12 +03:00
committed by Mikhail Glukhikh
parent 220141ab2b
commit a3b52fd8a6
5 changed files with 39 additions and 2 deletions
@@ -0,0 +1,10 @@
<problems>
<problem>
<file>test.kt</file>
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with function reference</problem_class>
<description>Convert lambda to reference</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.ConvertLambdaToReferenceInspection
@@ -0,0 +1,9 @@
// Mostly tested as intention. Here we just test shouldSuggestToConvert()
// Should suggest to convert
class TheirWrapper(val x: Int)
val x = { y: Int -> TheirWrapper(y) }
// Should not suggest to convert (too long reference)
fun foo(arg: TheirWrapper, convert: (TheirWrapper) -> String) = convert(arg)
val y = foo(TheirWrapper(42)) { it.toString() }