aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Falcone <asfalcone@google.com>2020-05-19 17:45:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-19 17:45:28 +0000
commit4eeabf7010ccd7c4d1456a354873e8a977120566 (patch)
tree7fdc9f2ae4a51b1ef66e0bee41931613cdf65166
parent4ada810b34afb5677d8495be3d2e9e9e3e4a7fae (diff)
parent2a8e19572f249ea05950a51a01c2c134f708b5cf (diff)
downloaddokka-4eeabf7010ccd7c4d1456a354873e8a977120566.tar.gz
Include inherited methods in asJava documentation am: 2a8e19572f
Change-Id: I166bede038d8542ddb37d7725690e6a03b6a26eb
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt21
-rw-r--r--core/testdata/format/dac/inheritedMethods/dac-as-java/Child.html29
2 files changed, 46 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index cc9c2c2bf..8776da4c2 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -206,13 +206,26 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
else -> NodeKind.Class
}
val node = nodeForElement(this, kind)
- superTypes.filter { !ignoreSupertype(it) }.forEach {
- node.appendType(it, NodeKind.Supertype)
- val superClass = it.resolve()
- if (superClass != null) {
+ superTypes.filter { !ignoreSupertype(it) }.forEach { superType ->
+ node.appendType(superType, NodeKind.Supertype)
+ val superClass = superType.resolve()
+ // parentNode is the actual DocumentationNode of this class's supertype
+ // It is necessary to create documentation links back to the superclass from inherited methods
+ val parentNode = refGraph.lookup(superType.typeSignature())
+ if (superClass != null && parentNode != null) {
link(superClass, node, RefKind.Inheritor)
+ // Explicitly add the methods of the superclass (which are not overridden) as nodes to this class
+ val overriddenMethods = methods.toList().flatMap { it.findSuperMethods().toList() }
+ val inheritedMethods = superClass.methods.filter { it !in overriddenMethods }.toTypedArray()
+
+ node.appendChildren(inheritedMethods, RefKind.InheritedMember) {
+ val child = build()
+ child.addReferenceTo(parentNode, RefKind.Owner)
+ return@appendChildren child
+ }
}
}
+
var methodsAndConstructors = methods
if (constructors.isEmpty()) {
diff --git a/core/testdata/format/dac/inheritedMethods/dac-as-java/Child.html b/core/testdata/format/dac/inheritedMethods/dac-as-java/Child.html
index a66d0bf6c..65e2addb0 100644
--- a/core/testdata/format/dac/inheritedMethods/dac-as-java/Child.html
+++ b/core/testdata/format/dac/inheritedMethods/dac-as-java/Child.html
@@ -60,6 +60,35 @@
</tr>
</tbody>
</table>
+ <table class="responsive" id="inhmethods">
+ <tbody>
+ <tr>
+ <th colSpan="2">
+ <devsite-heading ds-is="heading" text="Inherited functions" id="inherited-functions" level="h3" toc="" class="">
+ <h3 is-upgraded="">Inherited functions</h3>
+ </devsite-heading>
+ </th>
+ </tr>
+ <tr class="api apilevel-">
+ <td colSpan="2">
+ <div class="expandable jd-inherited-apis"><span class="expand-control exw-expanded">From class <code><a href="Parent.html#">Parent</a></code></span>
+ <table class="responsive exw-expanded-content">
+ <tbody>
+ <tr class="api apilevel-" data-version-added="ApiLevel:">
+ <td><code><span class="identifier">void</span></code></td>
+ <td width="100%"><code><a href="Parent.html#foo()">foo</a>()</code>
+ <p>
+ <p>Do a superclass foo</p>
+ </p>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
<h2>Public constructors</h2>
<a name="Child()"></a>
<div class="api apilevel-" data-version-added="">