RFR: 8285470: Improve handling of @inheritDoc [v3]

Jonathan Gibbons jjg at openjdk.java.net
Mon Apr 25 23:15:51 UTC 2022


On Fri, 22 Apr 2022 17:32:22 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

>> The only taglet that along with its own tag needs to know the immediately enclosing tag is `InheritDocTaglet`:
>> 
>>     @return {@inheritDoc}
>>     @throws NullPointerException {@inheritDoc}
>>     @param p {@inheritDoc}
>> 
>> However, the immediately enclosing tag is unconditionally passed to all taglets. If we stop passing it and make `InheritDocTaglet` compute it instead, the code becomes cleaner.
>> 
>> While reviewing, particularly note these benefits of the proposed change:
>> 
>>  * taglet-handling code knows less about `@inheritDoc`, and
>>  * `InheritDocTaglet` receives its own tag, not the tag that encloses it
>
> Pavel Rappo has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java
>   
>   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>

This one is somewhat questionable.  

Generally, the trees in `javac` and `javadoc` do not store parent pointers (to save space), leading to a general coding philosophy of "collect any necessary information as you walk down the tree".  I understand why you want to get rid of the extra parameters, but it is disappointing to see the code use a tree-walk (even if we have recently improved it) to re-acquire info that was already available a few stack-frames up.

Since the magic/use is primarily in `TagletWriter/Impl` with most other edits being to propagate the info, is there any better way to make the `holder` available, without having to call `getDocTreePath`? For example, `HtmlDocWriter` creates a `TagletWriter round about line 381: is there a way we could stash the holder in that object for later retrieval by the `InheritDocTaglet`.

I would hate for this PR to be seen as a precedent for more widespread use of `get[Doc]TreePath`.

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

PR: https://git.openjdk.java.net/jdk/pull/8361


More information about the javadoc-dev mailing list