diff --git a/plugins/kotlin/code-insight/kotlin.code-insight.k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/quickDoc/KotlinIdeDeclarationRenderer.kt b/plugins/kotlin/code-insight/kotlin.code-insight.k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/quickDoc/KotlinIdeDeclarationRenderer.kt index 6cfd37c598a9..13d5d63cd4e5 100644 --- a/plugins/kotlin/code-insight/kotlin.code-insight.k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/quickDoc/KotlinIdeDeclarationRenderer.kt +++ b/plugins/kotlin/code-insight/kotlin.code-insight.k2/src/org/jetbrains/kotlin/idea/k2/codeinsight/quickDoc/KotlinIdeDeclarationRenderer.kt @@ -486,7 +486,14 @@ internal class KotlinIdeDeclarationRenderer( return object : KtDeclarationNameRenderer { context(KtAnalysisSession, KtDeclarationRenderer) override fun renderName(name: Name, symbol: KtNamedSymbol?, printer: PrettyPrinter) { - if (symbol is KtClassOrObjectSymbol && symbol.classKind == KtClassKind.COMPANION_OBJECT && symbol.name == SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT) return + if (symbol is KtClassOrObjectSymbol && symbol.classKind == KtClassKind.COMPANION_OBJECT && symbol.name == SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT) { + val className = (symbol.getContainingSymbol() as? KtClassOrObjectSymbol)?.name + if (className != null) { + printer.append(highlight("of ") { asInfo } ) + printer.append(highlight(className.renderName()) { asClassName } ) + } + return + } if (symbol is KtEnumEntrySymbol) { printer.append(highlight("enum entry") { asKeyword }) printer.append(" ") diff --git a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocTestGenerated.java b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocTestGenerated.java index c6527cf996b4..b750399a28c0 100644 --- a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocTestGenerated.java +++ b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/documentation/FirQuickDocTestGenerated.java @@ -198,6 +198,11 @@ public class FirQuickDocTestGenerated extends AbstractFirQuickDocTest { runTest("../../idea/tests/testData/editor/quickDoc/OnClassDeclarationWithNoPackage.kt"); } + @TestMetadata("OnCompanionObject.kt") + public void testOnCompanionObject() throws Exception { + runTest("../../idea/tests/testData/editor/quickDoc/OnCompanionObject.kt"); + } + @TestMetadata("OnEmptySecondaryConstructor.kt") public void testOnEmptySecondaryConstructor() throws Exception { runTest("../../idea/tests/testData/editor/quickDoc/OnEmptySecondaryConstructor.kt"); diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocProviderTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocProviderTestGenerated.java index 8ac2ed5d3666..dba9839583b2 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocProviderTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/editor/quickDoc/QuickDocProviderTestGenerated.java @@ -198,6 +198,11 @@ public class QuickDocProviderTestGenerated extends AbstractQuickDocProviderTest runTest("testData/editor/quickDoc/OnClassDeclarationWithNoPackage.kt"); } + @TestMetadata("OnCompanionObject.kt") + public void testOnCompanionObject() throws Exception { + runTest("testData/editor/quickDoc/OnCompanionObject.kt"); + } + @TestMetadata("OnEmptySecondaryConstructor.kt") public void testOnEmptySecondaryConstructor() throws Exception { runTest("testData/editor/quickDoc/OnEmptySecondaryConstructor.kt"); diff --git a/plugins/kotlin/idea/tests/testData/editor/quickDoc/OnCompanionObject.kt b/plugins/kotlin/idea/tests/testData/editor/quickDoc/OnCompanionObject.kt new file mode 100644 index 000000000000..c36902efe887 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/editor/quickDoc/OnCompanionObject.kt @@ -0,0 +1,6 @@ +class CompanionContainer { + companion object +} + +//K2_INFO:
public companion object of CompanionContainer
 CompanionContainer
+//INFO:
public companion object of CompanionContainer
 CompanionContainer