From b3ce9a8eed32523c3ef2ee1ce186434bd14a6e64 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 5 Jan 2016 18:58:24 +0100 Subject: distinguish inherited companion object members --- core/src/main/kotlin/Formats/StructuredFormatService.kt | 2 ++ core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 7 ++++--- core/src/main/kotlin/Model/DocumentationNode.kt | 3 +++ core/src/main/kotlin/Model/DocumentationReference.kt | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index faa0b1ef..01f38605 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -287,7 +287,9 @@ abstract class StructuredFormatService(locationService: LocationService, appendSection("Functions", node.members(NodeKind.Function)) appendSection("Inherited Functions", node.inheritedMembers(NodeKind.Function)) appendSection("Companion Object Properties", node.members(NodeKind.CompanionObjectProperty)) + appendSection("Inherited Companion Object Properties", node.inheritedCompanionObjectMembers(NodeKind.Property)) appendSection("Companion Object Functions", node.members(NodeKind.CompanionObjectFunction)) + appendSection("Inherited Companion Object Functions", node.inheritedCompanionObjectMembers(NodeKind.Function)) appendSection("Other members", node.members.filter { it.kind !in setOf( NodeKind.Class, diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 3a35b764..a9701778 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -235,12 +235,13 @@ class DocumentationBuilder (!options.skipDeprecated || !isDeprecated()) } - fun DocumentationNode.appendMembers(descriptors: Iterable): List { + fun DocumentationNode.appendMembers(descriptors: Iterable, + inheritedLinkKind: RefKind = RefKind.InheritedMember): List { val nodes = descriptors.map { descriptor -> if (descriptor is CallableMemberDescriptor && descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { val baseDescriptor = descriptor.overriddenDescriptors.firstOrNull() if (baseDescriptor != null) { - link(this, baseDescriptor, RefKind.InheritedMember) + link(this, baseDescriptor, inheritedLinkKind) } null } @@ -314,7 +315,7 @@ class DocumentationBuilder if (companionObjectDescriptor != null) { val descriptors = companionObjectDescriptor.defaultType.memberScope.getContributedDescriptors() val descriptorsToDocument = descriptors.filter { it !is CallableDescriptor || !it.isInheritedFromAny() } - node.appendMembers(descriptorsToDocument) + node.appendMembers(descriptorsToDocument, RefKind.InheritedCompanionObjectMember) } node.appendAnnotations(this) node.appendModifiers(this) diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt index 121a5764..dcb50e8f 100644 --- a/core/src/main/kotlin/Model/DocumentationNode.kt +++ b/core/src/main/kotlin/Model/DocumentationNode.kt @@ -73,6 +73,8 @@ open class DocumentationNode(val name: String, get() = references(RefKind.Member).map { it.to } val inheritedMembers: List get() = references(RefKind.InheritedMember).map { it.to } + val inheritedCompanionObjectMembers: List + get() = references(RefKind.InheritedCompanionObjectMember).map { it.to } val extensions: List get() = references(RefKind.Extension).map { it.to } val inheritors: List @@ -107,6 +109,7 @@ open class DocumentationNode(val name: String, fun details(kind: NodeKind): List = details.filter { it.kind == kind } fun members(kind: NodeKind): List = members.filter { it.kind == kind } fun inheritedMembers(kind: NodeKind): List = inheritedMembers.filter { it.kind == kind } + fun inheritedCompanionObjectMembers(kind: NodeKind): List = inheritedCompanionObjectMembers.filter { it.kind == kind } fun links(kind: NodeKind): List = links.filter { it.kind == kind } fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single() diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt index 6db6d303..0b40e83a 100644 --- a/core/src/main/kotlin/Model/DocumentationReference.kt +++ b/core/src/main/kotlin/Model/DocumentationReference.kt @@ -6,6 +6,7 @@ enum class RefKind { Owner, Member, InheritedMember, + InheritedCompanionObjectMember, Detail, Link, HiddenLink, -- cgit