From 064416c0797ac16323ef8220481af91d2ade14bd Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 4 Aug 2021 00:36:49 -0400 Subject: [PATCH] feat(common): Add an utiliy method for comments (#2002) swc_common: - Add `SingleThreadedComments::from_leading_and_trailing`. --- common/Cargo.toml | 2 +- common/src/comments.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/Cargo.toml b/common/Cargo.toml index 72f98499c27..ae6f44ab26b 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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"] diff --git a/common/src/comments.rs b/common/src/comments.rs index e37cc1ffdd3..607c7acfeb9 100644 --- a/common/src/comments.rs +++ b/common/src/comments.rs @@ -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)