aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-12-03 12:39:39 +0100
committerGitHub <noreply@github.com>2020-12-03 12:39:39 +0100
commit6b383541d110ba4f32c9c9ae6c0af8aeeedd0b80 (patch)
tree57963d77754ab2b0de7eb5abe74b0c1ffd9fc825 /plugins
parent80d8991fc572bd145e873ae368dca0b201e069cf (diff)
downloaddokka-6b383541d110ba4f32c9c9ae6c0af8aeeedd0b80.tar.gz
dokka-6b383541d110ba4f32c9c9ae6c0af8aeeedd0b80.tar.bz2
dokka-6b383541d110ba4f32c9c9ae6c0af8aeeedd0b80.zip
Resolve DRI-s from valueOf and values in java enum (#1655)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt9
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt7
2 files changed, 13 insertions, 3 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 61af1db1..9a1b05d5 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -199,7 +199,7 @@ class DefaultPsiToDocumentableTranslator(
parseSupertypes(superTypes)
val (regularFunctions, accessors) = splitFunctionsAndAccessors()
val documentation = javadocParser.parseDocumentation(this).toSourceSetDependent()
- val allFunctions = async { regularFunctions.parallelMapNotNull { if (!it.isConstructor) parseFunction(it) else null } +
+ val allFunctions = async { regularFunctions.parallelMapNotNull { if (!it.isConstructor) parseFunction(it, parentDRI = dri) else null } +
superMethods.parallelMap { parseFunction(it.first, inheritedFrom = it.second) } }
val source = PsiDocumentableSource(this).toSourceSetDependent()
val classlikes = async { innerClasses.asIterable().parallelMap { parseClasslike(it, dri) } }
@@ -337,9 +337,12 @@ class DefaultPsiToDocumentableTranslator(
private fun parseFunction(
psi: PsiMethod,
isConstructor: Boolean = false,
- inheritedFrom: DRI? = null
+ inheritedFrom: DRI? = null,
+ parentDRI: DRI? = null
): DFunction {
- val dri = DRI.from(psi)
+ val dri = parentDRI?.let { dri ->
+ DRI.from(psi).copy(packageName = dri.packageName, classNames = dri.classNames)
+ } ?: DRI.from(psi)
val docs = javadocParser.parseDocumentation(psi)
return DFunction(
dri,
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index 51d7556c..18927218 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -2,6 +2,8 @@ package model
import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.JavaClassReference
+import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.links.sureClassNames
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.Param
@@ -11,6 +13,7 @@ import org.junit.jupiter.api.Test
import utils.AbstractModelTest
import utils.assertNotNull
import utils.name
+import org.jetbrains.dokka.links.Callable as DRICallable
class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
@@ -312,6 +315,10 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "java" / "E").cast<DEnum>()) {
name equals "E"
entries counts 1
+ functions.sortedBy { it.name }.map { it.dri } equals listOf(
+ DRI("java", "E", DRICallable("valueOf", null, listOf(JavaClassReference("java.lang.String"))), PointingToDeclaration),
+ DRI("java", "E", DRICallable("values", null, emptyList()), PointingToDeclaration),
+ )
with((this / "Foo").cast<DEnumEntry>()) {
name equals "Foo"