diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt index 5387623a7da..8719d258ef1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt @@ -23,10 +23,15 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.renderer.DescriptorRenderer +import org.jetbrains.kotlin.renderer.RenderingFormat import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getType class KotlinExpressionTypeProvider : ExpressionTypeProvider() { + private val typeRenderer = DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.withOptions { + textFormat = RenderingFormat.HTML + } + override fun getExpressionsAt(elementAt: PsiElement): List = elementAt.parentsWithSelf.filterIsInstance().filter { it.shouldShowType() }.toList() @@ -47,12 +52,12 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider() { if (element is KtCallableDeclaration) { val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, element] as? CallableDescriptor if (descriptor != null) { - return descriptor.returnType?.let { DescriptorRenderer.HTML.renderType(it) } ?: "Type is unknown" + return descriptor.returnType?.let { typeRenderer.renderType(it) } ?: "Type is unknown" } } val expressionType = element.getType(bindingContext) ?: return "Type is unknown" - val result = DescriptorRenderer.HTML.renderType(expressionType) + val result = typeRenderer.renderType(expressionType) val smartCast = bindingContext[BindingContext.SMARTCAST, element] if (smartCast != null) { return result + " (smart cast)" diff --git a/idea/testData/codeInsight/expressionType/BlockBodyFunction.kt b/idea/testData/codeInsight/expressionType/BlockBodyFunction.kt index f353751faef..dec6f67eee5 100644 --- a/idea/testData/codeInsight/expressionType/BlockBodyFunction.kt +++ b/idea/testData/codeInsight/expressionType/BlockBodyFunction.kt @@ -2,4 +2,4 @@ fun foo() { val x = 1 } -// TYPE: val x = 1 -> kotlin.Int +// TYPE: val x = 1 -> Int diff --git a/idea/testData/codeInsight/expressionType/MultiDeclaration.kt b/idea/testData/codeInsight/expressionType/MultiDeclaration.kt index d6d61cfdac7..361e6d6856f 100644 --- a/idea/testData/codeInsight/expressionType/MultiDeclaration.kt +++ b/idea/testData/codeInsight/expressionType/MultiDeclaration.kt @@ -4,4 +4,4 @@ fun f(x: IntStringPair) { val (first, second) = x } -// TYPE: first -> kotlin.Int +// TYPE: first -> Int diff --git a/idea/testData/codeInsight/expressionType/SmartCast.kt b/idea/testData/codeInsight/expressionType/SmartCast.kt index 6f5404f67b4..cb8069c6ec1 100644 --- a/idea/testData/codeInsight/expressionType/SmartCast.kt +++ b/idea/testData/codeInsight/expressionType/SmartCast.kt @@ -4,6 +4,6 @@ fun foo(x: Any) { } } -// TYPE: if (x is String) { x.length } -> kotlin.Unit -// TYPE: x -> kotlin.String (smart cast) -// TYPE: x.length -> kotlin.Int +// TYPE: if (x is String) { x.length } -> Unit +// TYPE: x -> String (smart cast) +// TYPE: x.length -> Int diff --git a/idea/testData/codeInsight/expressionType/VariableDeclaration.kt b/idea/testData/codeInsight/expressionType/VariableDeclaration.kt index 5172daedd64..717d58eb307 100644 --- a/idea/testData/codeInsight/expressionType/VariableDeclaration.kt +++ b/idea/testData/codeInsight/expressionType/VariableDeclaration.kt @@ -1,3 +1,3 @@ val x = 1 -// TYPE: val x = 1 -> kotlin.Int +// TYPE: val x = 1 -> Int