Repository navigation
Conversation
When a compound word was hyphenated across a line break in Javadoc (e.g., `infinite-\n * precision`), the formatter previously joined the tokens with a space, resulting in `infinite- precision`. Join adjacent word literals across a line break when the preceding literal ends in a hyphen following a word character, while preserving spaces after suspended hyphens (e.g., `pre- and post-`). Ported from google/google-java-format#1475 (commit 55863463), adapted to this fork's Token API. The markdown `///` test does not apply here. The tests were written first: hyphenatedLineBreakJoined failed with `infinite- precision`, suspendedHyphenPreserved and hyphenBeforeParagraphBreakNotJoined guard the cases that must stay as they are.
A block-level tag as the first content of a comment (<pre>, <ul>, <blockquote>,
<h1>, <table>, {@snippet}) requests a blank line before itself, and the writer
honoured it right after the opening `/**` line, producing two empty ` *` lines
at the top of the comment. Ignore any whitespace request while nothing
significant has been written yet; the footer-tag special case for the same
situation becomes redundant and goes.
Ported from the classic-Javadoc part of google/google-java-format commit
e4cef582 ("Improve interactions between wroteAnythingSignificant and
whitespace requests"). Tests first: preBlockAsFirstContentGetsNoBlankLines and
listAsFirstContentGetsNoBlankLines both failed with the two empty lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits, each a port with the upstream author kept, each done test-first.
1. google/google-java-format#1475 (Liam Miller-Cushon, still open upstream). With Javadoc formatting on,
infinite-at a line end followed byprecisioncame out asinfinite- precision. The lexer now joins a literal ending in a word character plus-with a word literal on the next line, unless it isand/or(pre- and post-processingstays) or a paragraph break sits between them. Adapted to this fork'sTokenAPI; the///markdown test is upstream-only. Tests:hyphenatedLineBreakJoinedfailed before the change;suspendedHyphenPreservedandhyphenBeforeParagraphBreakNotJoinedguard what must not change.2. Two empty lines at the top of a comment that starts with a block tag. Found while checking palantir#1476:
/**\n * <pre>{@code ...(and<ul>,<blockquote>,<h1>,<table>) came out with two*lines after/**, because the tag's blank-line request was honoured right after the opening line. The writer now ignores whitespace requests while nothing significant has been written, the classic-Javadoc half of upstream commit e4cef582 (cpovirk); the footer-tag special case for the same situation is removed as redundant. Tests:preBlockAsFirstContentGetsNoBlankLines,listAsFirstContentGetsNoBlankLines, both failed before the fix.Full module suite: 1614 tests, 0 failures. Only reachable through
JavaFormatterOptions.formatJavadoc(true); the CLI and plugins are unaffected.