Skip to content

Commit 287b3c3

Browse files
committed
refactor(ast_visit): descriptive method param names in Utf8ToUtf16Converter (#10987)
Pure refactor. Rename function params to be more descriptive than `it`.
1 parent 692b654 commit 287b3c3

2 files changed

Lines changed: 52 additions & 52 deletions

File tree

crates/oxc_ast_visit/src/generated/utf8_to_utf16_converter.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,9 +1079,9 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
10791079
self.convert_offset(&mut it.span.end);
10801080
}
10811081

1082-
fn visit_object_property(&mut self, it: &mut ObjectProperty<'a>) {
1083-
self.convert_offset(&mut it.span.start);
1084-
match (it.shorthand, &mut it.key, &mut it.value) {
1082+
fn visit_object_property(&mut self, prop: &mut ObjectProperty<'a>) {
1083+
self.convert_offset(&mut prop.span.start);
1084+
match (prop.shorthand, &mut prop.key, &mut prop.value) {
10851085
(true, PropertyKey::StaticIdentifier(key), Expression::Identifier(value)) => {
10861086
self.visit_identifier_name(key);
10871087
value.span = key.span;
@@ -1091,12 +1091,12 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
10911091
self.visit_expression(value);
10921092
}
10931093
}
1094-
self.convert_offset(&mut it.span.end);
1094+
self.convert_offset(&mut prop.span.end);
10951095
}
10961096

1097-
fn visit_binding_property(&mut self, it: &mut BindingProperty<'a>) {
1098-
self.convert_offset(&mut it.span.start);
1099-
match (it.shorthand, &mut it.key, &mut it.value) {
1097+
fn visit_binding_property(&mut self, prop: &mut BindingProperty<'a>) {
1098+
self.convert_offset(&mut prop.span.start);
1099+
match (prop.shorthand, &mut prop.key, &mut prop.value) {
11001100
(
11011101
true,
11021102
PropertyKey::StaticIdentifier(key),
@@ -1118,7 +1118,7 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
11181118
self.visit_binding_pattern(value);
11191119
}
11201120
}
1121-
self.convert_offset(&mut it.span.end);
1121+
self.convert_offset(&mut prop.span.end);
11221122
}
11231123

11241124
fn visit_export_named_declaration(&mut self, decl: &mut ExportNamedDeclaration<'a>) {
@@ -1143,9 +1143,9 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
11431143
}
11441144
}
11451145

1146-
fn visit_export_specifier(&mut self, it: &mut ExportSpecifier<'a>) {
1147-
self.convert_offset(&mut it.span.start);
1148-
match (&mut it.local, &mut it.exported) {
1146+
fn visit_export_specifier(&mut self, specifier: &mut ExportSpecifier<'a>) {
1147+
self.convert_offset(&mut specifier.span.start);
1148+
match (&mut specifier.local, &mut specifier.exported) {
11491149
(
11501150
ModuleExportName::IdentifierReference(local),
11511151
ModuleExportName::IdentifierName(exported),
@@ -1171,36 +1171,36 @@ impl<'a> VisitMut<'a> for Utf8ToUtf16Converter<'_> {
11711171
self.visit_module_export_name(exported);
11721172
}
11731173
}
1174-
self.convert_offset(&mut it.span.end);
1174+
self.convert_offset(&mut specifier.span.end);
11751175
}
11761176

1177-
fn visit_import_specifier(&mut self, it: &mut ImportSpecifier<'a>) {
1178-
self.convert_offset(&mut it.span.start);
1179-
match &mut it.imported {
1180-
ModuleExportName::IdentifierName(imported) if imported.span == it.local.span => {
1177+
fn visit_import_specifier(&mut self, specifier: &mut ImportSpecifier<'a>) {
1178+
self.convert_offset(&mut specifier.span.start);
1179+
match &mut specifier.imported {
1180+
ModuleExportName::IdentifierName(imported) if imported.span == specifier.local.span => {
11811181
self.visit_identifier_name(imported);
1182-
it.local.span = imported.span;
1182+
specifier.local.span = imported.span;
11831183
}
11841184
imported => {
11851185
self.visit_module_export_name(imported);
1186-
self.visit_binding_identifier(&mut it.local);
1186+
self.visit_binding_identifier(&mut specifier.local);
11871187
}
11881188
}
1189-
self.convert_offset(&mut it.span.end);
1189+
self.convert_offset(&mut specifier.span.end);
11901190
}
11911191

1192-
fn visit_with_clause(&mut self, it: &mut WithClause<'a>) {
1193-
self.visit_import_attributes(&mut it.with_entries);
1192+
fn visit_with_clause(&mut self, with_clause: &mut WithClause<'a>) {
1193+
self.visit_import_attributes(&mut with_clause.with_entries);
11941194
}
11951195

1196-
fn visit_template_literal(&mut self, it: &mut TemplateLiteral<'a>) {
1197-
self.convert_offset(&mut it.span.start);
1198-
for (quasi, expression) in it.quasis.iter_mut().zip(&mut it.expressions) {
1196+
fn visit_template_literal(&mut self, lit: &mut TemplateLiteral<'a>) {
1197+
self.convert_offset(&mut lit.span.start);
1198+
for (quasi, expression) in lit.quasis.iter_mut().zip(&mut lit.expressions) {
11991199
self.visit_template_element(quasi);
12001200
self.visit_expression(expression);
12011201
}
1202-
self.visit_template_element(it.quasis.last_mut().unwrap());
1203-
self.convert_offset(&mut it.span.end);
1202+
self.visit_template_element(lit.quasis.last_mut().unwrap());
1203+
self.convert_offset(&mut lit.span.end);
12041204
}
12051205
}
12061206

tasks/ast_tools/src/generators/utf8_to_utf16.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
9696
#(#methods)*
9797

9898
///@@line_break
99-
fn visit_object_property(&mut self, it: &mut ObjectProperty<'a>) {
100-
self.convert_offset(&mut it.span.start);
99+
fn visit_object_property(&mut self, prop: &mut ObjectProperty<'a>) {
100+
self.convert_offset(&mut prop.span.start);
101101

102102
// If shorthand, span of `key` and `value` are the same
103-
match (it.shorthand, &mut it.key, &mut it.value) {
103+
match (prop.shorthand, &mut prop.key, &mut prop.value) {
104104
(true, PropertyKey::StaticIdentifier(key), Expression::Identifier(value)) => {
105105
self.visit_identifier_name(key);
106106
value.span = key.span;
@@ -111,15 +111,15 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
111111
}
112112
}
113113

114-
self.convert_offset(&mut it.span.end);
114+
self.convert_offset(&mut prop.span.end);
115115
}
116116

117117
///@@line_break
118-
fn visit_binding_property(&mut self, it: &mut BindingProperty<'a>) {
119-
self.convert_offset(&mut it.span.start);
118+
fn visit_binding_property(&mut self, prop: &mut BindingProperty<'a>) {
119+
self.convert_offset(&mut prop.span.start);
120120

121121
// If shorthand, span of `key` and `value` are the same
122-
match (it.shorthand, &mut it.key, &mut it.value) {
122+
match (prop.shorthand, &mut prop.key, &mut prop.value) {
123123
(
124124
true,
125125
PropertyKey::StaticIdentifier(key),
@@ -142,7 +142,7 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
142142
}
143143
}
144144

145-
self.convert_offset(&mut it.span.end);
145+
self.convert_offset(&mut prop.span.end);
146146
}
147147

148148
///@@line_break
@@ -170,14 +170,14 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
170170
}
171171

172172
///@@line_break
173-
fn visit_export_specifier(&mut self, it: &mut ExportSpecifier<'a>) {
174-
self.convert_offset(&mut it.span.start);
173+
fn visit_export_specifier(&mut self, specifier: &mut ExportSpecifier<'a>) {
174+
self.convert_offset(&mut specifier.span.start);
175175

176176
// `local` and `exported` have same span if e.g.:
177177
// * `export {x}`
178178
// * `export {x} from 'foo.js;`
179179
// * `export {"a-b"} from 'foo.js';`
180-
match (&mut it.local, &mut it.exported) {
180+
match (&mut specifier.local, &mut specifier.exported) {
181181
(
182182
ModuleExportName::IdentifierReference(local),
183183
ModuleExportName::IdentifierName(exported),
@@ -205,48 +205,48 @@ fn generate(schema: &Schema, codegen: &Codegen) -> TokenStream {
205205
}
206206
}
207207

208-
self.convert_offset(&mut it.span.end);
208+
self.convert_offset(&mut specifier.span.end);
209209
}
210210

211211
///@@line_break
212-
fn visit_import_specifier(&mut self, it: &mut ImportSpecifier<'a>) {
213-
self.convert_offset(&mut it.span.start);
212+
fn visit_import_specifier(&mut self, specifier: &mut ImportSpecifier<'a>) {
213+
self.convert_offset(&mut specifier.span.start);
214214

215215
// `imported` and `local` have same span if e.g. `import {x} from 'foo';`
216-
match &mut it.imported {
217-
ModuleExportName::IdentifierName(imported) if imported.span == it.local.span => {
216+
match &mut specifier.imported {
217+
ModuleExportName::IdentifierName(imported) if imported.span == specifier.local.span => {
218218
self.visit_identifier_name(imported);
219-
it.local.span = imported.span;
219+
specifier.local.span = imported.span;
220220
}
221221
imported => {
222222
self.visit_module_export_name(imported);
223-
self.visit_binding_identifier(&mut it.local);
223+
self.visit_binding_identifier(&mut specifier.local);
224224
}
225225
}
226226

227-
self.convert_offset(&mut it.span.end);
227+
self.convert_offset(&mut specifier.span.end);
228228
}
229229

230230
///@@line_break
231-
fn visit_with_clause(&mut self, it: &mut WithClause<'a>) {
231+
fn visit_with_clause(&mut self, with_clause: &mut WithClause<'a>) {
232232
// `WithClause::attributes_keyword` has a span before start of the `WithClause`.
233233
// ESTree does not include that node, nor the span of the `WithClause` itself,
234234
// so skip processing those spans.
235-
self.visit_import_attributes(&mut it.with_entries);
235+
self.visit_import_attributes(&mut with_clause.with_entries);
236236
}
237237

238238
///@@line_break
239-
fn visit_template_literal(&mut self, it: &mut TemplateLiteral<'a>) {
240-
self.convert_offset(&mut it.span.start);
239+
fn visit_template_literal(&mut self, lit: &mut TemplateLiteral<'a>) {
240+
self.convert_offset(&mut lit.span.start);
241241

242242
// Visit `quasis` and `expressions` in source order. The two `Vec`s are interleaved.
243-
for (quasi, expression) in it.quasis.iter_mut().zip(&mut it.expressions) {
243+
for (quasi, expression) in lit.quasis.iter_mut().zip(&mut lit.expressions) {
244244
self.visit_template_element(quasi);
245245
self.visit_expression(expression);
246246
}
247-
self.visit_template_element(it.quasis.last_mut().unwrap());
247+
self.visit_template_element(lit.quasis.last_mut().unwrap());
248248

249-
self.convert_offset(&mut it.span.end);
249+
self.convert_offset(&mut lit.span.end);
250250
}
251251
}
252252

0 commit comments

Comments
 (0)