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))