KT-4913 Smart completion should work after '!'

#KT-4913 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-07-23 14:58:15 +02:00
parent 19999e6879
commit 32dbed602a
3 changed files with 19 additions and 0 deletions
@@ -56,6 +56,7 @@ import org.jetbrains.jet.lang.psi.JetCallElement
import org.jetbrains.jet.lang.types.TypeUtils
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
import org.jetbrains.jet.lang.psi.JetPrefixExpression
enum class Tail {
COMMA
@@ -74,6 +75,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
?: calculateForElvis(expressionWithType)
?: calculateForBlockExpression(expressionWithType)
?: calculateForWhenEntryValue(expressionWithType)
?: calculateForExclOperand(expressionWithType)
?: getFromBindingContext(expressionWithType)
}
@@ -242,6 +244,12 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
}
}
private fun calculateForExclOperand(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
val prefixExpression = expressionWithType.getParent() as? JetPrefixExpression ?: return null
if (prefixExpression.getOperationToken() != JetTokens.EXCL) return null
return listOf(ExpectedInfo(KotlinBuiltIns.getInstance().getBooleanType(), null))
}
private fun getFromBindingContext(expressionWithType: JetExpression): Collection<ExpectedInfo>? {
val expectedType = bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, expressionWithType] ?: return null
return listOf(ExpectedInfo(expectedType, null))
@@ -0,0 +1,6 @@
fun foo(p1: Boolean, p2: String) {
if (!<caret>)
}
// EXIST: p1
// ABSENT: p2
@@ -32,6 +32,11 @@ import org.jetbrains.jet.completion.AbstractJvmSmartCompletionTest;
@SuppressWarnings("all")
@TestMetadata("idea/testData/completion/smart")
public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionTest {
@TestMetadata("AfterExclSign.kt")
public void testAfterExclSign() throws Exception {
doTest("idea/testData/completion/smart/AfterExclSign.kt");
}
public void testAllFilesPresentInSmart() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/completion/smart"), Pattern.compile("^(.+)\\.kt$"), true);
}