[−][src]Trait swc_common::comments::Comments
Stores comment.
Implementation notes
Methods uses (&self)
instead of (&mut self)
for some reasons. Firstly,
this is similar to the previous api. Secondly, typescript parser requires
backtracking, which requires Clone. To avoid cloning large vectors, we
must use Rc<RefCell(&self)
allows multi-threaded
use-cases such as swc itself.
We use Option instead of no-op Comments implementation to avoid allocation unless required.
Required methods
pub fn add_leading(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_leading_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_leading(&self, pos: BytePos) -> bool
[src]
pub fn move_leading(&self, from: BytePos, to: BytePos)
[src]
pub fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
pub fn add_trailing(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_trailing(&self, pos: BytePos) -> bool
[src]
pub fn move_trailing(&self, from: BytePos, to: BytePos)
[src]
pub fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
Implementations on Foreign Types
impl<T: ?Sized, '_> Comments for &'_ T where
T: Comments,
[src]
T: Comments,
pub fn add_leading(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_leading_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_leading(&self, pos: BytePos) -> bool
[src]
pub fn move_leading(&self, from: BytePos, to: BytePos)
[src]
pub fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
pub fn add_trailing(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_trailing(&self, pos: BytePos) -> bool
[src]
pub fn move_trailing(&self, from: BytePos, to: BytePos)
[src]
pub fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
impl<T: ?Sized> Comments for Arc<T> where
T: Comments,
[src]
T: Comments,
pub fn add_leading(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_leading_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_leading(&self, pos: BytePos) -> bool
[src]
pub fn move_leading(&self, from: BytePos, to: BytePos)
[src]
pub fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
pub fn add_trailing(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_trailing(&self, pos: BytePos) -> bool
[src]
pub fn move_trailing(&self, from: BytePos, to: BytePos)
[src]
pub fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
impl<T: ?Sized> Comments for Box<T> where
T: Comments,
[src]
T: Comments,
pub fn add_leading(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_leading_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_leading(&self, pos: BytePos) -> bool
[src]
pub fn move_leading(&self, from: BytePos, to: BytePos)
[src]
pub fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
pub fn add_trailing(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_trailing(&self, pos: BytePos) -> bool
[src]
pub fn move_trailing(&self, from: BytePos, to: BytePos)
[src]
pub fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
Implementors
impl Comments for SingleThreadedComments
[src]
pub fn add_leading(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_leading_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_leading(&self, pos: BytePos) -> bool
[src]
pub fn move_leading(&self, from: BytePos, to: BytePos)
[src]
pub fn take_leading(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
pub fn add_trailing(&self, pos: BytePos, cmt: Comment)
[src]
pub fn add_trailing_comments(&self, pos: BytePos, comments: Vec<Comment>)
[src]
pub fn has_trailing(&self, pos: BytePos) -> bool
[src]
pub fn move_trailing(&self, from: BytePos, to: BytePos)
[src]
pub fn take_trailing(&self, pos: BytePos) -> Option<Vec<Comment>>
[src]
impl<T: ?Sized> Comments for Rc<T> where
T: Comments,
[src]
T: Comments,