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
16 changes: 10 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 @@ -989,12 +989,6 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
self.convert_offset(&mut it.span.end);
}

fn visit_ts_template_literal_type(&mut self, it: &mut TSTemplateLiteralType<'a>) {
self.convert_offset(&mut it.span.start);
walk_mut::walk_ts_template_literal_type(self, it);
self.convert_offset(&mut it.span.end);
}

fn visit_ts_as_expression(&mut self, it: &mut TSAsExpression<'a>) {
self.convert_offset(&mut it.span.start);
walk_mut::walk_ts_as_expression(self, it);
Expand Down Expand Up @@ -1234,6 +1228,16 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
self.visit_template_element(lit.quasis.last_mut().unwrap());
self.convert_offset(&mut lit.span.end);
}

fn visit_ts_template_literal_type(&mut self, lit: &mut TSTemplateLiteralType<'a>) {
self.convert_offset(&mut lit.span.start);
for (quasi, ts_type) in lit.quasis.iter_mut().zip(&mut lit.types) {
self.visit_template_element(quasi);
self.visit_ts_type(ts_type);
}
self.visit_template_element(lit.quasis.last_mut().unwrap());
self.convert_offset(&mut lit.span.end);
}
}

impl Utf8ToUtf16Converter<'_> {
Expand Down
16 changes: 16 additions & 0 deletions tasks/ast_tools/src/generators/utf8_to_utf16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl Generator for Utf8ToUtf16ConverterGenerator {
/// 1. Types where a shorthand syntax means 2 nodes have same span e.g. `const {x} = y;`, `export {x}`.
/// 2. `WithClause`, where `IdentifierName` for `with` keyword has span outside of the `WithClause`.
/// 3. `TemplateLiteral`s, where `quasis` and `expressions` are interleaved.
/// Ditto `TSTemplateLiteralType`s where `quasis` and `types` are interleaved.
/// 4. Decorators before `export` in `@dec export class C {}` / `@dec export default class {}`
/// have span before the start of `ExportNamedDeclaration` / `ExportDefaultDeclaration` span.
/// 5. `BindingPattern` where `type_annotation` has span within `BindingPatternKind`.
Expand All @@ -59,6 +60,7 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
"ExportSpecifier",
"WithClause",
"TemplateLiteral",
"TSTemplateLiteralType",
"BindingRestElement",
"Comment",
]
Expand Down Expand Up @@ -300,6 +302,20 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {

self.convert_offset(&mut lit.span.end);
}

///@@line_break
fn visit_ts_template_literal_type(&mut self, lit: &mut TSTemplateLiteralType<'a>) {
self.convert_offset(&mut lit.span.start);

// Visit `quasis` and `types` in source order. The two `Vec`s are interleaved.
for (quasi, ts_type) in lit.quasis.iter_mut().zip(&mut lit.types) {
self.visit_template_element(quasi);
self.visit_ts_type(ts_type);
}
self.visit_template_element(lit.quasis.last_mut().unwrap());

self.convert_offset(&mut lit.span.end);
}
}

///@@line_break
Expand Down
Loading