Fix bug when chain is not detected if method expression is used

This commit is contained in:
Vitaliy.Bibaev
2017-12-25 18:21:12 +03:00
committed by Yan Zhulanow
parent da731b9bae
commit 7cd1baff9d
4 changed files with 17 additions and 0 deletions
@@ -55,11 +55,16 @@ abstract class KotlinChainBuilderBase(private val transformer: ChainTransformer<
private fun getLatestElementInScope(element: PsiElement?): PsiElement? {
var current = element
while (current != null) {
if (current is KtNamedFunction && current.hasInitializer()) {
break
}
val parent = current.parent
if (parent is KtBlockExpression || parent is KtLambdaExpression) {
break
}
current = parent
}
@@ -0,0 +1,5 @@
package location
import java.util.stream.Stream
<caret>fun method() = Stream.of(1, 2, 3).count()
@@ -0,0 +1,5 @@
package location
import java.util.stream.Stream
<caret>val property = Stream.of(1, 2, 3).findAny()
@@ -36,4 +36,6 @@ class LocationPositiveChainTest : PositiveJavaStreamTest("location") {
fun testInString() = doTest()
fun testInVariableName() = doTest()
fun testInMethodReference() = doTest()
fun testAsMethodExpression() = doTest()
}