From 46b615b49fd9af994fc85c84596aa73bebed476c Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 11 May 2017 21:37:33 +0300 Subject: Resolve links in package docs in whole module #KT-16485 fixed --- core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'core/src/main/kotlin/Kotlin') diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt index 2ff69b4c..2b085769 100644 --- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt @@ -1,14 +1,9 @@ package org.jetbrains.dokka import com.google.inject.Inject -import com.intellij.psi.PsiMethod import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink -import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor -import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.DescriptorUtils class DeclarationLinkResolver @Inject constructor(val resolutionFacade: DokkaResolutionFacade, @@ -17,7 +12,8 @@ class DeclarationLinkResolver val options: DocumentationOptions, val externalDocumentationLinkResolver: ExternalDocumentationLinkResolver) { - fun resolveContentLink(fromDescriptor: DeclarationDescriptor, href: String): ContentBlock { + + fun tryResolveContentLink(fromDescriptor: DeclarationDescriptor, href: String): ContentBlock? { val symbol = try { val symbols = resolveKDocLink(resolutionFacade.resolveSession.bindingContext, resolutionFacade, fromDescriptor, null, href.split('.').toList()) @@ -38,10 +34,15 @@ class DeclarationLinkResolver if ("/" in href) { return ContentExternalLink(href) } - logger.warn("Unresolved link to $href in doc comment of ${fromDescriptor.signatureWithSourceLocation()}") - return ContentExternalLink("#") + return null } + fun resolveContentLink(fromDescriptor: DeclarationDescriptor, href: String) = + tryResolveContentLink(fromDescriptor, href) ?: run { + logger.warn("Unresolved link to $href in doc comment of ${fromDescriptor.signatureWithSourceLocation()}") + ContentExternalLink("#") + } + fun findTargetSymbol(symbols: Collection): DeclarationDescriptor? { if (symbols.isEmpty()) { return null -- cgit