Skip to content

fix(codegen)!: a legal comment can also be a jsdoc comment#11158

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments
May 19, 2025
Merged

fix(codegen)!: a legal comment can also be a jsdoc comment#11158
graphite-app[bot] merged 1 commit intomainfrom
05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 19, 2025

Breaking change: Changed the CommentAnnotation to CommentContent to
remove ambiguity on what an annotation is.

e.g. /** @license */

fixes #11093

Copilot AI review requested due to automatic review settings May 19, 2025 13:35
Copy link
Member Author

Boshen commented May 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-parser Area - Parser A-ast Area - AST A-codegen Area - Code Generation C-bug Category - Bug labels May 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 assign CommentContent and differentiate JsdocLegal.
  • Rename AST enum and methods in oxc_ast to use CommentContent.
  • Adjust codegen in gen.rs and comment-printing in comment.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-hq
Copy link

codspeed-hq bot commented May 19, 2025

CodSpeed Instrumentation Performance Report

Merging #11158 will improve performances by 14.35%

Comparing 05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments (1a4fec0) with main (468ddf4)

Summary

⚡ 1 improvements
✅ 37 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[cal.com.tsx] 3.5 ms 3 ms +14.35%

@Boshen Boshen force-pushed the 05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments branch from b20df64 to e0b1e11 Compare May 19, 2025 13:52
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 19, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 19, 2025

Merge activity

Breaking change: Changed the `CommentAnnotation` to `CommentContent` to
remove ambiguity on what an annotation is.

e.g. `/** @license */`

fixes #11093
@graphite-app graphite-app bot force-pushed the 05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments branch from e0b1e11 to 1a4fec0 Compare May 19, 2025 14:02
@graphite-app graphite-app bot merged commit 1a4fec0 into main May 19, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 05-19-fix_parser_consider_jsdoc_containing_license_as_legal_comments branch May 19, 2025 14:09
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-codegen Area - Code Generation A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to preserve license comments as part of legal comments after minifying

2 participants