mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 04:47:03 +03:00
Add a take_all() method to Comments. (#552)
This commit is contained in:
parent
4f76cddebd
commit
bac1cb52a3
@ -3,6 +3,7 @@ use crate::{
|
||||
syntax_pos::{BytePos, Span},
|
||||
};
|
||||
use chashmap::{CHashMap, ReadGuard};
|
||||
use std::collections::HashMap;
|
||||
|
||||
type CommentMap = CHashMap<BytePos, Vec<Comment>>;
|
||||
|
||||
@ -70,6 +71,19 @@ impl Comments {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes all the comments as (leading, trailing).
|
||||
pub fn take_all(
|
||||
self,
|
||||
) -> (
|
||||
HashMap<BytePos, Vec<Comment>>,
|
||||
HashMap<BytePos, Vec<Comment>>,
|
||||
) {
|
||||
(
|
||||
self.leading.into_iter().collect(),
|
||||
self.trailing.into_iter().collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
Loading…
Reference in New Issue
Block a user