Skip to content

Commit d72ed7f

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

File tree

15 files changed

+20
-16
lines changed

15 files changed

+20
-16
lines changed

apps/oxlint/src-js/generated/deserialize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5652,7 +5652,7 @@ function deserializeCommentKind(pos) {
56525652
case 1:
56535653
return "Block";
56545654
case 2:
5655-
return "MultiLineBlock";
5655+
return "Block";
56565656
default:
56575657
throw Error(`Unexpected discriminant ${uint8[pos]} for CommentKind`);
56585658
}

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_ast/src/generated/derive_estree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,7 @@ impl ESTree for CommentKind {
32343234
match self {
32353235
Self::Line => JsonSafeString("Line").serialize(serializer),
32363236
Self::Block => JsonSafeString("Block").serialize(serializer),
3237-
Self::MultilineBlock => JsonSafeString("MultiLineBlock").serialize(serializer),
3237+
Self::MultilineBlock => JsonSafeString("Block").serialize(serializer),
32383238
}
32393239
}
32403240
}

crates/oxc_codegen/src/comment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::borrow::Cow;
22

3+
use oxc_syntax::line_terminator::LineTerminatorSplitter;
34
use rustc_hash::{FxHashMap, FxHashSet};
45

56
use oxc_ast::{Comment, CommentKind, ast::Program};

crates/oxc_linter/src/rules/typescript/prefer_function_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ fn check_member(member: &TSSignature, node: &AstNode<'_>, ctx: &LintContext<'_>)
159159

160160
let has_comments = ctx.has_comments_between(interface_decl.span);
161161

162-
// TODO:
163162
if has_comments {
164163
let comments = ctx
165164
.comments_range(node_start..node_end)

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,

napi/parser/generated/deserialize/js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4211,7 +4211,7 @@ function deserializeCommentKind(pos) {
42114211
case 1:
42124212
return "Block";
42134213
case 2:
4214-
return "MultiLineBlock";
4214+
return "Block";
42154215
default:
42164216
throw Error(`Unexpected discriminant ${uint8[pos]} for CommentKind`);
42174217
}

napi/parser/generated/deserialize/js_parent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4944,7 +4944,7 @@ function deserializeCommentKind(pos) {
49444944
case 1:
49454945
return "Block";
49464946
case 2:
4947-
return "MultiLineBlock";
4947+
return "Block";
49484948
default:
49494949
throw Error(`Unexpected discriminant ${uint8[pos]} for CommentKind`);
49504950
}

napi/parser/generated/deserialize/js_range.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4657,7 +4657,7 @@ function deserializeCommentKind(pos) {
46574657
case 1:
46584658
return "Block";
46594659
case 2:
4660-
return "MultiLineBlock";
4660+
return "Block";
46614661
default:
46624662
throw Error(`Unexpected discriminant ${uint8[pos]} for CommentKind`);
46634663
}

napi/parser/generated/deserialize/js_range_parent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5191,7 +5191,7 @@ function deserializeCommentKind(pos) {
51915191
case 1:
51925192
return "Block";
51935193
case 2:
5194-
return "MultiLineBlock";
5194+
return "Block";
51955195
default:
51965196
throw Error(`Unexpected discriminant ${uint8[pos]} for CommentKind`);
51975197
}

0 commit comments

Comments
 (0)