diff options
Diffstat (limited to 'plugins/base/src/main/kotlin')
3 files changed, 29 insertions, 20 deletions
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() |