diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-01 22:26:28 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-01 22:26:28 +0300 |
commit | abe161a118d3d7df40ad0e1df8b8adf07773103b (patch) | |
tree | 4176768eaaac9eec7240fdcbb954238d790edae8 /core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | |
parent | 1934463c0a2a708acfde371daf0692811f479a7a (diff) | |
download | dokka-abe161a118d3d7df40ad0e1df8b8adf07773103b.tar.gz dokka-abe161a118d3d7df40ad0e1df8b8adf07773103b.tar.bz2 dokka-abe161a118d3d7df40ad0e1df8b8adf07773103b.zip |
Correct merging of different type namesake declarations between platforms
Diffstat (limited to 'core/src/main/kotlin/Kotlin/DocumentationBuilder.kt')
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index fcb86d53..299ad477 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -278,11 +278,36 @@ class DocumentationBuilder return null } + fun createGroupNode(signature: String, nodes: List<DocumentationNode>) = (nodes.find { it.kind == NodeKind.GroupNode } ?: + DocumentationNode(nodes.first().name, Content.Empty, NodeKind.GroupNode).apply { + appendTextNode(signature, NodeKind.Signature, RefKind.Detail) + }) + .also { groupNode -> + nodes.forEach { node -> + if (node != groupNode) { + node.owner?.let { owner -> + node.dropReferences { it.to == owner && it.kind == RefKind.Owner } + owner.dropReferences { it.to == node && it.kind == RefKind.Member } + owner.append(groupNode, RefKind.Member) + } + groupNode.append(node, RefKind.Member) + } + } + } + + fun DocumentationNode.appendOrUpdateMember(descriptor: DeclarationDescriptor) { if (descriptor.isGenerated() || !descriptor.isDocumented(options)) return val existingNode = refGraph.lookup(descriptor.signature()) if (existingNode != null) { + if (existingNode.kind == NodeKind.TypeAlias && descriptor is ClassDescriptor + || existingNode.kind == NodeKind.Class && descriptor is TypeAliasDescriptor) { + val node = createGroupNode(descriptor.signature(), listOf(existingNode, descriptor.build())) + register(descriptor, node) + return + } + existingNode.updatePlatforms(descriptor) if (descriptor is ClassDescriptor) { |