File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
crates/oxc_estree/src/serialize Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ use oxc_data_structures::code_buffer::CodeBuffer;
22
33/// Formatter trait.
44pub trait Formatter {
5+ /// `true` if formatter produces compact JSON (not pretty-printed JSON).
6+ const IS_COMPACT : bool ;
7+
58 /// Create new [`Formatter`].
69 fn new ( ) -> Self ;
710
@@ -30,6 +33,8 @@ pub trait Formatter {
3033pub struct CompactFormatter ;
3134
3235impl Formatter for CompactFormatter {
36+ const IS_COMPACT : bool = true ;
37+
3338 #[ inline( always) ]
3439 fn new ( ) -> Self {
3540 Self
@@ -71,6 +76,8 @@ pub struct PrettyFormatter {
7176}
7277
7378impl Formatter for PrettyFormatter {
79+ const IS_COMPACT : bool = false ;
80+
7481 #[ inline( always) ]
7582 fn new ( ) -> Self {
7683 Self { indent : 0 }
Original file line number Diff line number Diff line change @@ -35,9 +35,12 @@ pub trait ESTree {
3535
3636/// Trait for serializers.
3737pub trait Serializer {
38- /// `true` if output should contain TS fields
38+ /// `true` if output should contain TS fields.
3939 const INCLUDE_TS_FIELDS : bool ;
4040
41+ /// `true` if serializer's formatter produces compact JSON (not pretty-printed JSON).
42+ const IS_COMPACT : bool = Self :: Formatter :: IS_COMPACT ;
43+
4144 /// Type of `Formatter` this serializer uses.
4245 type Formatter : Formatter ;
4346
You can’t perform that action at this time.
0 commit comments