From f9baebebf36904caea48fa45292874f53c4986ab Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 15 May 2017 15:25:10 +0300 Subject: Fix linking to javadoc external static fields GH-131 fixed --- .../kotlin/Kotlin/ExternalDocumentationLinkResolver.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt index 8113f95d..299492a4 100644 --- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt +++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt @@ -3,8 +3,10 @@ package org.jetbrains.dokka import com.google.inject.Inject import com.intellij.psi.PsiMethod import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe @@ -87,14 +89,18 @@ interface InboundExternalLinkResolutionService { override fun getPath(symbol: DeclarationDescriptor): String? { if (symbol is JavaClassDescriptor) { return DescriptorUtils.getFqName(symbol).asString().replace(".", "/") + ".html" - } else if (symbol is JavaMethodDescriptor) { + } else if (symbol is JavaCallableMemberDescriptor) { val containingClass = symbol.containingDeclaration as? JavaClassDescriptor ?: return null val containingClassLink = getPath(containingClass) if (containingClassLink != null) { - val psi = symbol.sourcePsi() as? PsiMethod - if (psi != null) { - val params = psi.parameterList.parameters.joinToString { it.type.canonicalText } - return containingClassLink + "#" + symbol.name + "(" + params + ")" + if (symbol is JavaMethodDescriptor) { + val psi = symbol.sourcePsi() as? PsiMethod + if (psi != null) { + val params = psi.parameterList.parameters.joinToString { it.type.canonicalText } + return containingClassLink + "#" + symbol.name + "(" + params + ")" + } + } else if (symbol is JavaPropertyDescriptor) { + return "$containingClassLink#${symbol.name}" } } } -- cgit