RFR: JDK-8303895: Simplify and clean up LinkFactory code
Hannes Wallnöfer
hannesw at openjdk.org
Tue Mar 14 11:35:14 UTC 2023
Please review a change to clean up and simplify the link info and factory classes. This includes the following:
- Flatten the type hierarchy and remove the abstract `LinkInfo` and `LinkFactory` classes in the `jdk.javadoc.internal.doclets.toolkit.util.links` package. These classes are not used in the toolkit code and the abstraction has lost any value it may have had while significantly increasing complexity and readability of the code.
- Make all fields in `HtmlLinkInfo` private and add getters and setters to access them. The setters mostly use fluent style where it makes sense. I used a mixed approach to getter/setter naming, using get/set prefixes for fields with nouns as names, while omitting the prefix for complex names that start with a verb. While not being totally consistent I think this results in the best readability.
- Introduce a `forType(TypeMirror)` factory method to `HtmlLinkInfo` that returns a copy of itself with a new type. This is used to produce links to subtypes instead of tweaking and reusing the original `HtmlLinkInfo`.
The change does not cause any changes in the generated documentation for the JDK. There are a few places in the old code where the `skipPreview` flag is switched on or off. Some of these did not seem to be necessary to pass the tests and produce the same JDK documentation. This could either be caused by the change to copy `HtmlLinkInfo` objects instead of reusing them, or by changes in the JDK preview API since the feature has been introduced. In the end I chose to preserve all explicit changes to the `skipPreview` flag.
-------------
Commit messages:
- Make configuration field private
- Reintroduce method that sets skipPreview to false for bounds links
- Cleanup
- Encapsulate fields using mostly fluent setters
- Merge branch 'master' into JDK-8303895
- Do not reuse link info objects
- JDK-8303895: Flatten LinkFactory and LinkInfo type hierarchy
Changes: https://git.openjdk.org/jdk/pull/13014/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13014&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8303895
Stats: 950 lines in 9 files changed: 419 ins; 453 del; 78 mod
Patch: https://git.openjdk.org/jdk/pull/13014.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/13014/head:pull/13014
PR: https://git.openjdk.org/jdk/pull/13014
More information about the javadoc-dev
mailing list