mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(prettier) print for of statements (#1385)
This commit is contained in:
parent
788e9b3807
commit
b613eab2f0
1 changed files with 20 additions and 2 deletions
|
|
@ -189,13 +189,31 @@ impl<'a> Format<'a> for ForInStatement<'a> {
|
|||
|
||||
impl<'a> Format<'a> for ForOfStatement<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
Doc::Line
|
||||
let mut parts = p.vec();
|
||||
|
||||
parts.push(ss!("for"));
|
||||
|
||||
if self.r#await {
|
||||
parts.push(ss!(" await"));
|
||||
}
|
||||
parts.push(ss!(" ("));
|
||||
parts.push(format!(p, self.left));
|
||||
parts.push(ss!(" of "));
|
||||
parts.push(format!(p, self.right));
|
||||
parts.push(ss!(")"));
|
||||
parts.push(format!(p, self.body));
|
||||
|
||||
Doc::Group(parts)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Format<'a> for ForStatementLeft<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
Doc::Line
|
||||
match self {
|
||||
ForStatementLeft::VariableDeclaration(v) => v.format(p),
|
||||
ForStatementLeft::AssignmentTarget(v) => v.format(p),
|
||||
ForStatementLeft::UsingDeclaration(v) => v.format(p),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue