diff --git a/crates/oxc_estree/src/serialize/config.rs b/crates/oxc_estree/src/serialize/config.rs index 6b615191c5e90..25c54f06cc995 100644 --- a/crates/oxc_estree/src/serialize/config.rs +++ b/crates/oxc_estree/src/serialize/config.rs @@ -7,7 +7,7 @@ pub trait Config { fn new(ranges: bool) -> Self; - /// Whether to include range information in the serialized output + /// Get whether output should contain `range` fields. fn ranges(&self) -> bool; } diff --git a/crates/oxc_estree/src/serialize/mod.rs b/crates/oxc_estree/src/serialize/mod.rs index fc5fbda09a34e..e58232f61ad71 100644 --- a/crates/oxc_estree/src/serialize/mod.rs +++ b/crates/oxc_estree/src/serialize/mod.rs @@ -44,6 +44,7 @@ pub trait Serializer: SerializerPrivate { /// Type of sequence serializer this serializer uses. type SequenceSerializer: SequenceSerializer; + /// Get whether output should contain `range` fields. fn ranges(&self) -> bool; /// Serialize struct. @@ -180,6 +181,7 @@ impl<'s, C: Config, F: Formatter> Serializer for &'s mut ESTreeSerializer type StructSerializer = ESTreeStructSerializer<'s, C, F>; type SequenceSerializer = ESTreeSequenceSerializer<'s, C, F>; + /// Get whether output should contain `range` fields. #[inline(always)] fn ranges(&self) -> bool { self.config.ranges() diff --git a/crates/oxc_estree/src/serialize/structs.rs b/crates/oxc_estree/src/serialize/structs.rs index 8a96b16314ed9..711bfd551130a 100644 --- a/crates/oxc_estree/src/serialize/structs.rs +++ b/crates/oxc_estree/src/serialize/structs.rs @@ -40,7 +40,7 @@ pub trait StructSerializer { /// Finish serializing struct. fn end(self); - /// Whether to include range information in the serialized output + /// Get whether output should contain `range` fields. fn ranges(&self) -> bool; } @@ -150,6 +150,7 @@ impl StructSerializer for ESTreeStructSerializer<'_, C, buffer.print_ascii_byte(b'}'); } + /// Get whether output should contain `range` fields. #[inline(always)] fn ranges(&self) -> bool { self.serializer.ranges() @@ -224,6 +225,7 @@ impl<'p, P: StructSerializer> Serializer for FlatStructSerializer<'p, P> { } } + /// Get whether output should contain `range` fields. #[inline(always)] fn ranges(&self) -> bool { self.0.ranges() @@ -294,6 +296,7 @@ impl StructSerializer for FlatStructSerializer<'_, P> { // No-op - there may be more fields to be added to the struct in the parent } + /// Get whether output should contain `range` fields. #[inline(always)] fn ranges(&self) -> bool { self.0.ranges()