RFR: 8341904: Search tag in inherited doc comment creates additional index item

Pavel Rappo prappo at openjdk.org
Fri Nov 8 14:06:14 UTC 2024


On Tue, 29 Oct 2024 14:51:53 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> Please review a change to avoid generation of index items for comments inherited from overridden methods. This affects `{@index}`, `{@systemProperty}`, and `@spec` tags in both implicitly and explicitly doc comments. 
> 
> The change adds two additional means for avoiding generation of index items which partially overlap:
> 
>  - Adding the `inheritDoc` tag to the current `TagletWriter.Context` when rendering an inherited doc comment
>  - Comparing the element's type element with the type element currently being documented
> 
> The second check is necessary for implicitly inherited doc comments (e.g. overriding a method without doc comment), while usage of `{@inheritDoc}` tag is detected by checks. I still decided to add the `inheritDoc` tag constant to `TagletWriter.Context` since it is explicit, uses a mechanism that was created for the purpose, and might be useful in other places. 
> 
> There was a test case for the previous (buggy) behaviour to add a search tag index item using the overridden method signature as label. I changed the expected behaviour and added another method to cover usage of the `{@systemProperty}` tag in combination with `{@inheritDoc}`.

Looks good with or without the nit below.

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java line 479:

> 477:     // Test if element is the same as or belongs to the current page element
> 478:     private boolean isDifferentTypeElement(Element element) {
> 479:         if (element.getKind().isClass() || element.getKind().isInterface()) {

Your version might be a bit more readable, but this one is shorter:
Suggestion:

        if (element.getKind().isDeclaredType()) {

-------------

Marked as reviewed by prappo (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/21765#pullrequestreview-2423888865
PR Review Comment: https://git.openjdk.org/jdk/pull/21765#discussion_r1834452598


More information about the javadoc-dev mailing list