Skip to content

Commit 0c167a9

Browse files
committed
fixup: fmt
1 parent 74b48d5 commit 0c167a9

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

packages/async-rewriter3/src/lib.rs

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,31 +160,31 @@ fn make_fn_insertions(span: impl GetSpan) -> (Insertion, Insertion) {
160160
const _asynchronousReturnValue = (async () => {
161161
try {"#,
162162
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';
175174
}
175+
}
176176
177-
})();
177+
})();
178178
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+
}
184184
185-
_functionState = 'async';
186-
return _markSyntheticPromise(_asynchronousReturnValue);
187-
"#,
185+
_functionState = 'async';
186+
return _markSyntheticPromise(_asynchronousReturnValue);
187+
"#,
188188
)
189189
}
190190

@@ -239,7 +239,11 @@ enum AnyFunctionParent<'a> {
239239

240240
/// Collect all insertions for a given node.
241241
/// 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> {
243247
let ast_nodes = &semantic.nodes();
244248
// Look up the nearest function parent, if any.
245249
let function_parent = &ast_nodes
@@ -294,11 +298,11 @@ fn collect_insertions(node: &AstNode, semantic: &Semantic, debug_level: DebugLev
294298
Some(name) => {
295299
// `function foo() {}` -> `var foo; ... function foo__() {}; _cr = foo = foo__;`
296300
// 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+
));
302306
insertions.add_variable(name.to_string());
303307
}
304308
}
@@ -521,7 +525,11 @@ pub fn async_rewrite(input: &str, debug_level: DebugLevel) -> Result<String, Str
521525
let mut insertions = InsertionList::new();
522526
let mut collected_insertions = InsertionList::new();
523527
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+
)?);
525533
}
526534
{
527535
let vars = &collected_insertions.vars;

packages/async-rewriter3/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ fn main() {
66

77
//std::fs::File::open("../../node_modules/sinon/pkg/sinon.js").unwrap()
88
std::io::stdin().read_to_string(&mut input).unwrap();
9-
println!("{}", async_rewrite(input.as_str(), DebugLevel::TypesOnly).unwrap());
9+
println!(
10+
"{}",
11+
async_rewrite(input.as_str(), DebugLevel::TypesOnly).unwrap()
12+
);
1013
}

0 commit comments

Comments
 (0)