Fix completion of 'else' keyword

#KT-14665 fixed
This commit is contained in:
Simon Ogorodnik
2017-04-24 20:32:26 +03:00
parent bd2ad6a089
commit 6e8406f73c
4 changed files with 32 additions and 0 deletions
@@ -216,6 +216,10 @@ object KeywordCompletion {
}
}
if (prevLeaf?.getParentOfType<KtIfExpression>(strict = false) != null) {
prefixText += "if(true){}"
}
return buildFilterWithContext(prefixText, prevParent, position)
}
else {
@@ -0,0 +1,8 @@
fun foo(p: Int) {
var x = 0
if (p > 0)
x += p
el<caret>
}
//EXIST: else
@@ -0,0 +1,8 @@
fun foo(p: Int) {
if (p > 0) {
}
el<caret>
}
//EXIST: else
@@ -144,6 +144,18 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
doTest(fileName);
}
@TestMetadata("ElseAfterBlocklessIf.kt")
public void testElseAfterBlocklessIf() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/ElseAfterBlocklessIf.kt");
doTest(fileName);
}
@TestMetadata("ElseOnOtherLine.kt")
public void testElseOnOtherLine() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/ElseOnOtherLine.kt");
doTest(fileName);
}
@TestMetadata("FileKeyword.kt")
public void testFileKeyword() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/FileKeyword.kt");