RFR: JDK-8266748: Move modifiers code to Signatures.java

Jonathan Gibbons jjg at openjdk.java.net
Thu Jun 3 17:25:44 UTC 2021


On Fri, 21 May 2021 08:46:48 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:

> This change consolidates the code to generate type signature modifiers into `Signatures.TypeSignature`. 
> 
> Although this mostly consists of moving the code from `ClassWriterImpl` and `Utils` to `Signatures`, I also avoided the need to split the modifiers string when processing preview modifiers by returning a `List<String>` instead of a `String` in what used to be `Utils.modifiersToString` and is now `TypeSignature.getModifiers`.

Minor changes suggestion, to access items from the configuration where possible.

As a followup, it would be good to look at the remaining uses of `HtmlDocletWriter` in `Signatures`. There is at least a theme of "methods to create links", and if those methods are just used in the `Signatures` class, they would be candidates to move into that class as well.

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java line 134:

> 132:             HtmlTree nameSpan = new HtmlTree(TagName.SPAN).setStyle(HtmlStyle.elementName);
> 133:             Content className = Text.of(utils.getSimpleName(typeElement));
> 134:             if (writer.options.linkSource()) {

better to use configuration.getOptions()

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java line 210:

> 208:                 }
> 209:                 if (linkablePermits.size() < permits.size()) {
> 210:                     Content c = Text.of(writer.resources.getText("doclet.not.exhaustive"));

Better to use `configuration.getDocResources()`

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java line 249:

> 247:                      content.add(HtmlTree.SUP(writer.links.createLink(
> 248:                              writer.htmlIds.forPreviewSection(typeElement),
> 249:                              writer.contents.previewMark)));

use the configuration for these two values

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

Changes requested by jjg (Reviewer).

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


More information about the javadoc-dev mailing list