fix(codegen)!: a legal comment can also be a jsdoc comment#11158
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull Request Overview
This PR renames CommentAnnotation to CommentContent to clarify comment semantics and introduces a new JsdocLegal variant for JSDoc comments containing license or preserve annotations. It updates parsing, AST definitions, codegen logic, and test snapshots accordingly.
- Update parser (
trivia_builder.rs) to assignCommentContentand differentiateJsdocLegal. - Rename AST enum and methods in
oxc_astto useCommentContent. - Adjust codegen in
gen.rsand comment-printing incomment.rs, and refresh snapshots/tests.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_parser/src/lexer/trivia_builder.rs | Switch from CommentAnnotation to CommentContent and handle JsdocLegal. |
| crates/oxc_ast/src/ast/comment.rs | Rename enum to CommentContent, add JsdocLegal, update variants and methods. |
| crates/oxc_codegen/src/gen.rs | Refine single-line comment detection logic. |
| crates/oxc_codegen/src/comment.rs | Simplify legal/annotation/normal comment-printing branches. |
| crates/oxc_codegen/tests/integration/snapshots/*.snap | Update snapshots for new comment formatting. |
| crates/oxc_codegen/tests/integration/comments.rs | Change Default::default() to CodegenOptions::default() in tests. |
Comments suppressed due to low confidence (2)
crates/oxc_codegen/src/comment.rs:25
- [nitpick] Legal comments were previously printed regardless of position but now only when leading. Verify whether trailing legal comments should still be printed or if this restriction was intended.
if comment.is_leading() {
crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap:114
- [nitpick] Inconsistent whitespace in the snapshot comment: add a space after
*to match the other blocks (e.g. change* @preserve).
+* @preserve
CodSpeed Instrumentation Performance ReportMerging #11158 will improve performances by 14.35%Comparing Summary
Benchmarks breakdown
|
b20df64 to
e0b1e11
Compare
Merge activity
|
e0b1e11 to
1a4fec0
Compare

Breaking change: Changed the
CommentAnnotationtoCommentContenttoremove ambiguity on what an annotation is.
e.g.
/** @license */fixes #11093