@@ -74,45 +74,30 @@ impl<'a, 'b> SimpleArgument<'a, 'b> {
7474 }
7575
7676 fn is_simple_call_like_expression ( & self , depth : u8 ) -> bool {
77- if let Self :: Expression ( any_expression) = self {
78- if any_expression. is_call_like_expression ( ) {
79- let mut is_import_call_expression = false ;
80- let mut is_simple_callee = false ;
81- let arguments = match any_expression {
82- Expression :: NewExpression ( expr) => {
83- let callee = & expr. callee ;
84- is_simple_callee = Self :: from ( callee) . is_simple_impl ( depth) ;
85- & expr. arguments
86- }
87- Expression :: CallExpression ( expr) => {
88- let callee = & expr. callee ;
89- is_simple_callee = Self :: from ( callee) . is_simple_impl ( depth) ;
90- & expr. arguments
91- }
92- // Expression::ImportExpression(expr) => {
93- // is_import_call_expression = true;
94- // expr.arguments
95- // }
96- _ => unreachable ! ( "The check is done inside `is_call_like_expression`" ) ,
97- } ;
77+ let Self :: Expression ( expr) = self else {
78+ return false ;
79+ } ;
9880
99- if !is_import_call_expression && !is_simple_callee {
100- return false ;
101- }
81+ let mut is_simple_callee = false ;
10282
103- // This is a little awkward, but because we _increment_
104- // depth, we need to add it to the left and compare to the
105- // max we allow (2), versus just comparing `len <= depth`.
106- arguments. len ( ) + usize:: from ( depth) <= 2
107- && arguments
108- . iter ( )
109- . all ( |argument| Self :: new ( argument) . is_simple_impl ( depth + 1 ) )
110- } else {
111- false
83+ let ( callee, arguments) = match expr {
84+ Expression :: NewExpression ( expr) => ( & expr. callee , & expr. arguments ) ,
85+ Expression :: CallExpression ( expr) => ( & expr. callee , & expr. arguments ) ,
86+ Expression :: ImportExpression ( expr) => {
87+ return depth < 2 && expr. options . is_none ( ) ;
11288 }
113- } else {
114- false
89+ _ => return false ,
90+ } ;
91+
92+ if !Self :: from ( callee) . is_simple_impl ( depth) {
93+ return false ;
11594 }
95+
96+ // This is a little awkward, but because we _increment_
97+ // depth, we need to add it to the left and compare to the
98+ // max we allow (2), versus just comparing `len <= depth`.
99+ arguments. len ( ) + usize:: from ( depth) <= 2
100+ && arguments. iter ( ) . all ( |argument| Self :: new ( argument) . is_simple_impl ( depth + 1 ) )
116101 }
117102
118103 fn is_simple_member_expression ( & self , depth : u8 ) -> bool {
0 commit comments