diff --git a/crates/oxc_ast/src/ast/comment.rs b/crates/oxc_ast/src/ast/comment.rs index f3edd2cfe5e0c..0b47c39420926 100644 --- a/crates/oxc_ast/src/ast/comment.rs +++ b/crates/oxc_ast/src/ast/comment.rs @@ -249,26 +249,6 @@ impl Comment { self.annotation == CommentAnnotation::CoverageIgnore && self.is_leading() } - /// Sets the state of `newlines` to include/exclude a newline after the comment. - #[inline] - pub fn set_followed_by_newline(&mut self, followed_by_newline: bool) { - if followed_by_newline { - self.newlines.insert(CommentNewlines::Trailing); - } else { - self.newlines.remove(CommentNewlines::Trailing); - } - } - - /// Sets the state of `newlines` to include/exclude a newline before the comment. - #[inline] - pub fn set_preceded_by_newline(&mut self, preceded_by_newline: bool) { - if preceded_by_newline { - self.newlines.insert(CommentNewlines::Leading); - } else { - self.newlines.remove(CommentNewlines::Leading); - } - } - /// Returns `true` if this comment is preceded by a newline. #[inline] pub fn preceded_by_newline(self) -> bool { @@ -280,4 +260,16 @@ impl Comment { pub fn followed_by_newline(self) -> bool { self.newlines.contains(CommentNewlines::Trailing) } + + /// Sets the state of `newlines` to include/exclude a newline before the comment. + #[inline] + pub fn set_preceded_by_newline(&mut self, preceded_by_newline: bool) { + self.newlines.set(CommentNewlines::Leading, preceded_by_newline); + } + + /// Sets the state of `newlines` to include/exclude a newline after the comment. + #[inline] + pub fn set_followed_by_newline(&mut self, followed_by_newline: bool) { + self.newlines.set(CommentNewlines::Trailing, followed_by_newline); + } }