@@ -160,31 +160,31 @@ fn make_fn_insertions(span: impl GetSpan) -> (Insertion, Insertion) {
160
160
const _asynchronousReturnValue = (async () => {
161
161
try {"# ,
162
162
r#"
163
- } catch (err) {
164
- if (_functionState === 'sync') {
165
- /* Forward synchronous exceptions. */
166
- _synchronousReturnValue = err;
167
- _functionState = 'threw';
168
- } else {
169
- throw err;
170
- }
171
- } finally {
172
- if (_functionState !== 'threw') {
173
- _functionState = 'returned';
174
- }
163
+ } catch (err) {
164
+ if (_functionState === 'sync') {
165
+ /* Forward synchronous exceptions. */
166
+ _synchronousReturnValue = err;
167
+ _functionState = 'threw';
168
+ } else {
169
+ throw err;
170
+ }
171
+ } finally {
172
+ if (_functionState !== 'threw') {
173
+ _functionState = 'returned';
175
174
}
175
+ }
176
176
177
- })();
177
+ })();
178
178
179
- if (_functionState === 'returned') {
180
- return _synchronousReturnValue;
181
- } else if (_functionState === 'threw') {
182
- throw _synchronousReturnValue;
183
- }
179
+ if (_functionState === 'returned') {
180
+ return _synchronousReturnValue;
181
+ } else if (_functionState === 'threw') {
182
+ throw _synchronousReturnValue;
183
+ }
184
184
185
- _functionState = 'async';
186
- return _markSyntheticPromise(_asynchronousReturnValue);
187
- "# ,
185
+ _functionState = 'async';
186
+ return _markSyntheticPromise(_asynchronousReturnValue);
187
+ "# ,
188
188
)
189
189
}
190
190
@@ -239,7 +239,11 @@ enum AnyFunctionParent<'a> {
239
239
240
240
/// Collect all insertions for a given node.
241
241
/// This is the main function that does the work of rewriting the source code.
242
- fn collect_insertions ( node : & AstNode , semantic : & Semantic , debug_level : DebugLevel ) -> Result < InsertionList , & ' static str > {
242
+ fn collect_insertions (
243
+ node : & AstNode ,
244
+ semantic : & Semantic ,
245
+ debug_level : DebugLevel ,
246
+ ) -> Result < InsertionList , & ' static str > {
243
247
let ast_nodes = & semantic. nodes ( ) ;
244
248
// Look up the nearest function parent, if any.
245
249
let function_parent = & ast_nodes
@@ -294,11 +298,11 @@ fn collect_insertions(node: &AstNode, semantic: &Semantic, debug_level: DebugLev
294
298
Some ( name) => {
295
299
// `function foo() {}` -> `var foo; ... function foo__() {}; _cr = foo = foo__;`
296
300
// so that if somebody writes `function foo() {}` we consider it a valid completion record.
297
- insertions. push_pair (
298
- Insertion :: pair (
299
- Span :: new ( name . span ( ) . end , span . end ) ,
300
- "__" ,
301
- format ! ( "; \n _cr = {name} = {name}__; \n " , name = name . name . as_str ( ) ) ) ) ;
301
+ insertions. push_pair ( Insertion :: pair (
302
+ Span :: new ( name . span ( ) . end , span . end ) ,
303
+ "__" ,
304
+ format ! ( "; \n _cr = {name} = {name}__; \n " , name = name . name . as_str ( ) ) ,
305
+ ) ) ;
302
306
insertions. add_variable ( name. to_string ( ) ) ;
303
307
}
304
308
}
@@ -521,7 +525,11 @@ pub fn async_rewrite(input: &str, debug_level: DebugLevel) -> Result<String, Str
521
525
let mut insertions = InsertionList :: new ( ) ;
522
526
let mut collected_insertions = InsertionList :: new ( ) ;
523
527
for node in semantic_ret. semantic . nodes ( ) {
524
- collected_insertions. append ( & mut collect_insertions ( node, & semantic_ret. semantic , debug_level) ?) ;
528
+ collected_insertions. append ( & mut collect_insertions (
529
+ node,
530
+ & semantic_ret. semantic ,
531
+ debug_level,
532
+ ) ?) ;
525
533
}
526
534
{
527
535
let vars = & collected_insertions. vars ;
0 commit comments