RFR: JDK-8288624: Cleanup CommentHelper.getText0 [v3]

Jonathan Gibbons jjg at openjdk.org
Mon Jul 11 21:54:31 UTC 2022


> Please review a moderately simple fix to clean up (as in _remove_!) `CommentHelper.getText` and friends/overloads.
> 
> This is moderately simple, because most of the heavy lifting was done in 
> [JDK-8288699](https://bugs.openjdk.org/browse/JDK-8288624), to clean up `commentTagsToContent`.
> 
> The uses of `CommentHelper.getText` can generally be replaced by either `commentTagsToContent` or just `DocTree.toString()`.
> 
> Two bugs were uncovered as a result of the cleanup.  These are described in detail in a comment with screenshots in the [bug report](https://bugs.openjdk.org/browse/JDK-8288624?focusedCommentId=14508488&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14508488)  
> 
> Fixing the `see-list-long` bug was a direct reason to cleanup `commentTagsToContent`. The fix here could maybe be further improved by writing a simple visitor or (preferably) a pattern-switch when that is a standard feature of the language.
> 
> Fixing the other bug was mostly an accidental side-effect of just using `commentTagsToContent` instead of `CommentHelper.getText`, since the tags now get interpreted instead of ignored.  However, one tweak was necessary.
> The doc comments for serialization info end up in `serialized-form.html` and not in the primary file for the enclosing type.
> This means they should not undergo the standard `redirectRelativeLinks` treatment. Links using `{@link...}` are not affected, but links using explicit `<a href="relative-link">...</a>` are affected. Ideally, we should not be using such relative links in the JDK API documentation, but there are too many to change/fix as part of this work. The fix, for now, is to add a new overload to `commentTagsToContent` that provides the ability to disable the call to `redirectRelativeLinks` when needed ... that is, when generating `serialized-form.html`.
> 
> Initially, the goal was just a cleanup fix with no change to tests. The work has been tested by comparing generated docs before and after this work. There are a number of instances of differences in the generated docs, but all are instances of the bugs described above ... either the `see-list-long` bug, or the change that inline doc comment tags are now interpretedin places where they were previously ignored.  All existing tests continue to work without modification; new tests have been added for the fixes for the bugs that were discovered in the course of this work.

Jonathan Gibbons has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - remove need to special-case old behavior
 - Merge remote-tracking branch 'upstream/master' into 8288624.commenthelper-gettext
 - tolerate Windows newlines
 - fix whitespace
 - fix whitespace
 - JDK-8288624: Cleanup CommentHelper.getText0

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/9438/files
  - new: https://git.openjdk.org/jdk/pull/9438/files/e5b95523..9e881785

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9438&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9438&range=01-02

  Stats: 3389 lines in 207 files changed: 1179 ins; 1868 del; 342 mod
  Patch: https://git.openjdk.org/jdk/pull/9438.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9438/head:pull/9438

PR: https://git.openjdk.org/jdk/pull/9438


More information about the compiler-dev mailing list