|
1 | 1 | use std::{borrow::Borrow, collections::VecDeque, fmt::Debug};
|
2 | 2 | use wasm_bindgen::prelude::*;
|
3 |
| -use rslint_parser::{ast::{ArrowExpr, AssignExpr, CallExpr, ClassDecl, Constructor, Expr, ExprOrBlock, ExprStmt, FnDecl, FnExpr, Method, NameRef, ObjectPatternProp, ParameterList, Pattern, PropName, ReturnStmt, ThisExpr, UnaryExpr, VarDecl}, parse_text, AstNode, SyntaxNode, TextSize}; |
| 3 | +use rslint_parser::{ast::{ArrowExpr, AssignExpr, CallExpr, ClassDecl, Constructor, Expr, ExprOrBlock, ExprStmt, FnDecl, FnExpr, Literal, Method, NameRef, ObjectPatternProp, ParameterList, Pattern, PropName, ReturnStmt, ThisExpr, UnaryExpr, VarDecl}, parse_text, AstNode, SyntaxNode, TextSize}; |
4 | 4 |
|
5 | 5 | #[derive(Debug)]
|
6 | 6 | enum InsertionText {
|
@@ -363,14 +363,17 @@ fn collect_insertions(node: &SyntaxNode, nesting_depth: u32) -> InsertionList {
|
363 | 363 | as_expr.syntax().text_range()) ||
|
364 | 364 | (is_unary_rhs && !is_typeof_rhs);
|
365 | 365 | let is_argument_default_value = ParameterList::can_cast(as_expr.syntax().parent().unwrap().parent().unwrap().kind());
|
| 366 | + let is_literal = Literal::can_cast(as_expr.syntax().kind()); |
| 367 | + let wants_implicit_await_wrapper = !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference && !is_literal; |
366 | 368 |
|
367 | 369 | if is_named_typeof_rhs {
|
368 | 370 | insertions.push_back(Insertion::new_dynamic(as_expr.syntax().parent().unwrap().text_range().start(), [
|
369 | 371 | "(typeof ", as_expr.syntax().text().to_string().as_str(), " === 'undefined' ? 'undefined' : "
|
370 | 372 | ].concat()));
|
371 | 373 | pushed_insertions += 1;
|
372 | 374 | }
|
373 |
| - if !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference { |
| 375 | + |
| 376 | + if wants_implicit_await_wrapper { |
374 | 377 | insertions.push_back(Insertion::new(range.start(), "(_ex = "));
|
375 | 378 | pushed_insertions += 1;
|
376 | 379 | }
|
@@ -410,7 +413,7 @@ fn collect_insertions(node: &SyntaxNode, nesting_depth: u32) -> InsertionList {
|
410 | 413 | insertions.append(child_insertions);
|
411 | 414 | },
|
412 | 415 | }
|
413 |
| - if !is_dot_call_expression && !is_lhs_of_assign_expr && !is_argument_default_value && !is_eval_this_super_reference { |
| 416 | + if wants_implicit_await_wrapper && !is_dot_call_expression { |
414 | 417 | insertions.push_back(Insertion::new(range.end(), ", _isp(_ex) ? await _ex : _ex)"));
|
415 | 418 | }
|
416 | 419 | if is_named_typeof_rhs {
|
|
0 commit comments