GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Format MOE strip markers in javadoc like any other HTML comment by abashev · Pull Request #155 · openjavaformat/open-java-format

Conversation

@abashev

@abashev abashev commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

google/MOE, the tool whose <!-- MOE:begin_intracomment_strip --> and <!-- MOE:end_intracomment_strip --> markers the javadoc formatter recognised, has been dead for years; #150 drops the line-comment rule for // MOE:. This removes the javadoc side: the two token types, the lexer patterns, the formatter cases and the writer state that queued a begin marker until the next token and remembered its indent for the end marker. Both markers now take the ordinary HTML comment path: a line of their own, at the indent of the text around them. Once #150 is in as well, no MOE reference is left in src/main.

What changes for a javadoc that still carries the markers:

  • A blank line that the tag after a begin marker asks for comes after the marker, not before it.
  • A marker inside or between footer tags is a continuation line of the tag it follows, so it is indented four columns; the old code wrote the begin marker at the indent of the next token and gave the end marker that same indent.
  • A begin marker that closes the comment without an end marker is kept; the old code queued it and never flushed it, so /** Foo. <!-- MOE:begin_intracomment_strip --> */ came out as /** Foo. */.

Before, for the footer tags of the test:

 * @param user the person to teleport.
 *     <!-- MOE:begin_intracomment_strip -->
 *     Users must sign go/deatomize-waiver ahead of time.
 *     <!-- MOE:end_intracomment_strip -->
 * <!-- MOE:begin_intracomment_strip -->
 * @deprecated Sometimes turns the user into a goat.
 * <!-- MOE:end_intracomment_strip -->

After:

 * @param user the person to teleport.
 *     <!-- MOE:begin_intracomment_strip -->
 *     Users must sign go/deatomize-waiver ahead of time.
 *     <!-- MOE:end_intracomment_strip -->
 *     <!-- MOE:begin_intracomment_strip -->
 * @deprecated Sometimes turns the user into a goat.
 *     <!-- MOE:end_intracomment_strip -->

Tests

Written first: moeStripMarkersAreOrdinaryHtmlComments failed before the change, with the old layout as its actual output. The three cases that only guarded the begin/end pairing against exploding (moeCommentBeginOnlyInMiddleOfDoc, moeCommentBeginOnlyAtEndOfDoc, moeCommentEndOnly) are gone.

Verification

  • ./gradlew test over all modules is green; ./gradlew formatDiff changes nothing; a full recompile gives the same 119 javac warnings before and after.
  • JDK 21 corpus, 15,747 files, formatted with javadoc formatting on: no file differs between 21.X.X and this branch, and the JDK carries no MOE marker. The CLI never enables javadoc formatting (JavaFormatterOptions defaults it off and Main has no flag for it), so the usual -i run cannot see a javadoc change; the comparison ran through Formatter with formatJavadoc(true) plus the CLI's import and reflow passes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@abashev
Format MOE strip markers in javadoc like any other HTML comment
cd40a92
google/MOE, the tool whose intracomment-strip markers the javadoc formatter
recognised, has been dead for years. The lexer no longer gives
`<!-- MOE:begin_intracomment_strip -->` and `<!-- MOE:end_intracomment_strip -->`
token types of their own, and the writer loses the state that queued the begin
marker until the next token and remembered its indent for the end marker: both
markers now take the HTML comment path, a line of their own at the indent of
the text around them.

The layouts the old test pinned change in two places: a blank line the next
tag asks for comes after the begin marker instead of before it, and a marker
inside or between footer tags is indented as a continuation line of the tag it
follows. A begin marker that closes the comment without an end marker is kept
instead of silently deleted.

The test was written first: moeStripMarkersAreOrdinaryHtmlComments failed
before the change; the three cases that only guarded the begin/end pairing
against exploding are gone. None of the 15,747 JDK 21 sources changes with
javadoc formatting on; the JDK carries no MOE markers.
@abashev
abashev merged commit a13b036 into 21.X.X Oct 25, 2026
17 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@abashev
abashev deleted the remove-moe-javadoc-markers branch October 25, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@abashev
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.