Fix completion of 'else' keyword
#KT-14665 fixed
This commit is contained in:
@@ -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
|
||||
+12
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user