Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Dec 4, 2025

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:

/* single line block comment */

CommentKind::MultilineBlock

/* multiline 
block
 comment */

Maybe it would be better to rename CommentKind::Block to CommentKind::SinglelineBlock. as well

@github-actions github-actions bot added A-linter Area - Linter A-parser Area - Parser A-cli Area - CLI A-ast Area - AST A-codegen Area - Code Generation A-formatter Area - Formatter A-linter-plugins Area - Linter JS plugins labels Dec 4, 2025
Copy link
Member Author

Dunqing commented Dec 4, 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 the C-enhancement Category - New feature or request label Dec 4, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 4, 2025

CodSpeed Performance Report

Merging #16479 will not alter performance

Comparing 12-04-feat_ast_parser_codegen_add_commentkind_multineblock (2bdaad6) with main (2c275bf)

Summary

✅ 42 untouched
⏩ 3 skipped1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing Dunqing changed the title feat(ast, parser, codegen): add CommentKind::MultineBlock feat(ast, parser, codegen): add CommentKind::MultilineBlock Dec 4, 2025
@Dunqing Dunqing changed the title feat(ast, parser, codegen): add CommentKind::MultilineBlock feat(ast, parser, codegen): add CommentKind::MultilineBlock Dec 4, 2025
@Dunqing Dunqing force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from b30e61f to 6f67bf0 Compare December 4, 2025 09:51
@Dunqing Dunqing force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from 4640f6c to d72ed7f Compare December 4, 2025 14:30
@Dunqing Dunqing marked this pull request as ready for review December 4, 2025 14:38
@Dunqing Dunqing requested a review from camc314 as a code owner December 4, 2025 14:38
Copilot AI review requested due to automatic review settings December 4, 2025 14:38
@Dunqing Dunqing force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from 1b8e61a to 482f237 Compare December 4, 2025 14:39
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 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 = 2 enum 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.

@Dunqing Dunqing force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from 482f237 to 4c95de1 Compare December 4, 2025 14:45
@Dunqing Dunqing force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from 4c95de1 to 77d4387 Compare December 7, 2025 15:25
@overlookmotel
Copy link
Member

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.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 9, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 9, 2025

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
@graphite-app graphite-app bot force-pushed the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch from 2bdaad6 to 30a9076 Compare December 9, 2025 02:02
@graphite-app graphite-app bot merged commit 30a9076 into main Dec 9, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-04-feat_ast_parser_codegen_add_commentkind_multineblock branch December 9, 2025 02:08
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 9, 2025
graphite-app bot pushed a commit that referenced this pull request Dec 9, 2025
…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.
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
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
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-cli Area - CLI A-codegen Area - Code Generation A-formatter Area - Formatter A-linter Area - Linter A-linter-plugins Area - Linter JS plugins A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants