Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
oxc (0.151.0)
oxc (0.152.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -170,7 +170,7 @@ CHECKSUMS
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
maxitest (7.1.1) sha256=f504c01714f83d8e4483be8cb1a6b02faa7e08a135202c0516c1e55fd11cd78d
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
oxc (0.151.0)
oxc (0.152.0)
parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570
Expand Down
2 changes: 1 addition & 1 deletion lib/oxc/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Oxc
VERSION = "0.151.0"
VERSION = "0.152.0"
end
109 changes: 61 additions & 48 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ path = "src/lib.rs"
crate-type = ["cdylib", "staticlib", "rlib"]

[dependencies]
oxc = { version = "=0.151.0", features = ["full", "serialize"] }
oxc = { version = "=0.152.0", features = ["full", "serialize"] }
oxc_sourcemap = "8"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["raw_value"] }
Expand Down
1 change: 1 addition & 0 deletions rust/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn collect_comments(source: &str, program: &oxc::ast::ast::Program<'_>, include_
kind: match comment.kind {
CommentKind::Line => "Line",
CommentKind::SingleLineBlock | CommentKind::MultiLineBlock => "Block",
CommentKind::HtmlOpen | CommentKind::HtmlClose => "Line",
},
value: comment.content_span().source_text(source).to_string(),
start: comment.span.start,
Expand Down
28 changes: 28 additions & 0 deletions rust/tests/parse_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ fn parse_leaves_the_ast_out_when_it_was_only_asked_to_read() {
);
}

#[test]
fn parse_treats_html_comments_as_line_comments() {
let (code, answer) = parse("<!-- hi\nfoo()", r#"{"ast":false}"#);

assert_eq!(code, OxcErrorCode::None);

let payload: serde_json::Value = serde_json::from_str(&answer).unwrap();
let comments = payload["comments"].as_array().unwrap();

assert_eq!(comments.len(), 1);
assert_eq!(comments[0]["type"], "Line");
assert_eq!(comments[0]["value"], " hi");
}

#[test]
fn parse_treats_html_close_comments_as_line_comments_in_script_mode() {
let (code, answer) = parse("-->\nfoo()", r#"{"ast":false,"source_type":"script"}"#);

assert_eq!(code, OxcErrorCode::None);

let payload: serde_json::Value = serde_json::from_str(&answer).unwrap();
let comments = payload["comments"].as_array().unwrap();

assert_eq!(comments.len(), 1);
assert_eq!(comments[0]["type"], "Line");
assert_eq!(comments[0]["value"], "");
}

#[test]
fn parse_answers_what_it_could_not_read_inside_the_result() {
let (code, answer) = parse("const x = ;", r#"{"ast":false}"#);
Expand Down
Loading
Loading