diff options
author | Dmitry Jemerov <intelliyole@gmail.com> | 2015-01-14 14:01:20 +0100 |
---|---|---|
committer | Dmitry Jemerov <intelliyole@gmail.com> | 2015-01-14 14:01:20 +0100 |
commit | 60e610ebdd86663bedf113d2235ac3c8364171d0 (patch) | |
tree | 0804f2730bd7da28cfb063f1b00fb4cc1773c4f9 /src/Kotlin | |
parent | cd21e1fea43c0b7fa8013e3db7f49fe2b600b7f8 (diff) | |
parent | 0dd5ea3c1492b15bd386ec5c2c8d6e467a8f72a9 (diff) | |
download | dokka-60e610ebdd86663bedf113d2235ac3c8364171d0.tar.gz dokka-60e610ebdd86663bedf113d2235ac3c8364171d0.tar.bz2 dokka-60e610ebdd86663bedf113d2235ac3c8364171d0.zip |
Merge pull request #14 from orangy/override-link
link overriding functions to the corresponding base class functions
Diffstat (limited to 'src/Kotlin')
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 892a462e..0b978370 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -412,6 +412,14 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati } } + val descriptor = nodeToDescriptor[node] + if (descriptor is FunctionDescriptor) { + val overrides = descriptor.getOverriddenDescriptors(); + overrides?.forEach { + addOverrideLink(node, it) + } + } + resolveContentLinks(node, node.content) for (child in node.members) { @@ -422,6 +430,21 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati } } + /** + * Add an override link from a function node to the node corresponding to the specified descriptor. + * Note that this descriptor may be contained in a class where the function is not actually overridden + * (just inherited from the parent), so we need to go further up the override chain to find a function + * which exists in the code and for which we do have a documentation node. + */ + private fun addOverrideLink(node: DocumentationNode, overriddenDescriptor: FunctionDescriptor) { + val overriddenNode = descriptorToNode[overriddenDescriptor.getOriginal()] + if (overriddenNode != null) { + node.addReferenceTo(overriddenNode, DocumentationReference.Kind.Override) + } else { + overriddenDescriptor.getOverriddenDescriptors().forEach { addOverrideLink(node, it) } + } + } + fun getResolutionScope(node: DocumentationNode): DeclarationDescriptor { val descriptor = nodeToDescriptor[node] ?: throw IllegalArgumentException("Node is not known to this context") return descriptor |