-
-
Notifications
You must be signed in to change notification settings - Fork 737
feat(ast, parser, codegen): add CommentKind::MultilineBlock
#16479
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
feat(ast, parser, codegen): add CommentKind::MultilineBlock
#16479
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. |
CodSpeed Performance ReportMerging #16479 will not alter performanceComparing Summary
Footnotes
|
CommentKind::MultilineBlock
b30e61f to
6f67bf0
Compare
4640f6c to
d72ed7f
Compare
1b8e61a to
482f237
Compare
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.
Pull request overview
This PR adds a new CommentKind::MultilineBlock variant to distinguish between single-line block comments (/* comment */) and multi-line block comments that contain line breaks. This distinction is useful for formatters and code generators to preserve the original comment style.
Key changes:
- Added
CommentKind::MultilineBlock = 2enum variant with ESTree serialization to "Block" for compatibility - Updated parser to detect line breaks in block comments and assign the appropriate kind
- Modified codegen to handle multiline block comments with proper indentation
- Updated all pattern matches across formatter, linter, and NAPI bindings to handle the new variant
Reviewed changes
Copilot reviewed 7 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_ast/src/ast/comment.rs |
Added MultilineBlock variant, is_multiline_block() helper, and updated is_block() and content_span() to handle both block variants |
crates/oxc_ast/src/generated/derive_estree.rs |
Added serialization for MultilineBlock to "Block" for ESTree compatibility |
crates/oxc_parser/src/lexer/comment.rs |
Updated lexer logic to detect line breaks and create MultilineBlock comments when appropriate |
crates/oxc_parser/src/lexer/trivia_builder.rs |
Modified add_block_comment() to accept CommentKind parameter and updated test expectations |
crates/oxc_codegen/src/comment.rs |
Split block comment handling: single-line blocks printed as-is, multiline blocks with proper indentation; removed unused is_line_terminator import |
crates/oxc_formatter/src/formatter/trivia.rs |
Updated pattern match to handle both Block and MultilineBlock variants together |
crates/oxc_napi/src/lib.rs |
Updated pattern match to serialize both block variants to "Block" |
crates/oxc_linter/src/rules/typescript/prefer_function_type.rs |
Updated pattern match to handle both block comment variants |
| Generated JS files (9 files) | Updated deserializers to map discriminant 2 to "Block" for ESTree compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
482f237 to
4c95de1
Compare
4c95de1 to
77d4387
Compare
|
I pushed 1 commit to just maintain "correct" import order. 2nd PR in this stack is awaiting review by @leaysgur, so I've not merged this PR - I assume better we merge the whole stack in one go, rather than just this commit getting included in today's release. |
Merge activity
|
Add `CommentKind::MultilineBlock` to indicate a block comment that has at least one linebreak, which would be useful in the Codegen and Formatter Examples: CommentKind::Block: ```js /* single line block comment */ ``` CommentKind::MultilineBlock ```js /* multiline block comment */ ``` Maybe it would be better to rename `CommentKind::Block` to `CommentKind::SinglelineBlock.` as well
2bdaad6 to
30a9076
Compare
…Block` to `CommentKind::SinglelineBlock` (#16501) #16479 introduced a new kind called `CommentKind::MultilineBlock`, which means a block comment that has at least one line break. Therefore, `CommentKind::Block` means it is a single-line block. In this PR, rename `CommentKind::Block` to `CommentKind::SinglelineBlock` to make the kind name more descriptive.
Add `CommentKind::MultilineBlock` to indicate a block comment that has at least one linebreak, which would be useful in the Codegen and Formatter Examples: CommentKind::Block: ```js /* single line block comment */ ``` CommentKind::MultilineBlock ```js /* multiline block comment */ ``` Maybe it would be better to rename `CommentKind::Block` to `CommentKind::SinglelineBlock.` as well
…Block` to `CommentKind::SinglelineBlock` (#16501) #16479 introduced a new kind called `CommentKind::MultilineBlock`, which means a block comment that has at least one line break. Therefore, `CommentKind::Block` means it is a single-line block. In this PR, rename `CommentKind::Block` to `CommentKind::SinglelineBlock` to make the kind name more descriptive.

Add
CommentKind::MultilineBlockto indicate a block comment that has at least one linebreak, which would be useful in the Codegen and FormatterExamples:
CommentKind::Block:
/* single line block comment */CommentKind::MultilineBlock
Maybe it would be better to rename
CommentKind::BlocktoCommentKind::SinglelineBlock.as well