From fc70184fee01430ed9c673336026c6ede8bff5f3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 25 Feb 2015 20:06:16 +0100 Subject: working test for cross-language links in documentation (Kotlin class extends Java class) --- src/Kotlin/DocumentationBuilder.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 693f2675..1d7589a5 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -101,10 +101,10 @@ class DocumentationBuilder(val session: ResolveSession, fun resolveContentLink(descriptor: DeclarationDescriptor, href: String): ContentBlock { val symbols = resolveKDocLink(session, descriptor, null, href.split('.').toList()) + val symbol = findTargetSymbol(symbols) // don't include unresolved links in generated doc // assume that if an href doesn't contain '/', it's not an attempt to reference an external file - if (symbols.isNotEmpty()) { - val symbol = symbols.first() + if (symbol != null) { return ContentNodeLazyLink(href, {() -> refGraph.lookup(symbol.signature()) }) } if ("/" in href) { @@ -113,6 +113,17 @@ class DocumentationBuilder(val session: ResolveSession, return ContentExternalLink("#") } + fun findTargetSymbol(symbols: Collection): DeclarationDescriptor? { + if (symbols.isEmpty()) { + return null + } + val symbol = symbols.first() + if (symbol is CallableMemberDescriptor && symbol.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { + return symbol.getOverriddenDescriptors().firstOrNull() + } + return symbol + } + fun KDocSection.getTags(): Array = PsiTreeUtil.getChildrenOfType(this, javaClass()) ?: array() private fun Content.addTagToSeeAlso(descriptor: DeclarationDescriptor, seeTag: KDocTag) { -- cgit