Skip to content

Commit

Permalink
fix(es/utils): Fix macros (#2349)
Browse files Browse the repository at this point in the history
swc_ecma_utils:
 - Allow using macros from crates using `swc_ecmascript`.
  • Loading branch information
kdy1 authored Oct 5, 2021
1 parent 8403057 commit b64afb5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecmascript/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_utils"
repository = "https://github.com/swc-project/swc.git"
version = "0.46.1"
version = "0.46.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
3 changes: 3 additions & 0 deletions ecmascript/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[doc(hidden)]
pub extern crate swc_ecma_ast;

pub use self::{
factory::ExprFactory,
ident::{id, Id},
Expand Down
14 changes: 7 additions & 7 deletions ecmascript/utils/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro_rules! private_ident {
use swc_common::Mark;
let mark = Mark::fresh(Mark::root());
let span = $span.apply_mark(mark);
::swc_ecma_ast::Ident::new($s.into(), span)
$crate::swc_ecma_ast::Ident::new($s.into(), span)
}};
}

Expand All @@ -18,7 +18,7 @@ macro_rules! quote_ident {
quote_ident!(::swc_common::DUMMY_SP, $s)
};
($span:expr, $s:expr) => {{
::swc_ecma_ast::Ident::new($s.into(), $span)
$crate::swc_ecma_ast::Ident::new($s.into(), $span)
}};
}

Expand All @@ -28,7 +28,7 @@ macro_rules! quote_str {
quote_str!(::swc_common::DUMMY_SP, $s)
};
($span:expr, $s:expr) => {{
::swc_ecma_ast::Str {
$crate::swc_ecma_ast::Str {
span: $span,
value: $s.into(),
has_escape: false,
Expand All @@ -40,7 +40,7 @@ macro_rules! quote_str {
#[macro_export]
macro_rules! quote_expr {
($span:expr, null) => {{
use swc_ecma_ast::*;
use $crate::swc_ecma_ast::*;
Expr::Lit(Lit::Null(Null { span: $span }))
}};

Expand All @@ -60,7 +60,7 @@ macro_rules! quote_expr {
#[macro_export]
macro_rules! member_expr {
($span:expr, $first:ident) => {{
use swc_ecma_ast::Expr;
use $crate::swc_ecma_ast::Expr;
Box::new(Expr::Ident($crate::quote_ident!($span, stringify!($first))))
}};

Expand All @@ -75,14 +75,14 @@ macro_rules! member_expr {

member_expr!(@EXT, $span, Box::new(Expr::Member(MemberExpr{
span: ::swc_common::DUMMY_SP,
obj: ExprOrSuper::Expr($obj),
obj: $crate::swc_ecma_ast::ExprOrSuper::Expr($obj),
computed: false,
prop,
})), $($rest)*)
}};

(@EXT, $span:expr, $obj:expr, $first:ident) => {{
use swc_ecma_ast::*;
use $crate::swc_ecma_ast::*;
let prop = member_expr!($span, $first);

Box::new(Expr::Member(MemberExpr{
Expand Down

0 comments on commit b64afb5

Please sign in to comment.