From c59a3d8455ad45d679c47a387f854bdd81a01952 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 5 Jan 2016 18:32:04 +0100 Subject: don't include companion object members inherited from Any in class documentation --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin') diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index f92d15f9..3a35b764 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.isDocumentedAnnotation +import org.jetbrains.kotlin.resolve.findTopMostOverriddenDescriptors import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform import org.jetbrains.kotlin.resolve.source.PsiSourceElement @@ -311,7 +312,9 @@ class DocumentationBuilder } val companionObjectDescriptor = companionObjectDescriptor if (companionObjectDescriptor != null) { - node.appendMembers(companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors()) + val descriptors = companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors() + val descriptorsToDocument = descriptors.filter { it !is CallableDescriptor || !it.isInheritedFromAny() } + node.appendMembers(descriptorsToDocument) } node.appendAnnotations(this) node.appendModifiers(this) @@ -320,6 +323,12 @@ class DocumentationBuilder return node } + fun CallableDescriptor.isInheritedFromAny(): Boolean { + return findTopMostOverriddenDescriptors().any { + DescriptorUtils.getFqNameSafe(it.containingDeclaration).asString() == "kotlin.Any" + } + } + fun ClassDescriptor.isSubclassOfThrowable(): Boolean = defaultType.supertypes().any { it.constructor.declarationDescriptor == builtIns.throwable } -- cgit