diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-28 17:28:38 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 11:57:24 +0100 |
commit | d1177b3e3ca5935329c36fb5617861dabbd0cd3a (patch) | |
tree | b60e4e88abcb01e0e8efd9871b81b6fecb3a8198 /src/Formats/StructuredFormatService.kt | |
parent | 617401c6742f8c0f7ebe6e3d9839993441761987 (diff) | |
download | dokka-d1177b3e3ca5935329c36fb5617861dabbd0cd3a.tar.gz dokka-d1177b3e3ca5935329c36fb5617861dabbd0cd3a.tar.bz2 dokka-d1177b3e3ca5935329c36fb5617861dabbd0cd3a.zip |
show extensions applicable to superclasses in the list of class members
Diffstat (limited to 'src/Formats/StructuredFormatService.kt')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 8bc60826..d6a167d5 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -337,14 +337,32 @@ public abstract class StructuredFormatService(locationService: LocationService, DocumentationNode.Kind.EnumItem ) }, node, to) - appendSection(location, "Extension Properties", node.extensions.filter { it.kind == DocumentationNode.Kind.Property }, node, to) - appendSection(location, "Extension Functions", node.extensions.filter { it.kind == DocumentationNode.Kind.Function }, node, to) - appendSection(location, "Companion Object Extension Properties", node.extensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty }, node, to) - appendSection(location, "Companion Object Extension Functions", node.extensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectFunction }, node, to) + + val allExtensions = collectAllExtensions(node) + appendSection(location, "Extension Properties", allExtensions.filter { it.kind == DocumentationNode.Kind.Property }, node, to) + appendSection(location, "Extension Functions", allExtensions.filter { it.kind == DocumentationNode.Kind.Function }, node, to) + appendSection(location, "Companion Object Extension Properties", allExtensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectProperty }, node, to) + appendSection(location, "Companion Object Extension Functions", allExtensions.filter { it.kind == DocumentationNode.Kind.CompanionObjectFunction }, node, to) appendSection(location, "Inheritors", node.inheritors.filter { it.kind != DocumentationNode.Kind.EnumItem }, node, to) appendSection(location, "Links", node.links, node, to) } } + + private fun collectAllExtensions(node: DocumentationNode): Collection<DocumentationNode> { + val result = LinkedHashSet<DocumentationNode>() + val visited = hashSetOf<DocumentationNode>() + + fun collect(node: DocumentationNode) { + if (!visited.add(node)) return + result.addAll(node.extensions) + node.references(DocumentationReference.Kind.Superclass).forEach { collect(it.to) } + } + + collect(node) + + return result + + } }
\ No newline at end of file |