aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Kotlin
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-11 21:37:33 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-11 21:37:33 +0300
commit46b615b49fd9af994fc85c84596aa73bebed476c (patch)
treec0ec544d471f4bc37b3b73c7cd9fcf269b4ba854 /core/src/main/kotlin/Kotlin
parent0e8733ead6d5c4c6db7e4fe8a1f34b7598823290 (diff)
downloaddokka-46b615b49fd9af994fc85c84596aa73bebed476c.tar.gz
dokka-46b615b49fd9af994fc85c84596aa73bebed476c.tar.bz2
dokka-46b615b49fd9af994fc85c84596aa73bebed476c.zip
Resolve links in package docs in whole module
#KT-16485 fixed
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt17
1 files changed, 9 insertions, 8 deletions
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>): DeclarationDescriptor? {
if (symbols.isEmpty()) {
return null