mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(printer) Print UnaryExpression (#1273)
This commit is contained in:
parent
a7acd07df8
commit
cef4c88579
1 changed files with 13 additions and 2 deletions
|
|
@ -8,7 +8,7 @@
|
|||
use oxc_allocator::{Box, Vec};
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_syntax::operator::BinaryOperator;
|
||||
use oxc_syntax::operator::{BinaryOperator, UnaryOperator};
|
||||
|
||||
use crate::{array, doc::Doc, format, group, hardline, indent, softline, string, Prettier};
|
||||
|
||||
|
|
@ -623,7 +623,18 @@ impl<'a> Format<'a> for UpdateExpression<'a> {
|
|||
|
||||
impl<'a> Format<'a> for UnaryExpression<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
Doc::Line
|
||||
let mut parts = p.vec();
|
||||
parts.push(string!(p, self.operator.as_str()));
|
||||
|
||||
if matches!(
|
||||
self.operator,
|
||||
UnaryOperator::Typeof | UnaryOperator::Void | UnaryOperator::Delete
|
||||
) {
|
||||
parts.push(string!(p, " "));
|
||||
}
|
||||
|
||||
parts.push(format!(p, self.argument));
|
||||
Doc::Array(parts)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue