diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt index 58f8869ece8..a22b886f812 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InsertExplicitTypeArgumentsIntention.kt @@ -20,8 +20,8 @@ import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.core.ShortenReferences +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.KtCallElement import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtPsiFactory @@ -31,16 +31,17 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.ErrorUtils -class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention(KtCallExpression::class.java, "Add explicit type arguments"), LowPriorityAction { +class InsertExplicitTypeArgumentsIntention : + SelfTargetingRangeIntention(KtCallExpression::class.java, "Add explicit type arguments"), LowPriorityAction { override fun applicabilityRange(element: KtCallExpression): TextRange? { - return if (isApplicableTo(element, element.analyze())) element.calleeExpression!!.textRange else null + return if (isApplicableTo(element, element.analyze())) element.calleeExpression?.textRange else null } override fun applyTo(element: KtCallExpression, editor: Editor?) = applyTo(element) companion object { fun isApplicableTo(element: KtCallElement, bindingContext: BindingContext = element.analyze(BodyResolveMode.PARTIAL)): Boolean { - if (!element.typeArguments.isEmpty()) return false + if (element.typeArguments.isNotEmpty()) return false if (element.calleeExpression == null) return false val resolvedCall = element.getResolvedCall(bindingContext) ?: return false @@ -49,9 +50,9 @@ class InsertExplicitTypeArgumentsIntention : SelfTargetingRangeIntention") { IdeDescriptorRenderers.SOURCE_CODE.renderType(args[it]!!) } + val text = types.joinToString(", ", "<", ">") { + IdeDescriptorRenderers.SOURCE_CODE.renderType(args.getValue(it)) + } return KtPsiFactory(element).createTypeArguments(text) }