Fix NoSuchElementException editing script file

^KT-30440 Fixed
This commit is contained in:
Natalia Selezneva
2019-03-26 12:03:26 +03:00
parent 224f37ca00
commit 776a89086f
3 changed files with 14 additions and 1 deletions
@@ -152,7 +152,8 @@ class KotlinCodeBlockModificationListener(
is KtScriptInitializer -> {
return (blockDeclaration.body as? KtCallExpression)
?.lambdaArguments?.last()
?.lambdaArguments
?.lastOrNull()
?.getLambdaExpression()
?.takeIf { it.isAncestor(element) }
}
@@ -0,0 +1,7 @@
// TRUE
fun foo() = 1
foo(<caret>)
// SKIP_ANALYZE_CHECK
@@ -224,6 +224,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("idea/testData/codeInsight/outOfBlock/scriptInLambdaExpression.kts");
}
@TestMetadata("scriptTopLevelCallExpression.kts")
public void testScriptTopLevelCallExpression() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/scriptTopLevelCallExpression.kts");
}
@TestMetadata("scriptTopLevelExpression.kts")
public void testScriptTopLevelExpression() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/scriptTopLevelExpression.kts");