New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8304433: cleanup sentence breaker code in DocTreeMaker #13091
JDK-8304433: cleanup sentence breaker code in DocTreeMaker #13091
Conversation
👋 Welcome back jjg! A progress list of the required criteria for merging this PR into |
@jonathan-gibbons The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Took some time to step through old and new code because of many subtle changes, but that's the purpose of a cleanup I guess. 👍
@jonathan-gibbons This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 7 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Thank you |
/integrate |
Going to push as commit 80e9797.
Your commit was automatically rebased without conflicts. |
@jonathan-gibbons Pushed as commit 80e9797. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review a localized cleanup of the code in
DocTreeMaker
to split a description into the first sentence and the rest.There are two main aspects to the refactoring:
All the related code is moved into a new nested class,
SentenceBreaker
, withinDocTreeMaker
. This provides a stronger distinction between that code and the other, primary methods inDocTreeMaker
that implementDocTreeFactory
.The use of casts is improved to reduce the overall number required. In particular, the
cast
method is used early on to convertList<DocTree>
toList<DCTree>
. This is similar to existing usage of that method elsewhere.There are no significant changes in functionality. There is just one small observable difference, detected by one of the tests. The refactored code uses
List.of()
for an empty list; the older code used emptyjavac
List
objects. This was detected in a test that uses reflection to verify the result of scanning a tree, and the reflective check was forjavac
List
objects (only). The fix in the test is to just remove the import forjavac.util.List
and rely on the import forList
injava.util.*
, which picks upjava.util.List
, and which is a supertype ofjavac
List
.There is followup work that could be done, but is deferred to keep this change simpler and cleaner, with no significant change in functionality.
The handling of HTML tags in the first sentence is "less than ideal" and could be improved. In particular, most block tags, including lists and tables, do not terminate the first sentence, and could even lead to incorrect partitioning and downstream HTML generation. Presumably, this does not occur in practice. Related: the code that ignores
EndElement
tags in the first position also seems suspect.When a
List<DocTree>
is split, the two partial lists usejavac
List
s, not standard lists. This does have the benefit that such lists are immutable by design. That being said, it might be worth looking at the possibility of using unmodifiable "standard" lists instead.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/13091/head:pull/13091
$ git checkout pull/13091
Update a local copy of the PR:
$ git checkout pull/13091
$ git pull https://git.openjdk.org/jdk pull/13091/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13091
View PR using the GUI difftool:
$ git pr show -t 13091
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13091.diff