Skip to content

Commit 4640f6c

Browse files
Apply suggestions from code review
Co-authored-by: overlookmotel <[email protected]> Signed-off-by: Dunqing <[email protected]>
1 parent 6f67bf0 commit 4640f6c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/oxc_ast/src/ast/comment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum CommentKind {
1818
/// Block comment
1919
Block = 1,
2020
/// Multiline block comment (contains line breaks)
21+
#[estree(rename = "Block")]
2122
MultilineBlock = 2,
2223
}
2324

crates/oxc_parser/src/lexer/comment.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@ impl<'a> Lexer<'a> {
8383
/// Section 12.4 Multi Line Comment
8484
pub(super) fn skip_multi_line_comment(&mut self) -> Kind {
8585
// If `is_on_new_line` is already set, go directly to faster search which only looks for `*/`
86-
// TODO(FIXME): commented out since it doesn't means there is a line break in the comment, while it means the line break is before the comment
87-
// if self.token.is_on_new_line() {
88-
// return self.skip_multi_line_comment_after_line_break(self.source.position());
89-
// }
86+
// We need to identify if comment contains line breaks or not
87+
// (`CommentKind::Block` or `CommentKind::MultilineBlock`).
88+
// So we have to use the loop below for the first line of the comment even if
89+
// `Token`'s `is_on_new_line` flag is already set.
90+
// If the loop finds a line break before end of the comment, we then switch to
91+
// the faster `skip_multi_line_comment_after_line_break` which searches
92+
// for the end of the comment using `memchr`.
9093

9194
byte_search! {
9295
lexer: self,

0 commit comments

Comments
 (0)