diff --git a/crates/oxc_regular_expression/examples/parse_literal.rs b/crates/oxc_regular_expression/examples/parse_literal.rs index 72cc9b0ed7840..26b50b9146415 100644 --- a/crates/oxc_regular_expression/examples/parse_literal.rs +++ b/crates/oxc_regular_expression/examples/parse_literal.rs @@ -47,7 +47,7 @@ fn main() { let ret = parser.parse(); match ret { - Ok(ast::RegExpLiteral { pattern, flags, .. }) => { + Ok(ast::RegularExpression { pattern, flags, .. }) => { println!("✨ {}", pattern.span.source_text(source_text)); println!("{pattern:#?}"); println!("✨ {}", flags.span.source_text(source_text)); diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index 5dabd1cff0533..be0065cf34496 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -2,7 +2,7 @@ use oxc_allocator::{Box, Vec}; use oxc_span::{Atom as SpanAtom, Span}; #[derive(Debug)] -pub struct RegExpLiteral<'a> { +pub struct RegularExpression<'a> { pub span: Span, pub pattern: Pattern<'a>, pub flags: Flags, diff --git a/crates/oxc_regular_expression/src/literal_parser.rs b/crates/oxc_regular_expression/src/literal_parser.rs index 64d694aee05ad..066ba6ea6662f 100644 --- a/crates/oxc_regular_expression/src/literal_parser.rs +++ b/crates/oxc_regular_expression/src/literal_parser.rs @@ -24,7 +24,7 @@ impl<'a> Parser<'a> { } } - pub fn parse(self) -> Result> { + pub fn parse(self) -> Result> { // Precheck if the source text is a valid regular expression literal // If valid, parse the pattern and flags with returned span offsets let (body_start_offset, body_end_offset, flag_start_offset) = @@ -54,7 +54,7 @@ impl<'a> Parser<'a> { ) .parse()?; - Ok(ast::RegExpLiteral { + Ok(ast::RegularExpression { span: self.span_factory.create(0, self.source_text.len()), pattern, flags, diff --git a/crates/oxc_regular_expression/src/options.rs b/crates/oxc_regular_expression/src/options.rs index 02280ed3378f1..af45dd66adcc0 100644 --- a/crates/oxc_regular_expression/src/options.rs +++ b/crates/oxc_regular_expression/src/options.rs @@ -18,6 +18,7 @@ impl ParserOptions { pub fn with_unicode_mode(self) -> ParserOptions { ParserOptions { unicode_mode: true, ..self } } + #[must_use] pub fn with_unicode_sets_mode(self) -> ParserOptions { ParserOptions { unicode_mode: true, unicode_sets_mode: true, ..self }