Skip to content

Commit 0d23774

Browse files
committed
refactor(formatter): remove unneeded JoinBuilder::finish and JoinNodesBuilder::finish methods (#16146)
No longer needed
1 parent 9317ebc commit 0d23774

23 files changed

+116
-136
lines changed

crates/oxc_formatter/src/formatter/builders.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,12 +2360,6 @@ where
23602360

23612361
self
23622362
}
2363-
2364-
/// Finishes the output and returns any error encountered.
2365-
#[expect(clippy::unused_self)]
2366-
pub fn finish(&self) {
2367-
// TODO: remove this method
2368-
}
23692363
}
23702364

23712365
/// Builder to join together nodes that ensures that nodes separated by empty lines continue
@@ -2437,11 +2431,6 @@ where
24372431
self
24382432
}
24392433

2440-
#[expect(clippy::unused_self)]
2441-
pub fn finish(&self) {
2442-
// TODO: remove this method
2443-
}
2444-
24452434
/// Get the number of line breaks between two consecutive SyntaxNodes in the tree
24462435
pub fn has_lines_before(&self, span: Span) -> bool {
24472436
self.fmt.source_text().get_lines_before(span, self.fmt.comments()) > 1

crates/oxc_formatter/src/formatter/printer/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,10 +1738,10 @@ Group 1 breaks"
17381738
[group(&format_args!(
17391739
token("["),
17401740
soft_block_indent(&format_args!(
1741-
format_with(|f| f
1742-
.join_with(format_args!(token(","), soft_line_break_or_space()))
1743-
.entries(&self.items)
1744-
.finish()),
1741+
format_with(|f| {
1742+
f.join_with(format_args!(token(","), soft_line_break_or_space()))
1743+
.entries(&self.items);
1744+
}),
17451745
if_group_breaks(&token(",")),
17461746
)),
17471747
token("]")

crates/oxc_formatter/src/utils/array.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ pub fn write_array_node<'a, 'b, N>(
8282
}),
8383
);
8484
}
85-
86-
join.finish();
8785
}
8886

8987
/// Determines if a trailing separator should be inserted after an array element

crates/oxc_formatter/src/utils/member_chain/groups.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a, 'b> TailChainGroups<'a, 'b> {
113113

114114
impl<'a> Format<'a> for TailChainGroups<'a, '_> {
115115
fn fmt(&self, f: &mut Formatter<'_, 'a>) {
116-
f.join().entries(self.groups.iter()).finish();
116+
f.join().entries(self.groups.iter());
117117
}
118118
}
119119

@@ -248,6 +248,6 @@ pub struct FormatMemberChainGroup<'a, 'b> {
248248

249249
impl<'a> Format<'a> for FormatMemberChainGroup<'a, '_> {
250250
fn fmt(&self, f: &mut Formatter<'_, 'a>) {
251-
f.join().entries(self.group.members.iter()).finish();
251+
f.join().entries(self.group.members.iter());
252252
}
253253
}

crates/oxc_formatter/src/utils/member_chain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'a> Format<'a> for MemberChain<'a, '_> {
200200
fn fmt(&self, f: &mut Formatter<'_, 'a>) {
201201
let has_comment = self.has_comment(f);
202202
let format_one_line = format_with(|f| {
203-
f.join().entries(iter::once(&self.head).chain(self.tail.iter())).finish();
203+
f.join().entries(iter::once(&self.head).chain(self.tail.iter()));
204204
});
205205

206206
self.inspect_member_chain_groups(f);

crates/oxc_formatter/src/write/assignment_pattern_property_list.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ impl<'a> Format<'a> for AssignmentTargetPropertyList<'a, '_> {
7070
} else {
7171
FormatTrailingCommas::ES5.trailing_separator(f.options())
7272
};
73-
f.join_nodes_with_soft_line()
74-
.entries_with_trailing_separator(
75-
AssignmentTargetPropertyListIter {
76-
properties: self.properties.iter(),
77-
rest: self.rest,
78-
},
79-
",",
80-
trailing_separator,
81-
)
82-
.finish();
73+
f.join_nodes_with_soft_line().entries_with_trailing_separator(
74+
AssignmentTargetPropertyListIter {
75+
properties: self.properties.iter(),
76+
rest: self.rest,
77+
},
78+
",",
79+
trailing_separator,
80+
);
8381
}
8482
}

crates/oxc_formatter/src/write/binary_like_expression.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ impl<'a> Format<'a> for BinaryLikeExpression<'a, '_> {
250250
if (inline_logical_expression && !flattened)
251251
|| (!inline_logical_expression && should_indent_if_inlines)
252252
{
253-
return write!(f, [group(&format_once(|f| { f.join().entries(parts).finish() }))]);
253+
return write!(
254+
f,
255+
[group(&format_once(|f| {
256+
f.join().entries(parts);
257+
}))]
258+
);
254259
}
255260

256261
// `parts` is guaranteed to have at least 2 elements (Left + Right)
@@ -267,7 +272,9 @@ impl<'a> Format<'a> for BinaryLikeExpression<'a, '_> {
267272
f,
268273
[group(&format_args!(
269274
first,
270-
indent(&format_with(|f| { f.join().entries(tail_parts.iter()).finish() }))
275+
indent(&format_with(|f| {
276+
f.join().entries(tail_parts.iter());
277+
}))
271278
))
272279
.with_group_id(Some(group_id))]
273280
);

crates/oxc_formatter/src/write/binding_property_list.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ impl<'a> Format<'a> for BindingPropertyList<'a, '_> {
7171
FormatTrailingCommas::ES5.trailing_separator(f.options())
7272
};
7373

74-
f.join_nodes_with_soft_line()
75-
.entries_with_trailing_separator(
76-
BindingPropertyListIter { properties: self.properties.iter(), rest: self.rest },
77-
",",
78-
trailing_separator,
79-
)
80-
.finish();
74+
f.join_nodes_with_soft_line().entries_with_trailing_separator(
75+
BindingPropertyListIter { properties: self.properties.iter(), rest: self.rest },
76+
",",
77+
trailing_separator,
78+
);
8179
}
8280
}

