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
10 changes: 4 additions & 6 deletions crates/oxc_ast_visit/src/generated/utf8_to_utf16_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
self.convert_offset(&mut it.span.end);
}

fn visit_formal_parameters(&mut self, it: &mut FormalParameters<'a>) {
self.convert_offset(&mut it.span.start);
walk_mut::walk_formal_parameters(self, it);
self.convert_offset(&mut it.span.end);
}

fn visit_formal_parameter(&mut self, it: &mut FormalParameter<'a>) {
self.convert_offset(&mut it.span.start);
walk_mut::walk_formal_parameter(self, it);
Expand Down Expand Up @@ -1067,6 +1061,10 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
self.convert_offset(&mut it.span.end);
}

fn visit_formal_parameters(&mut self, params: &mut FormalParameters<'a>) {
walk_mut::walk_formal_parameters(self, params);
}

fn visit_object_property(&mut self, prop: &mut ObjectProperty<'a>) {
self.convert_offset(&mut prop.span.start);
match (prop.shorthand, &mut prop.key, &mut prop.value) {
Expand Down
10 changes: 10 additions & 0 deletions tasks/ast_tools/src/generators/utf8_to_utf16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Generator for Utf8ToUtf16ConverterGenerator {
/// have span before the start of `ExportNamedDeclaration` / `ExportDefaultDeclaration` span.
/// 5. `BindingPattern` where `type_annotation` has span within `BindingPatternKind`.
/// Except for `BindingRestElement`, where `type_annotation`'s span is after `BindingPatternKind`.
/// 6. `FormalParameters` where span can include a `TSThisParameter` which is visited before it.
///
/// Define custom visitors for these types, which ensure `convert_offset` is always called with offsets
/// in ascending order.
Expand All @@ -52,6 +53,7 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
// Types with custom visitors (see comment above).
// Also skip `Comment` because we handle adjusting comment spans separately.
let skip_type_ids = [
"FormalParameters",
"ObjectProperty",
"BindingProperty",
"ExportNamedDeclaration",
Expand Down Expand Up @@ -100,6 +102,14 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
#(#methods)*

///@@line_break
fn visit_formal_parameters(&mut self, params: &mut FormalParameters<'a>) {
// Span of `FormalParameters` itself does not appear in ESTree AST,
// and its span includes `TSThisParameter` in types like `Function`,
// which is converted before `FormalParameters`. So skip converting span.
walk_mut::walk_formal_parameters(self, params);
}

///@@line_break
fn visit_object_property(&mut self, prop: &mut ObjectProperty<'a>) {
self.convert_offset(&mut prop.span.start);
Expand Down
Loading