Fix keyword completion in 'if' blocks

#KT-17914 fixed
This commit is contained in:
fitermay
2017-05-18 01:52:22 -04:00
committed by Simon Ogorodnik
parent 75b73ecbcb
commit d0991fffd2
5 changed files with 122 additions and 1 deletions
@@ -217,7 +217,7 @@ object KeywordCompletion {
}
if (prevLeaf?.getParentOfType<KtIfExpression>(strict = false) != null) {
prefixText += "if(true){}"
prefixText += "if(true){}\n"
}
return buildFilterWithContext(prefixText, prevParent, position)
+35
View File
@@ -0,0 +1,35 @@
fun some() {
if (true) {
} else {
}
<caret>
}
// EXIST: do
// EXIST: as
// EXIST: class
// EXIST: else
// EXIST: false
// EXIST: for
// EXIST: fun
// EXIST: if
// EXIST: interface
// EXIST: null
// EXIST: object
// EXIST: return
// EXIST: super
// EXIST: throw
// EXIST: true
// EXIST: try
// EXIST: typealias
// EXIST: val
// EXIST: var
// EXIST: when
// EXIST: while
// NOTHING_ELSE
+34
View File
@@ -0,0 +1,34 @@
fun some() {
if (true) {
} else {
<caret>
}
}
// EXIST: do
// EXIST: as
// EXIST: class
// EXIST: else
// EXIST: false
// EXIST: for
// EXIST: fun
// EXIST: if
// EXIST: interface
// EXIST: null
// EXIST: object
// EXIST: return
// EXIST: super
// EXIST: throw
// EXIST: true
// EXIST: try
// EXIST: typealias
// EXIST: val
// EXIST: var
// EXIST: when
// EXIST: while
// NOTHING_ELSE
+34
View File
@@ -0,0 +1,34 @@
fun some() {
if (true) {
<caret>
} else {
}
}
// EXIST: do
// EXIST: as
// EXIST: class
// EXIST: else
// EXIST: false
// EXIST: for
// EXIST: fun
// EXIST: if
// EXIST: interface
// EXIST: null
// EXIST: object
// EXIST: return
// EXIST: super
// EXIST: throw
// EXIST: true
// EXIST: try
// EXIST: typealias
// EXIST: val
// EXIST: var
// EXIST: when
// EXIST: while
// NOTHING_ELSE
@@ -62,6 +62,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
doTest(fileName);
}
@TestMetadata("AfterIf.kt")
public void testAfterIf() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/AfterIf.kt");
doTest(fileName);
}
@TestMetadata("AfterSafeDot.kt")
public void testAfterSafeDot() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/AfterSafeDot.kt");
@@ -228,6 +234,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
doTest(fileName);
}
@TestMetadata("InElse.kt")
public void testInElse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InElse.kt");
doTest(fileName);
}
@TestMetadata("InEnumScope1.kt")
public void testInEnumScope1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InEnumScope1.kt");
@@ -270,6 +282,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
doTest(fileName);
}
@TestMetadata("InIf.kt")
public void testInIf() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InIf.kt");
doTest(fileName);
}
@TestMetadata("InInterfaceScope.kt")
public void testInInterfaceScope() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InInterfaceScope.kt");