crates/oxc_formatter/src/write/block_statement.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ use crate::{
1111

1212
impl<'a> Format<'a> for AstNode<'a, Vec<'a, Statement<'a>>> {
1313
fn fmt(&self, f: &mut Formatter<'_, 'a>) {
14-
f.join_nodes_with_hardline()
15-
.entries(
16-
self.iter().filter(|stmt| !matches!(stmt.as_ref(), Statement::EmptyStatement(_))),
17-
)
18-
.finish();
14+
f.join_nodes_with_hardline().entries(
15+
self.iter().filter(|stmt| !matches!(stmt.as_ref(), Statement::EmptyStatement(_))),
16+
);
1917
}
2018
}
2119

crates/oxc_formatter/src/write/call_arguments.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ impl<'a> Format<'a> for AstNode<'a, ArenaVec<'a, Argument<'a>>> {
8787
[
8888
l_paren_token,
8989
format_with(|f| {
90-
f.join_with(space())
91-
.entries_with_trailing_separator(
92-
self.iter(),
93-
",",
94-
TrailingSeparator::Omit,
95-
)
96-
.finish();
90+
f.join_with(space()).entries_with_trailing_separator(
91+
self.iter(),
92+
",",
93+
TrailingSeparator::Omit,
94+
);
9795
}),
9896
r_paren_token
9997
]
@@ -131,9 +129,11 @@ impl<'a> Format<'a> for AstNode<'a, ArenaVec<'a, Argument<'a>>> {
131129
[
132130
l_paren_token,
133131
soft_block_indent(&format_with(|f| {
134-
f.join_with(soft_line_break_or_space())
135-
.entries_with_trailing_separator(self.iter(), ",", trailing_operator)
136-
.finish();
132+
f.join_with(soft_line_break_or_space()).entries_with_trailing_separator(
133+
self.iter(),
134+
",",
135+
trailing_operator,
136+
);
137137
})),
138138
r_paren_token,
139139
]
@@ -813,8 +813,6 @@ fn write_grouped_arguments<'a>(
813813
}));
814814
}
815815
}
816-
817-
joiner.finish();
818816
}),
819817
")"
820818
]
@@ -841,15 +839,15 @@ fn write_grouped_arguments<'a>(
841839
[
842840
"(",
843841
format_once(|f| {
844-
f.join_with(soft_line_break_or_space())
845-
.entries(grouped.into_iter().map(|(element, _)| {
842+
f.join_with(soft_line_break_or_space()).entries(grouped.into_iter().map(
843+
|(element, _)| {
846844
format_once(move |f| {
847845
if let Some(element) = element {
848846
f.write_element(element);
849847
}
850848
})
851-
}))
852-
.finish();
849+
},
850+
));
853851
}),
854852
")",
855853
]

0 commit comments

Comments
 (0)