diff --git a/plugins/kotlin/code-insight/utils/src/org/jetbrains/kotlin/idea/codeinsight/utils/elementRenderingUtils.kt b/plugins/kotlin/code-insight/utils/src/org/jetbrains/kotlin/idea/codeinsight/utils/elementRenderingUtils.kt index 94020722159c..7d22e6391d90 100644 --- a/plugins/kotlin/code-insight/utils/src/org/jetbrains/kotlin/idea/codeinsight/utils/elementRenderingUtils.kt +++ b/plugins/kotlin/code-insight/utils/src/org/jetbrains/kotlin/idea/codeinsight/utils/elementRenderingUtils.kt @@ -110,12 +110,22 @@ fun KtElement.renderTrimmed(): String { override fun visitCallExpression(expression: KtCallExpression) { expression.calleeExpression?.accept(this) + expression.typeArgumentList?.accept(this) expression.valueArgumentList?.accept(this) - repeat(expression.lambdaArguments.size) { builder.append("{...}") } + repeat(expression.lambdaArguments.size) { builder.append("{$ellipsis}") } } override fun visitValueArgumentList(list: KtValueArgumentList) { - builder.append(if (list.arguments.isEmpty()) "()" else "(...)") + val arguments = list.arguments + builder.append("(") + if (arguments.isNotEmpty()) { + if (arguments.size <= 3 && arguments.all { it.getArgumentExpression() is KtConstantExpression }) { + arguments.joinTo(builder) { it.text } + } else { + builder.append(ellipsis) + } + } + builder.append(")") } override fun visitQualifiedExpression(expression: KtQualifiedExpression) { @@ -171,7 +181,7 @@ fun KtElement.renderTrimmed(): String { if (expression.parent is KtFunctionLiteral) { super.visitBlockExpression(expression) } else { - builder.append("{...}") + builder.append("{$ellipsis}") } } @@ -196,7 +206,7 @@ fun KtElement.renderTrimmed(): String { it.accept(this) builder.append(')') } - builder.append(" {...}") + builder.append(" {$ellipsis}") } override fun visitForExpression(expression: KtForExpression) { @@ -233,7 +243,7 @@ fun KtElement.renderTrimmed(): String { } override fun visitTryExpression(expression: KtTryExpression) { - builder.append("try {...}") + builder.append("try {$ellipsis}") } // Declarations @@ -277,7 +287,7 @@ fun KtElement.renderTrimmed(): String { classOrObject.name?.let { builder.append(" $it") } classOrObject.getSuperTypeList()?.accept(this) - classOrObject.body?.let { builder.append(" {...}") } + classOrObject.body?.let { builder.append(" {$ellipsis}") } } override fun visitSuperTypeList(list: KtSuperTypeList) { @@ -315,11 +325,13 @@ fun KtElement.renderTrimmed(): String { return Renderer().render(this) } +internal const val ellipsis = "${Typography.ellipsis}" + @NlsSafe -fun getExpressionShortText(element: KtElement): String { - val text = element.renderTrimmed().trimStart() +fun getExpressionShortText(element: PsiElement): String { + val text = ((element as? KtElement)?.renderTrimmed() ?: element.text).trimStart() val firstNewLinePos = text.indexOf('\n') var trimmedText = text.substring(0, if (firstNewLinePos != -1) firstNewLinePos else min(100, text.length)) - if (trimmedText.length != text.length) trimmedText += " ..." + if (trimmedText.length != text.length) trimmedText += " $ellipsis" return trimmedText } \ No newline at end of file diff --git a/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/CastExpressionFixFactories.kt b/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/CastExpressionFixFactories.kt index 73b75a4e54eb..affe013d5167 100644 --- a/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/CastExpressionFixFactories.kt +++ b/plugins/kotlin/fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/CastExpressionFixFactories.kt @@ -8,10 +8,11 @@ import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KtTypeRendererForSo import org.jetbrains.kotlin.analysis.api.types.KtErrorType import org.jetbrains.kotlin.analysis.api.types.KtType import org.jetbrains.kotlin.idea.base.analysis.api.utils.shortenReferences -import org.jetbrains.kotlin.idea.base.resources.KotlinBundle import org.jetbrains.kotlin.idea.base.psi.replaced +import org.jetbrains.kotlin.idea.base.resources.KotlinBundle import org.jetbrains.kotlin.idea.codeinsight.api.applicators.* import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.* +import org.jetbrains.kotlin.idea.codeinsight.utils.getExpressionShortText import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.KtPsiFactory @@ -24,7 +25,7 @@ object CastExpressionFixFactories { private val applicator: KotlinModCommandApplicator = modCommandApplicator { familyName(KotlinBundle.lazyMessage("fix.cast.expression.family")) - actionName { psi, input -> KotlinBundle.message("fix.cast.expression.text", psi.text, input.typePresentation) } + actionName { psi, input -> KotlinBundle.message("fix.cast.expression.text", getExpressionShortText(psi), input.typePresentation) } applyTo { psi, input, context, updater -> val expressionToInsert = KtPsiFactory(context.project).createExpressionByPattern("$0 as $1", psi, input.typeSourceCode) val newExpression = psi.replaced(expressionToInsert) diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/accessibilityChecker/classSecondaryConstructor/log.log b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/accessibilityChecker/classSecondaryConstructor/log.log index 1f8ee25deeb8..774387dbb401 100644 --- a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/accessibilityChecker/classSecondaryConstructor/log.log +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/accessibilityChecker/classSecondaryConstructor/log.log @@ -1,3 +1,3 @@ These declarations cannot be transformed: actual val a: Some -constructor(a: Some, b: Int){...} +constructor(a: Some, b: Int){…} diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt index 73ec03f2b2e2..c0e8c7d296c3 100644 --- a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt @@ -1,5 +1,5 @@ // "Add missing actual members" "true" -// SHOULD_FAIL_WITH: Some types are not accessible:,class M {...} -> Type <Unknown> is not accessible from target module +// SHOULD_FAIL_WITH: Some types are not accessible:,class M {…} -> Type <Unknown> is not accessible from target module // DISABLE-ERRORS // IGNORE_K2 diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt.after b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt.after index dcf403631df8..d07702d58cfa 100644 --- a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt.after +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/addMissingActualMembers/membersWithIncorrectType/jvm/F.kt.after @@ -1,5 +1,5 @@ // "Add missing actual members" "true" -// SHOULD_FAIL_WITH: Some types are not accessible:,class M {...} -> Type <Unknown> is not accessible from target module +// SHOULD_FAIL_WITH: Some types are not accessible:,class M {…} -> Type <Unknown> is not accessible from target module // DISABLE-ERRORS // IGNORE_K2 diff --git a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/createExpect/withAnnotations/log.log b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/createExpect/withAnnotations/log.log index f0ee851a4816..095562a89c96 100644 --- a/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/createExpect/withAnnotations/log.log +++ b/plugins/kotlin/idea/tests/testData/multiModuleQuickFix/createExpect/withAnnotations/log.log @@ -1,3 +1,3 @@ These declarations cannot be transformed: -fun foo(arg: Int){...} +fun foo(arg: Int){…} actual lateinit var some: Boolean diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis.kt b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis.kt index ef600281feec..df15b4c6ce0f 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis.kt @@ -6,5 +6,5 @@ fun main() { fun foo(a: Int): Int = 5 /* -foo(...) +foo(…) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis2.kt b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis2.kt index f83ecb93e409..d5ec7a1be684 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis2.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis2.kt @@ -7,5 +7,5 @@ fun foo(a: Int): Int = 5 fun boo(a: Int): Int = 5 /* -boo(...) +boo(…) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis3.kt b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis3.kt index 8e452790ff09..7adb55527cf3 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis3.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/afterRightParenthesis3.kt @@ -7,6 +7,6 @@ fun foo(a: Int): Int = 5 fun boo(a: Int): Int = 5 /* -foo(...) -boo(...) +foo(…) +boo(…) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/lambdaCalls.kt b/plugins/kotlin/idea/tests/testData/smartSelection/lambdaCalls.kt index 4793432ab385..8566bc426aa6 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/lambdaCalls.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/lambdaCalls.kt @@ -11,7 +11,7 @@ fun foo(t: T) { /* 1 { 1 } -t.foo{...} -t.foo{...}.foo{...} -t.foo{...}.foo{...}.foo(...) +t.foo{…} +t.foo{…}.foo{…} +t.foo{…}.foo{…}.foo(…) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/multilineCalls.kt b/plugins/kotlin/idea/tests/testData/smartSelection/multilineCalls.kt index 6a4220f0f9fd..517196caa2e7 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/multilineCalls.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/multilineCalls.kt @@ -12,7 +12,7 @@ fun foo(t: T) { /* 2 -t.foo(...) -t.foo(...).foo() -t.foo(...).foo().foo(...) +t.foo(…) +t.foo(…).foo() +t.foo(…).foo().foo(4) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/objectLiteral.kt b/plugins/kotlin/idea/tests/testData/smartSelection/objectLiteral.kt index fdda337c9e63..f3bb46ffb24d 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/objectLiteral.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/objectLiteral.kt @@ -11,6 +11,6 @@ fun foo() { } /* -object : T {...} -object : T {...}.foo(...) +object : T {…} +object : T {…}.foo(…) */ \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/simple.kt b/plugins/kotlin/idea/tests/testData/smartSelection/simple.kt index e70d5d0c0d14..48f25b35d9bc 100644 --- a/plugins/kotlin/idea/tests/testData/smartSelection/simple.kt +++ b/plugins/kotlin/idea/tests/testData/smartSelection/simple.kt @@ -4,5 +4,5 @@ fun main(args: Array) { /* 1.0 1.0 + 1 -Math.pow(...) +Math.pow(…) */