Skip to content

Commit 1815d8d

Browse files
committed
refactor(formatter): revert all changes from removing AstKind::Argument
1 parent d493d78 commit 1815d8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1960
-1650
lines changed

crates/oxc_formatter/src/ast_nodes/generated/format.rs

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,21 +2853,14 @@ impl<'a> Format<'a> for AstNode<'a, RegExpLiteral<'a>> {
28532853

28542854
impl<'a> Format<'a> for AstNode<'a, JSXElement<'a>> {
28552855
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
2856-
let is_suppressed = f.comments().is_suppressed(self.span().start);
2857-
if !is_suppressed && format_type_cast_comment_node(self, false, f)? {
2856+
if format_type_cast_comment_node(self, false, f)? {
28582857
return Ok(());
28592858
}
2860-
let needs_parentheses = !is_suppressed && self.needs_parentheses(f);
2859+
let needs_parentheses = self.needs_parentheses(f);
28612860
if needs_parentheses {
28622861
"(".fmt(f)?;
28632862
}
2864-
let result = if is_suppressed {
2865-
self.format_leading_comments(f)?;
2866-
FormatSuppressedNode(self.span()).fmt(f)?;
2867-
self.format_trailing_comments(f)
2868-
} else {
2869-
self.write(f)
2870-
};
2863+
let result = self.write(f);
28712864
if needs_parentheses {
28722865
")".fmt(f)?;
28732866
}
@@ -2899,21 +2892,14 @@ impl<'a> Format<'a> for AstNode<'a, JSXClosingElement<'a>> {
28992892

29002893
impl<'a> Format<'a> for AstNode<'a, JSXFragment<'a>> {
29012894
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
2902-
let is_suppressed = f.comments().is_suppressed(self.span().start);
2903-
if !is_suppressed && format_type_cast_comment_node(self, false, f)? {
2895+
if format_type_cast_comment_node(self, false, f)? {
29042896
return Ok(());
29052897
}
2906-
let needs_parentheses = !is_suppressed && self.needs_parentheses(f);
2898+
let needs_parentheses = self.needs_parentheses(f);
29072899
if needs_parentheses {
29082900
"(".fmt(f)?;
29092901
}
2910-
let result = if is_suppressed {
2911-
self.format_leading_comments(f)?;
2912-
FormatSuppressedNode(self.span()).fmt(f)?;
2913-
self.format_trailing_comments(f)
2914-
} else {
2915-
self.write(f)
2916-
};
2902+
let result = self.write(f);
29172903
if needs_parentheses {
29182904
")".fmt(f)?;
29192905
}
@@ -4216,13 +4202,11 @@ impl<'a> Format<'a> for AstNode<'a, TSTypeAliasDeclaration<'a>> {
42164202
impl<'a> Format<'a> for AstNode<'a, TSClassImplements<'a>> {
42174203
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
42184204
let is_suppressed = f.comments().is_suppressed(self.span().start);
4219-
if is_suppressed {
4220-
self.format_leading_comments(f)?;
4221-
FormatSuppressedNode(self.span()).fmt(f)?;
4222-
self.format_trailing_comments(f)
4223-
} else {
4224-
self.write(f)
4225-
}
4205+
self.format_leading_comments(f)?;
4206+
let result =
4207+
if is_suppressed { FormatSuppressedNode(self.span()).fmt(f) } else { self.write(f) };
4208+
self.format_trailing_comments(f)?;
4209+
result
42264210
}
42274211
}
42284212

@@ -4818,13 +4802,11 @@ impl<'a> Format<'a> for AstNode<'a, TSNonNullExpression<'a>> {
48184802
impl<'a> Format<'a> for AstNode<'a, Decorator<'a>> {
48194803
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
48204804
let is_suppressed = f.comments().is_suppressed(self.span().start);
4821-
if is_suppressed {
4822-
self.format_leading_comments(f)?;
4823-
FormatSuppressedNode(self.span()).fmt(f)?;
4824-
self.format_trailing_comments(f)
4825-
} else {
4826-
self.write(f)
4827-
}
4805+
self.format_leading_comments(f)?;
4806+
let result =
4807+
if is_suppressed { FormatSuppressedNode(self.span()).fmt(f) } else { self.write(f) };
4808+
self.format_trailing_comments(f)?;
4809+
result
48284810
}
48294811
}
48304812

0 commit comments

Comments
 (0)