feat(common): Add an utiliy method for comments (#2002)

swc_common:
 - Add `SingleThreadedComments::from_leading_and_trailing`.
This commit is contained in:
David Sherret 2021-08-04 00:36:49 -04:00 committed by GitHub
parent 080b1fa3ac
commit 064416c079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_common"
repository = "https://github.com/swc-project/swc.git"
version = "0.11.3"
version = "0.11.4"
[features]
concurrent = ["parking_lot"]

View File

@ -230,6 +230,15 @@ impl Comments for SingleThreadedComments {
}
impl SingleThreadedComments {
/// Creates a new `SingleThreadedComments` from the provided leading and
/// trailing.
pub fn from_leading_and_trailing(
leading: SingleThreadedCommentsMap,
trailing: SingleThreadedCommentsMap,
) -> Self {
SingleThreadedComments { leading, trailing }
}
/// Takes all the comments as (leading, trailing).
pub fn take_all(self) -> (SingleThreadedCommentsMap, SingleThreadedCommentsMap) {
(self.leading, self.trailing)