Skip to content

Commit a58ec2a

Browse files
committed
refactor(formatter): remove all without_parentheses usages
1 parent f162da8 commit a58ec2a

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

crates/oxc_formatter/src/parentheses/expression.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl NeedsParentheses<'_> for AstNode<'_, NumericLiteral<'_>> {
197197
}
198198

199199
if let AstNodes::StaticMemberExpression(member) = self.parent {
200-
return member.object.without_parentheses().span() == self.span();
200+
return member.object.span() == self.span();
201201
}
202202
false
203203
}
@@ -491,7 +491,7 @@ impl NeedsParentheses<'_> for AstNode<'_, ConditionalExpression<'_>> {
491491
return true;
492492
}
493493
if let AstNodes::ConditionalExpression(e) = parent {
494-
e.test.without_parentheses().span() == self.span()
494+
e.test.span() == self.span()
495495
} else {
496496
update_or_lower_expression_needs_parens(self.span(), parent)
497497
}
@@ -705,7 +705,7 @@ impl NeedsParentheses<'_> for AstNode<'_, ArrowFunctionExpression<'_>> {
705705
return true;
706706
}
707707
if let AstNodes::ConditionalExpression(e) = parent {
708-
e.test.without_parentheses().span() == self.span()
708+
e.test.span() == self.span()
709709
} else {
710710
update_or_lower_expression_needs_parens(self.span(), parent)
711711
}
@@ -1075,7 +1075,7 @@ fn await_or_yield_needs_parens(span: Span, node: &AstNodes<'_>) -> bool {
10751075
return true;
10761076
}
10771077
if let AstNodes::ConditionalExpression(e) = node {
1078-
e.test.without_parentheses().span() == span
1078+
e.test.span() == span
10791079
} else {
10801080
update_or_lower_expression_needs_parens(span, node)
10811081
}
@@ -1102,7 +1102,7 @@ fn ts_as_or_satisfies_needs_parens(
11021102

11031103
fn is_class_extends(span: Span, parent: &AstNodes<'_>) -> bool {
11041104
if let AstNodes::Class(c) = parent {
1105-
return c.super_class.as_ref().is_some_and(|c| c.without_parentheses().span() == span);
1105+
return c.super_class.as_ref().is_some_and(|c| c.span() == span);
11061106
}
11071107
false
11081108
}

crates/oxc_formatter/src/write/binary_like_expression.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,8 @@ impl<'a> Format<'a> for BinaryLikeExpression<'a, '_> {
227227
// For example, `(a+b)(call)`, `!(a + b)`, `(a + b).test`.
228228
let is_inside_parenthesis = match parent {
229229
AstNodes::StaticMemberExpression(_) | AstNodes::UnaryExpression(_) => true,
230-
AstNodes::CallExpression(call) => {
231-
call.callee().without_parentheses().span() == self.span()
232-
}
233-
AstNodes::NewExpression(new) => {
234-
new.callee().without_parentheses().span() == self.span()
235-
}
230+
AstNodes::CallExpression(call) => call.callee().span() == self.span(),
231+
AstNodes::NewExpression(new) => new.callee().span() == self.span(),
236232
_ => false,
237233
};
238234

0 commit comments

Comments
 (0)