aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/model/documentableProperties.kt7
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt14
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt7
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt28
-rw-r--r--plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt2
-rw-r--r--plugins/base/src/test/kotlin/enums/EnumsTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt2
-rw-r--r--plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt14
-rw-r--r--plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt15
10 files changed, 62 insertions, 31 deletions
diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt
index 67e5e88d..f630ba3b 100644
--- a/core/src/main/kotlin/model/documentableProperties.kt
+++ b/core/src/main/kotlin/model/documentableProperties.kt
@@ -4,11 +4,10 @@ import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.MergeStrategy
data class InheritedFunction(val isInherited: Boolean): ExtraProperty<DFunction> {
- object InheritedFunctionKey: ExtraProperty.Key<DFunction, Boolean> {
- override fun mergeStrategyFor(left: Boolean, right: Boolean) = MergeStrategy.Fail {
+ companion object : ExtraProperty.Key<DFunction, InheritedFunction> {
+ override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Fail {
throw IllegalArgumentException("Function inheritance should be consistent!")
}
}
- override val key: ExtraProperty.Key<DFunction, Boolean> =
- InheritedFunctionKey
+ override val key: ExtraProperty.Key<DFunction, *> = InheritedFunction
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 1c374626..dd154ce2 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
import org.jetbrains.kotlin.idea.kdoc.findKDoc
import org.jetbrains.kotlin.psi.KtExpression
-import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.components.isVararg
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
@@ -270,8 +269,14 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
)
}
+ fun CallableMemberDescriptor.createDRI(wasOverriden: Boolean = false): Pair<DRI, Boolean> =
+ if (kind == CallableMemberDescriptor.Kind.DECLARATION || overriddenDescriptors.isEmpty())
+ Pair(DRI.from(this), wasOverriden)
+ else
+ overriddenDescriptors.first().createDRI(true)
+
override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): DFunction {
- val dri = parent.dri.copy(callable = Callable.from(descriptor))
+ val (dri, isInherited) = descriptor.createDRI()
val isExpect = descriptor.isExpect
val actual = descriptor.createSources()
@@ -294,7 +299,10 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
else PlatformDependent.from(platformData, descriptor.modifier()),
type = descriptor.returnType!!.toBound(),
platformData = listOf(platformData),
- extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations())
+ extra = PropertyContainer.withAll(
+ InheritedFunction(isInherited),
+ descriptor.additionalExtras(), descriptor.getAnnotations()
+ )
)
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index b217117b..11f57696 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -33,7 +33,7 @@ open class DefaultPageCreator(
ClasslikePageNode(
e.name.orEmpty(), contentForEnumEntry(e), setOf(e.dri), e,
e.classlikes.map(::pageForClasslike) +
- e.functions.map(::pageForFunction)
+ e.filteredFunctions.map(::pageForFunction)
)
open fun pageForClasslike(c: DClasslike): ClasslikePageNode {
@@ -43,13 +43,16 @@ open class DefaultPageCreator(
c.name.orEmpty(), contentForClasslike(c), setOf(c.dri), c,
constructors.map(::pageForFunction) +
c.classlikes.map(::pageForClasslike) +
- c.functions.map(::pageForFunction) +
+ c.filteredFunctions.map(::pageForFunction) +
if (c is DEnum) c.entries.map(::pageForEnumEntry) else emptyList()
)
}
open fun pageForFunction(f: DFunction) = MemberPageNode(f.name, contentForFunction(f), setOf(f.dri), f)
+ private val WithScope.filteredFunctions
+ get() = functions.filter { it.extra[InheritedFunction]?.isInherited != true }
+
protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) {
header(1) { text(m.name) }
block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) {
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index ee862fb8..87c78aa8 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -5,7 +5,6 @@ import com.intellij.lang.jvm.types.JvmReferenceType
import com.intellij.psi.*
import com.intellij.psi.impl.source.PsiClassReferenceType
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.links.DriOfAny
import org.jetbrains.dokka.links.withClass
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.PropertyContainer
@@ -116,8 +115,8 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
parseSupertypes(superTypes)
val (regularFunctions, accessors) = splitFunctionsAndAccessors()
val documentation = javadocParser.parseDocumentation(this).toPlatformDependant()
- val allFunctions = regularFunctions.mapNotNull { if (!it.isConstructor) parseFunction(it, dri) else null } +
- superMethods.map { parseFunction(it, dri, isInherited = true) }
+ val allFunctions = regularFunctions.mapNotNull { if (!it.isConstructor) parseFunction(it) else null } +
+ superMethods.map { parseFunction(it, isInherited = true) }
val source = PsiDocumentableSource(this).toPlatformDependant()
val classlikes = innerClasses.map { parseClasslike(it, dri) }
val visibility = getVisibility().toPlatformDependant()
@@ -131,11 +130,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
documentation,
source,
allFunctions,
- fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) },
+ fields.mapNotNull { parseField(it, accessors[it].orEmpty()) },
classlikes,
visibility,
null,
- constructors.map { parseFunction(it, dri, true) },
+ constructors.map { parseFunction(it, true) },
listOf(platformData),
PropertyContainer.empty<DAnnotation>() + annotations.toList().toExtra()
)
@@ -157,11 +156,11 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
documentation,
source,
allFunctions,
- fields.filter { it !is PsiEnumConstant }.map { parseField(it, dri, accessors[it].orEmpty()) },
+ fields.filter { it !is PsiEnumConstant }.map { parseField(it, accessors[it].orEmpty()) },
classlikes,
visibility,
null,
- constructors.map { parseFunction(it, dri, true) },
+ constructors.map { parseFunction(it, true) },
ancestors,
listOf(platformData),
PropertyContainer.empty<DEnum>() + annotations.toList().toExtra()
@@ -172,7 +171,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
documentation,
source,
allFunctions,
- fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) },
+ fields.mapNotNull { parseField(it, accessors[it].orEmpty()) },
classlikes,
visibility,
null,
@@ -184,9 +183,9 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
else -> DClass(
dri,
name.orEmpty(),
- constructors.map { parseFunction(it, dri, true) },
+ constructors.map { parseFunction(it, true) },
allFunctions,
- fields.mapNotNull { parseField(it, dri, accessors[it].orEmpty()) },
+ fields.mapNotNull { parseField(it, accessors[it].orEmpty()) },
classlikes,
source,
visibility,
@@ -203,11 +202,10 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
private fun parseFunction(
psi: PsiMethod,
- parent: DRI,
isConstructor: Boolean = false,
isInherited: Boolean = false
): DFunction {
- val dri = DRI.from(psi).copy(classNames = parent.classNames)
+ val dri = DRI.from(psi)
return DFunction(
dri,
if (isConstructor) "<init>" else psi.name,
@@ -328,7 +326,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
return regularMethods to accessors
}
- private fun parseField(psi: PsiField, parent: DRI, accessors: List<PsiMethod>): DProperty {
+ private fun parseField(psi: PsiField, accessors: List<PsiMethod>): DProperty {
val dri = DRI.from(psi)
return DProperty(
dri,
@@ -338,8 +336,8 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
psi.getVisibility().toPlatformDependant(),
getBound(psi.type),
null,
- accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it, parent) },
- accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it, parent) },
+ accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it) },
+ accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it) },
psi.getModifier().toPlatformDependant(),
listOf(platformData),
PropertyContainer.empty<DProperty>() + psi.annotations.toList().toExtra()
diff --git a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt
index dae1b2be..c1044e09 100644
--- a/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt
+++ b/plugins/base/src/test/kotlin/basic/DokkaBasicTests.kt
@@ -32,7 +32,7 @@ class DokkaBasicTests : AbstractCoreTest() {
) {
pagesGenerationStage = {
println(it.dri)
- assertTrue(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5)
+ assertTrue(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 2)
}
}
}
diff --git a/plugins/base/src/test/kotlin/enums/EnumsTest.kt b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
index c9024a72..e765d203 100644
--- a/plugins/base/src/test/kotlin/enums/EnumsTest.kt
+++ b/plugins/base/src/test/kotlin/enums/EnumsTest.kt
@@ -36,7 +36,6 @@ class EnumsTest : AbstractCoreTest() {
val test = map.filterKeys { it.name == "Test" }.values.firstOrNull()
assertTrue(test != null) { "Test not found" }
assertTrue(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" }
- assertTrue(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" }
}
}
}
@@ -83,7 +82,6 @@ class EnumsTest : AbstractCoreTest() {
val test = map.filterKeys { it.name == "Test" }.values.firstOrNull()
assertNotNull(test, "Test not found")
assertTrue(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" }
- assertTrue(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" }
}
}
}
diff --git a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt
index 0111e8fb..5facd194 100644
--- a/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt
+++ b/plugins/base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt
@@ -47,7 +47,7 @@ class BasicMultiplatformTest : AbstractCoreTest() {
configuration
) {
pagesGenerationStage = {
- assertEquals(6, it.parentMap.size)
+ assertEquals(3, it.parentMap.size)
}
}
}
diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
index 20ee7490..e66490c1 100644
--- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
+++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
@@ -49,7 +49,7 @@ class PageTransformerBuilderTest : AbstractCoreTest() {
orig = it
}
pagesTransformationStage = { root ->
- list.assertCount(7, "Page list: ")
+ list.assertCount(4, "Page list: ")
orig?.let { root.assertTransform(it) }
}
}
diff --git a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt
index e559713a..2f872c11 100644
--- a/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt
+++ b/plugins/base/src/test/resources/expect/annotatedFunctionWithAnnotationParameters/src/annotatedFunctionWithAnnotationParameters.kt
@@ -1,7 +1,19 @@
@Target(AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
-public annotation class Fancy(val size: Int)
+public annotation class Fancy(val size: Int) {
+ override fun equals(other: Any?): Boolean {
+ return super.equals(other)
+ }
+
+ override fun hashCode(): Int {
+ return super.hashCode()
+ }
+
+ override fun toString(): String {
+ return super.toString()
+ }
+}
@Fancy(1) fun f() {}
diff --git a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt
index f858e671..0988d4b3 100644
--- a/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt
+++ b/plugins/base/src/test/resources/expect/functionWithAnnotatedParam/src/functionWithAnnotatedParam.kt
@@ -1,7 +1,20 @@
@Target(AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
-public annotation class Fancy
+public annotation class Fancy {
+
+ override fun equals(other: Any?): Boolean {
+ return super.equals(other)
+ }
+
+ override fun hashCode(): Int {
+ return super.hashCode()
+ }
+
+ override fun toString(): String {
+ return super.toString()
+ }
+}
fun function(@Fancy notInlined: () -> Unit) {
}