From dd432c8283b9c4a4aa98ae79a5fa4cbc07ec63fd Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 4 Oct 2018 06:40:29 +0300 Subject: Add specialization instead of platform sub-duplication removal --- .../main/kotlin/Generation/DocumentationMerger.kt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'core/src/main/kotlin/Generation') diff --git a/core/src/main/kotlin/Generation/DocumentationMerger.kt b/core/src/main/kotlin/Generation/DocumentationMerger.kt index b29c2915..f58d2f8e 100644 --- a/core/src/main/kotlin/Generation/DocumentationMerger.kt +++ b/core/src/main/kotlin/Generation/DocumentationMerger.kt @@ -127,12 +127,21 @@ class DocumentationMerger( singleNode.dropReferences { it.kind == RefKind.Owner } return singleNode } - val nodeWithMaxPlatforms = nodes.maxBy { it.platforms.size }!! - val maxPlatforms = nodeWithMaxPlatforms.platforms.toSet() - val notContained = nodes.filterNot { maxPlatforms.containsAll(it.platforms) } - val reducedDuplicates = listOf(nodeWithMaxPlatforms) + notContained - if (!reducedDuplicates.containsAll(nodes)) { - return mergeMembersWithEqualSignature(signature, reducedDuplicates) + + // Specialization processing + // Given (Common, JVM, JRE6, JS) and (JVM, JRE6) and (JVM, JRE7) + // Sorted: (JVM, JRE6), (JVM, JRE7), (Common, JVM, JRE6, JS) + // Should output: (JVM, JRE6), (JVM, JRE7), (Common, JS) + // Should not remove first platform + val nodesSortedByPlatformCount = nodes.sortedBy { it.platforms.size } + val allPlatforms = mutableSetOf() + nodesSortedByPlatformCount.forEach { node -> + node.platforms + .filterNot { allPlatforms.add(it) } + .filter { it != node.platforms.first() } + .forEach { platform -> + node.dropReferences { it.kind == RefKind.Platform && it.to.name == platform } + } } val groupNode = DocumentationNode(nodes.first().name, Content.Empty, NodeKind.GroupNode) -- cgit