Fix bug when chain is not detected if method expression is used
This commit is contained in:
committed by
Yan Zhulanow
parent
da731b9bae
commit
7cd1baff9d
+5
@@ -55,11 +55,16 @@ abstract class KotlinChainBuilderBase(private val transformer: ChainTransformer<
|
|||||||
private fun getLatestElementInScope(element: PsiElement?): PsiElement? {
|
private fun getLatestElementInScope(element: PsiElement?): PsiElement? {
|
||||||
var current = element
|
var current = element
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
|
if (current is KtNamedFunction && current.hasInitializer()) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
val parent = current.parent
|
val parent = current.parent
|
||||||
if (parent is KtBlockExpression || parent is KtLambdaExpression) {
|
if (parent is KtBlockExpression || parent is KtLambdaExpression) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
current = parent
|
current = parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -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 testInString() = doTest()
|
||||||
fun testInVariableName() = doTest()
|
fun testInVariableName() = doTest()
|
||||||
fun testInMethodReference() = doTest()
|
fun testInMethodReference() = doTest()
|
||||||
|
|
||||||
|
fun testAsMethodExpression() = doTest()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user