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
}