Create From Usage: Do not suggest list of type candidates when there is at most one
This commit is contained in:
+15
-3
@@ -445,9 +445,21 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
|
|
||||||
private fun setupReturnTypeTemplate(builder: TemplateBuilder, declaration: JetCallableDeclaration): TypeExpression? {
|
private fun setupReturnTypeTemplate(builder: TemplateBuilder, declaration: JetCallableDeclaration): TypeExpression? {
|
||||||
val returnTypeRef = declaration.getReturnTypeRef() ?: return null
|
val returnTypeRef = declaration.getReturnTypeRef() ?: return null
|
||||||
val returnTypeExpression = TypeExpression(typeCandidates[config.callableInfo.returnTypeInfo]!!)
|
val candidates = typeCandidates[config.callableInfo.returnTypeInfo]!!
|
||||||
builder.replaceElement(returnTypeRef, returnTypeExpression)
|
return when (candidates.size) {
|
||||||
return returnTypeExpression
|
0 -> null
|
||||||
|
|
||||||
|
1 -> {
|
||||||
|
builder.replaceElement(returnTypeRef, candidates.first().renderedType!!)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
val returnTypeExpression = TypeExpression(candidates)
|
||||||
|
builder.replaceElement(returnTypeRef, returnTypeExpression)
|
||||||
|
returnTypeExpression
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupValVarTemplate(builder: TemplateBuilder, property: JetProperty) {
|
private fun setupValVarTemplate(builder: TemplateBuilder, property: JetProperty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user