mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 00:32:15 +03:00
pers(es/ast): Introduce IdentName
(#9185)
**Description:** The identifier in the `prop` field of `MemberExpr` does not need information like `optional` or `ctxt`.
This commit is contained in:
parent
b2491e5461
commit
7b3e5b3f61
@ -190,7 +190,7 @@ impl swc_bundler::Hook for Hook {
|
||||
|
||||
Ok(vec![
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("url".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("url".into(), span)),
|
||||
value: Box::new(Expr::Lit(Lit::Str(Str {
|
||||
span,
|
||||
raw: None,
|
||||
@ -198,7 +198,7 @@ impl swc_bundler::Hook for Hook {
|
||||
}))),
|
||||
},
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("main".into(), span)),
|
||||
value: Box::new(if module_record.is_entry {
|
||||
Expr::Member(MemberExpr {
|
||||
span,
|
||||
@ -206,7 +206,7 @@ impl swc_bundler::Hook for Hook {
|
||||
span,
|
||||
kind: MetaPropKind::ImportMeta,
|
||||
})),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
prop: MemberProp::Ident(IdentName::new("main".into(), span)),
|
||||
})
|
||||
} else {
|
||||
Expr::Lit(Lit::Bool(Bool { span, value: false }))
|
||||
|
@ -159,7 +159,7 @@ fn wrap_module(
|
||||
init: Some(Box::new(Expr::Call(CallExpr {
|
||||
span: DUMMY_SP,
|
||||
callee: Ident::new("__swcpack_require__".into(), DUMMY_SP, helper_ctxt)
|
||||
.make_member(Ident::new_no_ctxt("bind".into(), DUMMY_SP))
|
||||
.make_member(quote_ident!("bind"))
|
||||
.as_callee(),
|
||||
args: vec![Expr::undefined(DUMMY_SP).as_arg(), module_fn.as_arg()],
|
||||
..Default::default()
|
||||
@ -284,7 +284,7 @@ where
|
||||
},
|
||||
ImportSpecifier::Default(s) => {
|
||||
props.push(ObjectPatProp::KeyValue(KeyValuePatProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("default".into(), DUMMY_SP)),
|
||||
key: PropName::Ident(IdentName::new("default".into(), DUMMY_SP)),
|
||||
value: Box::new(s.local.into()),
|
||||
}));
|
||||
}
|
||||
|
@ -204,12 +204,10 @@ impl ExportToReturn {
|
||||
.push(PropOrSpread::Prop(Box::new(Prop::Shorthand(i))));
|
||||
}
|
||||
|
||||
fn export_key_value(&mut self, mut key: Ident, value: Ident) {
|
||||
key.ctxt = SyntaxContext::empty();
|
||||
|
||||
fn export_key_value(&mut self, key: Ident, value: Ident) {
|
||||
self.return_props
|
||||
.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(key),
|
||||
key: PropName::Ident(key.into()),
|
||||
value: Box::new(Expr::Ident(value)),
|
||||
}))));
|
||||
}
|
||||
|
@ -1048,7 +1048,7 @@ where
|
||||
init: Some(
|
||||
mod_var
|
||||
.clone()
|
||||
.make_member(orig.clone())
|
||||
.make_member(orig.clone().into())
|
||||
.into(),
|
||||
),
|
||||
definite: Default::default(),
|
||||
|
@ -206,7 +206,7 @@ where
|
||||
ExportSpecifier::Default(s) => {
|
||||
props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt(
|
||||
key: PropName::Ident(IdentName::new(
|
||||
"default".into(),
|
||||
DUMMY_SP,
|
||||
)),
|
||||
@ -224,7 +224,7 @@ where
|
||||
};
|
||||
props.push(PropOrSpread::Prop(Box::new(
|
||||
Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(exported),
|
||||
key: PropName::Ident(exported.into()),
|
||||
value: Box::new(Expr::Ident(orig)),
|
||||
}),
|
||||
)));
|
||||
@ -258,7 +258,7 @@ where
|
||||
|
||||
props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt(
|
||||
key: PropName::Ident(IdentName::new(
|
||||
"default".into(),
|
||||
export.span,
|
||||
)),
|
||||
@ -279,7 +279,7 @@ where
|
||||
|
||||
props.push(PropOrSpread::Prop(Box::new(Prop::KeyValue(
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt(
|
||||
key: PropName::Ident(IdentName::new(
|
||||
"default".into(),
|
||||
export.span,
|
||||
)),
|
||||
|
@ -312,7 +312,7 @@ where
|
||||
};
|
||||
let prop = match &e.prop {
|
||||
MemberProp::Ident(i) => {
|
||||
let mut i = i.clone();
|
||||
let mut i = Ident::from(i.clone());
|
||||
i.ctxt = exported_ctxt;
|
||||
i
|
||||
}
|
||||
@ -351,7 +351,7 @@ where
|
||||
};
|
||||
|
||||
let mut prop = match &me.prop {
|
||||
MemberProp::Ident(v) => v.clone(),
|
||||
MemberProp::Ident(v) => Ident::from(v.clone()),
|
||||
_ => return,
|
||||
};
|
||||
prop.ctxt = self.imported_idents.get(&obj.to_id()).copied().unwrap();
|
||||
|
@ -133,7 +133,7 @@ impl VisitMut for KeywordRenamer {
|
||||
Prop::Shorthand(i) => {
|
||||
if let Some(renamed) = self.renamed(i) {
|
||||
*n = Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(i.clone()),
|
||||
key: PropName::Ident(i.clone().into()),
|
||||
value: Box::new(Expr::Ident(renamed)),
|
||||
});
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ impl VisitMut for Inliner {
|
||||
}
|
||||
if i.sym != orig.sym {
|
||||
*n = Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(orig),
|
||||
key: PropName::Ident(orig.into()),
|
||||
value: Box::new(Expr::Ident(i.clone())),
|
||||
});
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ impl Visit for FieldInitFinder {
|
||||
if let Expr::Member(callee) = &**callee {
|
||||
if callee.obj.is_ident_ref_to("Object") {
|
||||
match &callee.prop {
|
||||
MemberProp::Ident(Ident { sym: prop_sym, .. })
|
||||
MemberProp::Ident(IdentName { sym: prop_sym, .. })
|
||||
if *prop_sym == *"assign" =>
|
||||
{
|
||||
let old = self.in_object_assign;
|
||||
@ -441,7 +441,9 @@ impl Visit for FieldInitFinder {
|
||||
if !self.in_rhs || self.in_object_assign {
|
||||
if let Expr::Ident(obj) = &*e.obj {
|
||||
match &e.prop {
|
||||
MemberProp::Ident(Ident { sym: prop_sym, .. }) if *prop_sym == *"prototype" => {
|
||||
MemberProp::Ident(IdentName { sym: prop_sym, .. })
|
||||
if *prop_sym == *"prototype" =>
|
||||
{
|
||||
self.accessed.insert(obj.into());
|
||||
}
|
||||
_ => {}
|
||||
|
@ -183,7 +183,7 @@ impl<T> IntoParallelIterator for T where T: IntoIterator {}
|
||||
|
||||
fn metadata(key: &str, value: &str) -> PropOrSpread {
|
||||
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt(key.into(), DUMMY_SP)),
|
||||
key: PropName::Ident(IdentName::new(key.into(), DUMMY_SP)),
|
||||
value: Box::new(Expr::Lit(Lit::Str(Str {
|
||||
span: DUMMY_SP,
|
||||
value: value.into(),
|
||||
@ -242,7 +242,7 @@ impl ExportMetadata {
|
||||
for prop in &with.props {
|
||||
if let PropOrSpread::Prop(p) = prop {
|
||||
if let Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(Ident { sym, .. }),
|
||||
key: PropName::Ident(IdentName { sym, .. }),
|
||||
value,
|
||||
..
|
||||
}) = &**p
|
||||
|
@ -1112,7 +1112,7 @@ impl swc_bundler::Hook for Hook {
|
||||
|
||||
Ok(vec![
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("url".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("url".into(), span)),
|
||||
value: Box::new(Expr::Lit(Lit::Str(Str {
|
||||
span,
|
||||
raw: None,
|
||||
@ -1120,7 +1120,7 @@ impl swc_bundler::Hook for Hook {
|
||||
}))),
|
||||
},
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("main".into(), span)),
|
||||
value: Box::new(if module_record.is_entry {
|
||||
Expr::Member(MemberExpr {
|
||||
span,
|
||||
@ -1128,7 +1128,7 @@ impl swc_bundler::Hook for Hook {
|
||||
span,
|
||||
kind: MetaPropKind::ImportMeta,
|
||||
})),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
prop: MemberProp::Ident(IdentName::new("main".into(), span)),
|
||||
})
|
||||
} else {
|
||||
Expr::Lit(Lit::Bool(Bool { span, value: false }))
|
||||
|
@ -9,7 +9,7 @@ use anyhow::Error;
|
||||
use swc_bundler::{BundleKind, Bundler, Config, ModuleRecord};
|
||||
use swc_common::{errors::HANDLER, FileName, Globals, Span};
|
||||
use swc_ecma_ast::{
|
||||
Bool, Expr, Ident, KeyValueProp, Lit, MemberExpr, MemberProp, MetaPropExpr, MetaPropKind,
|
||||
Bool, Expr, IdentName, KeyValueProp, Lit, MemberExpr, MemberProp, MetaPropExpr, MetaPropKind,
|
||||
PropName, Str,
|
||||
};
|
||||
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
|
||||
@ -150,7 +150,7 @@ impl swc_bundler::Hook for Hook {
|
||||
|
||||
Ok(vec![
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("url".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("url".into(), span)),
|
||||
value: Box::new(Expr::Lit(Lit::Str(Str {
|
||||
span,
|
||||
raw: None,
|
||||
@ -158,7 +158,7 @@ impl swc_bundler::Hook for Hook {
|
||||
}))),
|
||||
},
|
||||
KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
key: PropName::Ident(IdentName::new("main".into(), span)),
|
||||
value: Box::new(if module_record.is_entry {
|
||||
Expr::Member(MemberExpr {
|
||||
span,
|
||||
@ -166,7 +166,7 @@ impl swc_bundler::Hook for Hook {
|
||||
span,
|
||||
kind: MetaPropKind::ImportMeta,
|
||||
})),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt("main".into(), span)),
|
||||
prop: MemberProp::Ident(IdentName::new("main".into(), span)),
|
||||
})
|
||||
} else {
|
||||
Expr::Lit(Lit::Bool(Bool { span, value: false }))
|
||||
|
@ -20,7 +20,7 @@ use swc_common::{
|
||||
};
|
||||
use swc_config::config_types::BoolOr;
|
||||
pub use swc_config::IsModule;
|
||||
use swc_ecma_ast::{EsVersion, Ident, Program};
|
||||
use swc_ecma_ast::{EsVersion, Ident, IdentName, Program};
|
||||
use swc_ecma_codegen::{text_writer::WriteJs, Emitter, Node};
|
||||
use swc_ecma_minifier::js::JsMinifyCommentOption;
|
||||
use swc_ecma_parser::{parse_file_as_module, parse_file_as_program, parse_file_as_script, Syntax};
|
||||
@ -409,4 +409,8 @@ impl Visit for IdentCollector {
|
||||
fn visit_ident(&mut self, ident: &Ident) {
|
||||
self.names.insert(ident.span.lo, ident.sym.clone());
|
||||
}
|
||||
|
||||
fn visit_ident_name(&mut self, ident: &IdentName) {
|
||||
self.names.insert(ident.span.lo, ident.sym.clone());
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use crate::{
|
||||
Accessibility, TsExprWithTypeArgs, TsIndexSignature, TsTypeAnn, TsTypeParamDecl,
|
||||
TsTypeParamInstantiation,
|
||||
},
|
||||
BigInt, ComputedPropName, EmptyStmt, Id, Ident, Number,
|
||||
BigInt, ComputedPropName, EmptyStmt, Id, Ident, IdentName, Number,
|
||||
};
|
||||
|
||||
#[ast_node]
|
||||
@ -295,7 +295,8 @@ pub enum Key {
|
||||
Public(PropName),
|
||||
}
|
||||
|
||||
bridge_from!(Key, PropName, Ident);
|
||||
bridge_from!(Key, IdentName, Ident);
|
||||
bridge_from!(Key, PropName, IdentName);
|
||||
bridge_from!(Key, PropName, Id);
|
||||
bridge_from!(Key, PropName, Number);
|
||||
bridge_from!(Key, PropName, ComputedPropName);
|
||||
|
@ -22,8 +22,8 @@ use crate::{
|
||||
TsAsExpr, TsConstAssertion, TsInstantiation, TsNonNullExpr, TsSatisfiesExpr, TsTypeAnn,
|
||||
TsTypeAssertion, TsTypeParamDecl, TsTypeParamInstantiation,
|
||||
},
|
||||
ArrayPat, BindingIdent, ComputedPropName, Id, ImportPhase, Invalid, KeyValueProp, Number,
|
||||
ObjectPat, PropName, Str,
|
||||
ArrayPat, BindingIdent, ComputedPropName, Id, IdentName, ImportPhase, Invalid, KeyValueProp,
|
||||
Number, ObjectPat, PropName, Str,
|
||||
};
|
||||
|
||||
#[ast_node(no_clone)]
|
||||
@ -315,18 +315,12 @@ impl Expr {
|
||||
}
|
||||
|
||||
/// #Note
|
||||
///
|
||||
/// This preserves SyntaxContext of [`Expr::Ident`], and noop for
|
||||
/// [`Expr::JSXMember`] and [`Expr::JSXNamespacedName`].
|
||||
pub fn with_span(mut self, span: Span) -> Expr {
|
||||
self.set_span(span);
|
||||
self
|
||||
}
|
||||
|
||||
/// # Note
|
||||
///
|
||||
/// This preserves SyntaxContext of [`Expr::Ident`], and noop for
|
||||
/// [`Expr::JSXMember`] and [`Expr::JSXNamespacedName`].
|
||||
|
||||
pub fn set_span(&mut self, span: Span) {
|
||||
match self {
|
||||
@ -362,8 +356,8 @@ impl Expr {
|
||||
Expr::MetaProp(e) => e.span = span,
|
||||
Expr::Await(e) => e.span = span,
|
||||
Expr::Paren(e) => e.span = span,
|
||||
Expr::JSXMember(..) => {}
|
||||
Expr::JSXNamespacedName(..) => {}
|
||||
Expr::JSXMember(e) => e.span = span,
|
||||
Expr::JSXNamespacedName(e) => e.span = span,
|
||||
Expr::JSXEmpty(e) => e.span = span,
|
||||
Expr::JSXElement(e) => e.span = span,
|
||||
Expr::JSXFragment(e) => e.span = span,
|
||||
@ -434,6 +428,7 @@ impl Default for Expr {
|
||||
}
|
||||
}
|
||||
|
||||
bridge_expr_from!(Ident, IdentName);
|
||||
bridge_expr_from!(Ident, Id);
|
||||
bridge_expr_from!(FnExpr, Function);
|
||||
bridge_expr_from!(ClassExpr, Class);
|
||||
@ -538,7 +533,7 @@ impl ObjectLit {
|
||||
Prop::KeyValue(kv) => {
|
||||
let key = match &kv.key {
|
||||
PropName::Ident(i) => i.clone(),
|
||||
PropName::Str(s) => Ident::new_no_ctxt(s.value.clone(), s.span),
|
||||
PropName::Str(s) => IdentName::new(s.value.clone(), s.span),
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
@ -604,7 +599,7 @@ impl ImportWith {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
|
||||
pub struct ImportWithItem {
|
||||
pub key: Ident,
|
||||
pub key: IdentName,
|
||||
pub value: Str,
|
||||
}
|
||||
|
||||
@ -850,7 +845,7 @@ pub struct MemberExpr {
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub enum MemberProp {
|
||||
#[tag("Identifier")]
|
||||
Ident(Ident),
|
||||
Ident(IdentName),
|
||||
#[tag("PrivateName")]
|
||||
PrivateName(PrivateName),
|
||||
#[tag("Computed")]
|
||||
@ -880,7 +875,7 @@ pub struct SuperPropExpr {
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub enum SuperProp {
|
||||
#[tag("Identifier")]
|
||||
Ident(Ident),
|
||||
Ident(IdentName),
|
||||
#[tag("Computed")]
|
||||
Computed(ComputedPropName),
|
||||
}
|
||||
@ -903,13 +898,13 @@ impl Take for MemberProp {
|
||||
|
||||
impl Default for MemberProp {
|
||||
fn default() -> Self {
|
||||
MemberProp::Ident(Ident::dummy())
|
||||
MemberProp::Ident(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl Take for SuperProp {
|
||||
fn dummy() -> Self {
|
||||
SuperProp::Ident(Ident::dummy())
|
||||
SuperProp::Ident(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
fmt::Display,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
@ -173,9 +174,22 @@ impl From<BindingIdent> for Ident {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&'_ str> for Ident {
|
||||
fn from(bi: &str) -> Self {
|
||||
Ident::new_no_ctxt(bi.into(), DUMMY_SP)
|
||||
impl From<Atom> for Ident {
|
||||
fn from(bi: Atom) -> Self {
|
||||
Ident::new_no_ctxt(bi, DUMMY_SP)
|
||||
}
|
||||
}
|
||||
bridge_from!(Ident, Atom, &'_ str);
|
||||
bridge_from!(Ident, Atom, Cow<'_, str>);
|
||||
bridge_from!(Ident, Atom, String);
|
||||
|
||||
impl From<(Atom, Span)> for Ident {
|
||||
fn from((sym, span): (Atom, Span)) -> Self {
|
||||
Ident {
|
||||
span,
|
||||
sym,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,6 +367,89 @@ impl Ident {
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("Identifier")]
|
||||
#[derive(Eq, Hash, Default, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct IdentName {
|
||||
#[cfg_attr(feature = "__rkyv", omit_bounds)]
|
||||
pub span: Span,
|
||||
|
||||
#[cfg_attr(feature = "serde-impl", serde(rename = "value"))]
|
||||
pub sym: Atom,
|
||||
}
|
||||
|
||||
impl From<Atom> for IdentName {
|
||||
fn from(sym: Atom) -> Self {
|
||||
IdentName {
|
||||
span: DUMMY_SP,
|
||||
sym,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(Atom, Span)> for IdentName {
|
||||
fn from((sym, span): (Atom, Span)) -> Self {
|
||||
IdentName { span, sym }
|
||||
}
|
||||
}
|
||||
|
||||
bridge_from!(IdentName, Atom, &'_ str);
|
||||
bridge_from!(IdentName, Atom, Cow<'_, str>);
|
||||
bridge_from!(IdentName, Atom, String);
|
||||
bridge_from!(IdentName, Ident, &'_ BindingIdent);
|
||||
bridge_from!(IdentName, Ident, BindingIdent);
|
||||
|
||||
impl AsRef<str> for IdentName {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.sym
|
||||
}
|
||||
}
|
||||
|
||||
impl IdentName {
|
||||
pub const fn new(sym: Atom, span: Span) -> Self {
|
||||
Self { span, sym }
|
||||
}
|
||||
}
|
||||
|
||||
impl Take for IdentName {
|
||||
fn dummy() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Ident> for IdentName {
|
||||
fn from(i: Ident) -> Self {
|
||||
IdentName {
|
||||
span: i.span,
|
||||
sym: i.sym,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IdentName> for Ident {
|
||||
fn from(i: IdentName) -> Self {
|
||||
Ident {
|
||||
span: i.span,
|
||||
sym: i.sym,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bridge_from!(BindingIdent, Ident, Atom);
|
||||
bridge_from!(BindingIdent, Atom, &'_ str);
|
||||
bridge_from!(BindingIdent, Atom, Cow<'_, str>);
|
||||
bridge_from!(BindingIdent, Atom, String);
|
||||
|
||||
impl From<IdentName> for BindingIdent {
|
||||
fn from(i: IdentName) -> Self {
|
||||
BindingIdent {
|
||||
id: i.into(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// See [Ident] for documentation.
|
||||
pub type Id = (Atom, SyntaxContext);
|
||||
|
||||
@ -368,6 +465,12 @@ impl Display for Ident {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for IdentName {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.sym)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for BindingIdent {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}{:?}", self.sym, self.ctxt)
|
||||
@ -524,6 +627,7 @@ pub trait EsReserved: AsRef<str> {
|
||||
}
|
||||
|
||||
impl EsReserved for Atom {}
|
||||
impl EsReserved for IdentName {}
|
||||
impl EsReserved for Ident {}
|
||||
impl EsReserved for BindingIdent {}
|
||||
impl EsReserved for &'_ str {}
|
||||
|
@ -7,6 +7,7 @@ use crate::{
|
||||
ident::Ident,
|
||||
lit::Lit,
|
||||
typescript::TsTypeParamInstantiation,
|
||||
IdentName,
|
||||
};
|
||||
|
||||
/// Used for `obj` property of `JSXMemberExpr`.
|
||||
@ -25,13 +26,13 @@ pub enum JSXObject {
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct JSXMemberExpr {
|
||||
pub span: Span,
|
||||
|
||||
#[cfg_attr(feature = "serde-impl", serde(rename = "object"))]
|
||||
#[span(lo)]
|
||||
pub obj: JSXObject,
|
||||
|
||||
#[cfg_attr(feature = "serde-impl", serde(rename = "property"))]
|
||||
#[span(hi)]
|
||||
pub prop: Ident,
|
||||
pub prop: IdentName,
|
||||
}
|
||||
|
||||
/// XML-based namespace syntax:
|
||||
@ -39,11 +40,10 @@ pub struct JSXMemberExpr {
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct JSXNamespacedName {
|
||||
pub span: Span,
|
||||
#[cfg_attr(feature = "serde-impl", serde(rename = "namespace"))]
|
||||
#[span(lo)]
|
||||
pub ns: Ident,
|
||||
#[span(hi)]
|
||||
pub name: Ident,
|
||||
pub ns: IdentName,
|
||||
pub name: IdentName,
|
||||
}
|
||||
|
||||
#[ast_node("JSXEmptyExpression")]
|
||||
@ -166,7 +166,7 @@ pub struct JSXAttr {
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub enum JSXAttrName {
|
||||
#[tag("Identifier")]
|
||||
Ident(Ident),
|
||||
Ident(IdentName),
|
||||
#[tag("JSXNamespacedName")]
|
||||
JSXNamespacedName(JSXNamespacedName),
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ pub use self::{
|
||||
decl::{ClassDecl, Decl, FnDecl, UsingDecl, VarDecl, VarDeclKind, VarDeclarator},
|
||||
expr::*,
|
||||
function::{Function, Param, ParamOrTsParamProp},
|
||||
ident::{BindingIdent, EsReserved, Id, Ident, PrivateName},
|
||||
ident::{BindingIdent, EsReserved, Id, Ident, IdentName, PrivateName},
|
||||
jsx::{
|
||||
JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment,
|
||||
JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpr, JSXExpr, JSXExprContainer,
|
||||
@ -171,7 +171,7 @@ pub use self::{
|
||||
ArchivedTplElement, ArchivedUnaryExpr, ArchivedUpdateExpr, ArchivedYieldExpr,
|
||||
},
|
||||
function::{ArchivedFunction, ArchivedParam, ArchivedParamOrTsParamProp},
|
||||
ident::{ArchivedBindingIdent, ArchivedIdent, ArchivedPrivateName},
|
||||
ident::{ArchivedBindingIdent, ArchivedIdent, ArchivedIdentName, ArchivedPrivateName},
|
||||
jsx::{
|
||||
ArchivedJSXAttr, ArchivedJSXAttrName, ArchivedJSXAttrOrSpread, ArchivedJSXAttrValue,
|
||||
ArchivedJSXClosingElement, ArchivedJSXClosingFragment, ArchivedJSXElement,
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
ident::Ident,
|
||||
lit::Str,
|
||||
typescript::{TsExportAssignment, TsImportEqualsDecl, TsInterfaceDecl, TsNamespaceExportDecl},
|
||||
ObjectLit,
|
||||
BindingIdent, IdentName, ObjectLit,
|
||||
};
|
||||
|
||||
#[ast_node]
|
||||
@ -359,6 +359,9 @@ pub enum ModuleExportName {
|
||||
Str(Str),
|
||||
}
|
||||
|
||||
bridge_from!(ModuleExportName, Ident, BindingIdent);
|
||||
bridge_from!(ModuleExportName, Ident, IdentName);
|
||||
|
||||
impl ModuleExportName {
|
||||
/// Get the atom of the export name.
|
||||
pub fn atom(&self) -> &Atom {
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
ident::{BindingIdent, Ident},
|
||||
prop::PropName,
|
||||
typescript::TsTypeAnn,
|
||||
Id, Invalid,
|
||||
Id, IdentName, Invalid,
|
||||
};
|
||||
|
||||
#[ast_node(no_clone)]
|
||||
@ -65,6 +65,7 @@ impl Take for Pat {
|
||||
}
|
||||
|
||||
bridge_pat_from!(BindingIdent, Ident);
|
||||
bridge_pat_from!(BindingIdent, IdentName);
|
||||
bridge_pat_from!(BindingIdent, Id);
|
||||
|
||||
macro_rules! pat_to_other {
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
lit::{BigInt, Number, Str},
|
||||
stmt::BlockStmt,
|
||||
typescript::TsTypeAnn,
|
||||
Id, MemberProp, Pat,
|
||||
Id, IdentName, MemberProp, Pat,
|
||||
};
|
||||
|
||||
#[ast_node]
|
||||
@ -37,6 +37,8 @@ pub enum Prop {
|
||||
Method(MethodProp),
|
||||
}
|
||||
|
||||
bridge_from!(Prop, Ident, IdentName);
|
||||
|
||||
#[ast_node("KeyValueProperty")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -52,9 +54,8 @@ pub struct KeyValueProp {
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct AssignProp {
|
||||
#[span(lo)]
|
||||
pub span: Span,
|
||||
pub key: Ident,
|
||||
#[span(hi)]
|
||||
pub value: Box<Expr>,
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ pub struct MethodProp {
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub enum PropName {
|
||||
#[tag("Identifier")]
|
||||
Ident(Ident),
|
||||
Ident(IdentName),
|
||||
/// String literal.
|
||||
#[tag("StringLiteral")]
|
||||
Str(Str),
|
||||
@ -109,6 +110,7 @@ pub enum PropName {
|
||||
BigInt(BigInt),
|
||||
}
|
||||
|
||||
bridge_from!(PropName, IdentName, Ident);
|
||||
bridge_from!(PropName, Ident, Id);
|
||||
|
||||
impl Default for PropName {
|
||||
|
@ -4,9 +4,8 @@ use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span, SyntaxContext,
|
||||
use crate::{
|
||||
decl::{Decl, VarDecl},
|
||||
expr::Expr,
|
||||
ident::Ident,
|
||||
pat::Pat,
|
||||
Lit, Str, UsingDecl,
|
||||
Ident, Lit, Str, UsingDecl,
|
||||
};
|
||||
|
||||
/// Use when only block statements are allowed.
|
||||
|
@ -21,7 +21,7 @@ use crate::{
|
||||
lit::{Bool, Number, Str},
|
||||
module::ModuleItem,
|
||||
pat::{ArrayPat, AssignPat, ObjectPat, Pat, RestPat},
|
||||
BigInt, BindingIdent, TplElement,
|
||||
BigInt, BindingIdent, IdentName, TplElement,
|
||||
};
|
||||
|
||||
#[ast_node("TsTypeAnnotation")]
|
||||
@ -104,10 +104,9 @@ pub enum TsParamPropParam {
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
pub struct TsQualifiedName {
|
||||
#[span(lo)]
|
||||
pub span: Span,
|
||||
pub left: TsEntityName,
|
||||
#[span(hi)]
|
||||
pub right: Ident,
|
||||
pub right: IdentName,
|
||||
}
|
||||
|
||||
#[ast_node]
|
||||
|
@ -1714,9 +1714,7 @@ where
|
||||
|
||||
emit!(n.key);
|
||||
|
||||
// emit for a computed property, but not an identifier already marked as
|
||||
// optional
|
||||
if n.is_optional && !n.key.as_ident().map(|i| i.optional).unwrap_or(false) {
|
||||
if n.is_optional {
|
||||
punct!("?");
|
||||
}
|
||||
|
||||
@ -2363,6 +2361,11 @@ where
|
||||
self.emit_ident_like(ident.span, &ident.sym, ident.optional)?;
|
||||
}
|
||||
|
||||
#[emitter]
|
||||
fn emit_ident_name(&mut self, ident: &IdentName) -> Result {
|
||||
self.emit_ident_like(ident.span, &ident.sym, false)?;
|
||||
}
|
||||
|
||||
fn emit_ident_like(&mut self, span: Span, sym: &Atom, optional: bool) -> Result {
|
||||
// TODO: Use write_symbol when ident is a symbol.
|
||||
self.emit_leading_comments_of_span(span, false)?;
|
||||
|
@ -808,7 +808,7 @@ impl VisitMut for FlowHelper<'_> {
|
||||
arg: Some(Box::new(Expr::Object(ObjectLit {
|
||||
span,
|
||||
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt("v".into(), DUMMY_SP)),
|
||||
key: PropName::Ident(IdentName::new("v".into(), DUMMY_SP)),
|
||||
value: s.arg.take().unwrap_or_else(|| {
|
||||
Box::new(Expr::Unary(UnaryExpr {
|
||||
span: DUMMY_SP,
|
||||
|
@ -134,7 +134,8 @@ where
|
||||
decl: DefaultDecl::Class(ClassExpr { ident, class }),
|
||||
..
|
||||
}) => {
|
||||
let ident = ident.unwrap_or_else(|| quote_ident!("_default"));
|
||||
let ident =
|
||||
ident.unwrap_or_else(|| quote_ident!("_default").into());
|
||||
|
||||
let mut decl = self.fold_class_as_var_decl(ident.clone(), class);
|
||||
decl.visit_mut_children_with(self);
|
||||
@ -148,7 +149,7 @@ where
|
||||
span: DUMMY_SP,
|
||||
orig: ModuleExportName::Ident(ident),
|
||||
exported: Some(ModuleExportName::Ident(
|
||||
quote_ident!("default"),
|
||||
quote_ident!("default").into(),
|
||||
)),
|
||||
is_type_only: false,
|
||||
}
|
||||
@ -304,7 +305,7 @@ where
|
||||
if let Expr::Class(c @ ClassExpr { ident: None, .. }) = &mut *n.value {
|
||||
match &n.key {
|
||||
PropName::Ident(ident) => {
|
||||
c.ident = Some(ident.clone().into_private());
|
||||
c.ident = Some(Ident::from(ident.clone()).into_private());
|
||||
}
|
||||
PropName::Str(Str { value, span, .. }) => {
|
||||
if is_valid_prop_ident(value) {
|
||||
@ -528,7 +529,7 @@ where
|
||||
super_class_ident: Option<Ident>,
|
||||
class: Box<Class>,
|
||||
) -> Vec<Stmt> {
|
||||
let class_name = class_name.unwrap_or_else(|| quote_ident!("_class"));
|
||||
let class_name = class_name.unwrap_or_else(|| quote_ident!("_class").into());
|
||||
let mut stmts = vec![];
|
||||
|
||||
let mut methods = vec![];
|
||||
@ -887,7 +888,7 @@ where
|
||||
/// { key: "prop" }
|
||||
fn mk_key_prop(key: PropName) -> Box<Prop> {
|
||||
Box::new(Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(quote_ident!(Default::default(), key.span(), "key")),
|
||||
key: PropName::Ident(quote_ident!(Default::default(), key.span(), "key").into()),
|
||||
value: match key {
|
||||
PropName::Ident(i) => Box::new(Expr::Lit(Lit::Str(quote_str!(i.span, i.sym)))),
|
||||
PropName::Str(s) => Box::new(Expr::from(s)),
|
||||
|
@ -12,7 +12,7 @@ pub enum HashKey {
|
||||
impl From<&PropName> for HashKey {
|
||||
fn from(p: &PropName) -> Self {
|
||||
match p {
|
||||
PropName::Ident(Ident { sym: value, .. }) | PropName::Str(Str { value, .. }) => {
|
||||
PropName::Ident(IdentName { sym: value, .. }) | PropName::Str(Str { value, .. }) => {
|
||||
HashKey::Str(value.clone())
|
||||
}
|
||||
PropName::Num(Number { value, .. }) => HashKey::Str(value.to_string().into()),
|
||||
|
@ -248,7 +248,7 @@ impl VisitMut for ComputedProps {
|
||||
let left = if is_compute {
|
||||
obj_ident.clone().computed_member(key)
|
||||
} else {
|
||||
obj_ident.clone().make_member(key.ident().unwrap())
|
||||
obj_ident.clone().make_member(key.ident().unwrap().into())
|
||||
};
|
||||
Box::new(Expr::Assign(AssignExpr {
|
||||
span,
|
||||
@ -380,7 +380,7 @@ fn prop_name_to_expr(p: PropName, loose: bool) -> (Expr, bool) {
|
||||
match p {
|
||||
PropName::Ident(i) => (
|
||||
if loose {
|
||||
Expr::Ident(i)
|
||||
Expr::Ident(i.into())
|
||||
} else {
|
||||
Expr::Lit(Lit::Str(Str {
|
||||
raw: None,
|
||||
|
@ -321,7 +321,7 @@ impl AssignFolder {
|
||||
decls.push(VarDeclarator {
|
||||
span: decl.span,
|
||||
name: p.key.clone().into(),
|
||||
init: Some(decl.init.unwrap().make_member(p.key.clone()).into()),
|
||||
init: Some(decl.init.unwrap().make_member(p.key.clone().into()).into()),
|
||||
definite: false,
|
||||
});
|
||||
return;
|
||||
@ -869,7 +869,7 @@ impl VisitMut for AssignFolder {
|
||||
span: *span,
|
||||
op: op!("="),
|
||||
left: p.key.clone().into(),
|
||||
right: right.take().make_member(p.key.clone()).into(),
|
||||
right: right.take().make_member(p.key.clone().into()).into(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -1170,7 +1170,7 @@ fn make_ref_prop_expr(ref_ident: &Ident, prop: Box<Expr>, mut computed: bool) ->
|
||||
expr: prop,
|
||||
})
|
||||
} else {
|
||||
MemberProp::Ident(prop.ident().unwrap())
|
||||
MemberProp::Ident(prop.ident().unwrap().into())
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ impl ForOf {
|
||||
span: DUMMY_SP,
|
||||
left: error_ident.clone().into(),
|
||||
op: op!("="),
|
||||
right: Box::new(Expr::Ident(quote_ident!("err"))),
|
||||
right: Box::new(Expr::Ident(quote_ident!("err").into())),
|
||||
}
|
||||
.into_stmt(),
|
||||
],
|
||||
|
@ -77,7 +77,7 @@ impl VisitMut for FnName {
|
||||
//
|
||||
p.value = if let PropName::Ident(ref i) = p.key {
|
||||
Box::new(Expr::Fn(FnExpr {
|
||||
ident: Some(prepare(i.clone())),
|
||||
ident: Some(prepare(i.clone().into())),
|
||||
..expr.take()
|
||||
}))
|
||||
} else {
|
||||
|
@ -774,7 +774,7 @@ impl VisitMut for Generator {
|
||||
let mut args = node.args.take().into_iter().map(Some).collect::<Vec<_>>();
|
||||
let arg = self.visit_elements(&mut args, None, None);
|
||||
|
||||
let apply = callee.make_member(Ident::new_no_ctxt("apply".into(), node.span));
|
||||
let apply = callee.make_member(IdentName::new("apply".into(), node.span));
|
||||
|
||||
*node = CallExpr {
|
||||
span: node.span,
|
||||
@ -1217,7 +1217,7 @@ impl Generator {
|
||||
left: MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj: Box::new(Expr::Ident(temp.clone())),
|
||||
prop: MemberProp::Ident(p.clone()),
|
||||
prop: MemberProp::Ident(p.clone().into()),
|
||||
}
|
||||
.into(),
|
||||
right: Box::new(Expr::Ident(p)),
|
||||
|
@ -189,7 +189,7 @@ impl SuperReplacer {
|
||||
// .a -> "a"
|
||||
fn normalize_computed_expr(&mut self, prop: &mut SuperProp) -> Box<Expr> {
|
||||
match prop.take() {
|
||||
SuperProp::Ident(Ident {
|
||||
SuperProp::Ident(IdentName {
|
||||
sym: value, span, ..
|
||||
}) => Box::new(Expr::Lit(Lit::Str(Str {
|
||||
raw: None,
|
||||
|
@ -790,7 +790,7 @@ fn make_arg_nth(n: usize) -> MemberExpr {
|
||||
fn check_arg_len(n: usize) -> Expr {
|
||||
Expr::Bin(BinExpr {
|
||||
left: Expr::Ident(Ident::new_no_ctxt("arguments".into(), DUMMY_SP))
|
||||
.make_member(Ident::new_no_ctxt("length".into(), DUMMY_SP))
|
||||
.make_member(IdentName::new("length".into(), DUMMY_SP))
|
||||
.into(),
|
||||
op: op!(">"),
|
||||
right: n.into(),
|
||||
|
@ -78,7 +78,7 @@ impl VisitMut for Shorthand {
|
||||
}
|
||||
Prop::Method(MethodProp { key, function }) => {
|
||||
let key = match key.take() {
|
||||
PropName::Ident(Ident { span, sym, .. }) if sym == "__proto__" => {
|
||||
PropName::Ident(IdentName { span, sym, .. }) if sym == "__proto__" => {
|
||||
ComputedPropName {
|
||||
span,
|
||||
expr: sym.into(),
|
||||
|
@ -151,7 +151,7 @@ impl VisitMut for Spread {
|
||||
let apply = MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj: callee_updated.unwrap_or_else(|| callee.take()),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt("apply".into(), *span)),
|
||||
prop: MemberProp::Ident(IdentName::new("apply".into(), *span)),
|
||||
};
|
||||
|
||||
*e = Expr::Call(CallExpr {
|
||||
@ -415,7 +415,7 @@ impl Spread {
|
||||
let callee = buf
|
||||
.remove(0)
|
||||
.expr
|
||||
.make_member(Ident::new_no_ctxt("concat".into(), DUMMY_SP))
|
||||
.make_member(IdentName::new("concat".into(), DUMMY_SP))
|
||||
.as_callee();
|
||||
|
||||
return Expr::Call(CallExpr {
|
||||
@ -441,7 +441,7 @@ impl Spread {
|
||||
elems: vec![],
|
||||
})
|
||||
})
|
||||
.make_member(Ident::new_no_ctxt("concat".into(), span))
|
||||
.make_member(IdentName::new("concat".into(), span))
|
||||
.as_callee(),
|
||||
|
||||
args: buf,
|
||||
|
@ -169,7 +169,7 @@ impl VisitMut for TemplateLiteral {
|
||||
callee: MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj,
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt(
|
||||
prop: MemberProp::Ident(IdentName::new(
|
||||
"concat".into(),
|
||||
expr_span,
|
||||
)),
|
||||
@ -210,7 +210,7 @@ impl VisitMut for TemplateLiteral {
|
||||
callee: MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj,
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt(
|
||||
prop: MemberProp::Ident(IdentName::new(
|
||||
"concat".into(),
|
||||
expr_span,
|
||||
)),
|
||||
|
@ -754,10 +754,7 @@ impl ObjectRest {
|
||||
ref value, span, ..
|
||||
}) => {
|
||||
let value = value.clone();
|
||||
(
|
||||
key,
|
||||
MemberProp::Ident(quote_ident!(Default::default(), span, value)),
|
||||
)
|
||||
(key, MemberProp::Ident(IdentName::new(value, span)))
|
||||
}
|
||||
PropName::Num(Number { span, value, .. }) => (
|
||||
key,
|
||||
@ -953,7 +950,7 @@ fn object_without_properties(
|
||||
span: DUMMY_SP,
|
||||
elems: excluded_props,
|
||||
}
|
||||
.make_member(Ident::new_no_ctxt("map".into(), DUMMY_SP))
|
||||
.make_member(quote_ident!("map"))
|
||||
.as_callee(),
|
||||
args: vec![helper_expr!(to_property_key).as_arg()],
|
||||
..Default::default()
|
||||
|
@ -780,7 +780,7 @@ impl<C: Comments> ClassProperties<C> {
|
||||
name: ident.into(),
|
||||
init: Some(Box::new(Expr::from(NewExpr {
|
||||
span,
|
||||
callee: Box::new(Expr::Ident(quote_ident!("WeakMap"))),
|
||||
callee: Box::new(Expr::Ident(quote_ident!("WeakMap").into())),
|
||||
args: Some(Default::default()),
|
||||
..Default::default()
|
||||
}))),
|
||||
@ -870,7 +870,7 @@ impl<C: Comments> ClassProperties<C> {
|
||||
},
|
||||
}));
|
||||
if inserted && self.c.private_as_properties {
|
||||
Some(Ident::dummy())
|
||||
Some(IdentName::default())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -895,7 +895,7 @@ impl<C: Comments> ClassProperties<C> {
|
||||
name: weak_coll_var.clone(),
|
||||
fn_name: fn_name.clone(),
|
||||
}));
|
||||
Some(Ident::dummy())
|
||||
Some(Default::default())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -924,7 +924,7 @@ impl<C: Comments> ClassProperties<C> {
|
||||
} else {
|
||||
Expr::New(NewExpr {
|
||||
span,
|
||||
callee: Box::new(Expr::Ident(extra)),
|
||||
callee: Box::new(Expr::Ident(extra.into())),
|
||||
args: Some(Default::default()),
|
||||
..Default::default()
|
||||
})
|
||||
|
@ -339,7 +339,7 @@ impl VisitMut for PrivateInObject {
|
||||
var_name.clone(),
|
||||
Some(Box::new(Expr::New(NewExpr {
|
||||
span: DUMMY_SP,
|
||||
callee: Box::new(Expr::Ident(quote_ident!("WeakSet"))),
|
||||
callee: Box::new(Expr::Ident(quote_ident!("WeakSet").into())),
|
||||
args: Some(Default::default()),
|
||||
..Default::default()
|
||||
}))),
|
||||
|
@ -52,7 +52,7 @@ impl Fold for MemberExprLit {
|
||||
};
|
||||
} else {
|
||||
return MemberExpr {
|
||||
prop: MemberProp::Ident(swc_ecma_utils::quote_ident!(i.ctxt, i.span, i.sym)),
|
||||
prop: MemberProp::Ident(IdentName::new(i.sym, i.span)),
|
||||
..e
|
||||
};
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ impl Fold for PropertyLiteral {
|
||||
if value.is_reserved() || !is_valid_ident(&value) {
|
||||
PropName::Str(Str { span, raw, value })
|
||||
} else {
|
||||
PropName::Ident(Ident::new_no_ctxt(value, span))
|
||||
PropName::Ident(IdentName::new(value, span))
|
||||
}
|
||||
}
|
||||
PropName::Ident(i) => {
|
||||
let Ident { sym, span, .. } = i;
|
||||
let IdentName { sym, span, .. } = i;
|
||||
if sym.is_reserved() || sym.contains('-') || sym.contains('.') {
|
||||
PropName::Str(Str {
|
||||
span,
|
||||
@ -62,7 +62,7 @@ impl Fold for PropertyLiteral {
|
||||
value: sym,
|
||||
})
|
||||
} else {
|
||||
PropName::Ident(Ident { span, sym, ..i })
|
||||
PropName::Ident(IdentName { span, sym })
|
||||
}
|
||||
}
|
||||
_ => n,
|
||||
|
@ -117,7 +117,7 @@ impl NoAlert {
|
||||
|
||||
fn handle_member_prop(&mut self, prop: &MemberProp) {
|
||||
match prop {
|
||||
MemberProp::Ident(Ident { sym, .. }) => {
|
||||
MemberProp::Ident(IdentName { sym, .. }) => {
|
||||
self.prop = Some(sym.clone());
|
||||
}
|
||||
MemberProp::Computed(comp) => {
|
||||
|
@ -74,7 +74,7 @@ impl Visit for NoConsole {
|
||||
fn visit_member_expr(&mut self, member: &MemberExpr) {
|
||||
if let Expr::Ident(ident) = member.obj.as_ref() {
|
||||
match &member.prop {
|
||||
MemberProp::Ident(Ident { sym, .. }) => {
|
||||
MemberProp::Ident(IdentName { sym, .. }) => {
|
||||
self.check(member.span, ident, sym);
|
||||
}
|
||||
MemberProp::Computed(ComputedPropName { expr, .. }) => {
|
||||
|
@ -187,7 +187,7 @@ impl Radix {
|
||||
|
||||
fn extract_prop_value(&mut self, prop: &MemberProp) -> Option<JsWord> {
|
||||
match prop {
|
||||
MemberProp::Ident(Ident { sym, .. }) => Some(sym.clone()),
|
||||
MemberProp::Ident(IdentName { sym, .. }) => Some(sym.clone()),
|
||||
MemberProp::Computed(ComputedPropName { expr, .. }) => {
|
||||
if let Expr::Lit(Lit::Str(Str { value, .. })) = expr.as_ref() {
|
||||
return Some(value.clone());
|
||||
|
@ -31,10 +31,9 @@ impl Optimizer<'_> {
|
||||
|
||||
self.changed = true;
|
||||
report_change!("arguments: Optimizing computed access to arguments");
|
||||
*prop = MemberProp::Ident(Ident {
|
||||
*prop = MemberProp::Ident(IdentName {
|
||||
span: s.span,
|
||||
sym: s.take().value,
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -53,10 +52,9 @@ impl Optimizer<'_> {
|
||||
|
||||
self.changed = true;
|
||||
report_change!("arguments: Optimizing computed access to arguments");
|
||||
*prop = SuperProp::Ident(Ident {
|
||||
*prop = SuperProp::Ident(IdentName {
|
||||
span: s.span,
|
||||
sym: s.take().value,
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -2235,7 +2235,7 @@ impl VisitMut for Optimizer<'_> {
|
||||
let ctx = Ctx {
|
||||
dont_use_prepend_nor_append: contains_leaping_continue_with_label(
|
||||
&n.body,
|
||||
n.label.to_id(),
|
||||
n.label.sym.clone(),
|
||||
),
|
||||
..self.ctx
|
||||
};
|
||||
@ -2397,7 +2397,7 @@ impl VisitMut for Optimizer<'_> {
|
||||
e.visit_mut_with(self);
|
||||
|
||||
*n = Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(i.clone()),
|
||||
key: PropName::Ident(i.clone().into()),
|
||||
value: e,
|
||||
});
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ impl VisitMut for NormalMultiReplacer<'_> {
|
||||
self.changed = true;
|
||||
|
||||
*p = Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(Ident::new_no_ctxt(i.sym.clone(), i.span)),
|
||||
key: PropName::Ident(IdentName::new(i.sym.clone(), i.span)),
|
||||
value,
|
||||
});
|
||||
}
|
||||
@ -592,7 +592,7 @@ impl VisitMut for ExprReplacer {
|
||||
unreachable!("`{}` is already taken", i)
|
||||
};
|
||||
*p = Prop::KeyValue(KeyValueProp {
|
||||
key: PropName::Ident(i.clone()),
|
||||
key: PropName::Ident(i.clone().into()),
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use phf::phf_set;
|
||||
use swc_atoms::{Atom, JsWord};
|
||||
use swc_common::Spanned;
|
||||
use swc_ecma_ast::{
|
||||
ArrayLit, Expr, ExprOrSpread, Ident, Lit, MemberExpr, MemberProp, ObjectLit, Prop,
|
||||
ArrayLit, Expr, ExprOrSpread, IdentName, Lit, MemberExpr, MemberProp, ObjectLit, Prop,
|
||||
PropOrSpread, SeqExpr, Str,
|
||||
};
|
||||
use swc_ecma_utils::{prop_name_eq, ExprExt, Known};
|
||||
@ -269,7 +269,7 @@ impl Pure<'_> {
|
||||
}
|
||||
|
||||
let op = match prop {
|
||||
MemberProp::Ident(Ident { sym, .. }) => {
|
||||
MemberProp::Ident(IdentName { sym, .. }) => {
|
||||
if self.ctx.is_callee {
|
||||
return None;
|
||||
}
|
||||
@ -533,7 +533,7 @@ impl Pure<'_> {
|
||||
span: *span,
|
||||
props: vec![],
|
||||
})),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt(key, *span)),
|
||||
prop: MemberProp::Ident(IdentName::new(key, *span)),
|
||||
})
|
||||
} else {
|
||||
// Invalid key. Replace with side effects plus `undefined`.
|
||||
|
@ -168,7 +168,7 @@ impl Pure<'_> {
|
||||
let arr = match callee {
|
||||
Expr::Member(MemberExpr {
|
||||
obj,
|
||||
prop: MemberProp::Ident(Ident { sym, .. }),
|
||||
prop: MemberProp::Ident(IdentName { sym, .. }),
|
||||
..
|
||||
}) if *sym == *"join" => {
|
||||
if let Expr::Array(arr) = &mut **obj {
|
||||
|
@ -1,5 +1,4 @@
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::SyntaxContext;
|
||||
use swc_ecma_ast::*;
|
||||
|
||||
use super::Pure;
|
||||
@ -10,7 +9,7 @@ impl Pure<'_> {
|
||||
&mut self,
|
||||
obj: Option<&Expr>,
|
||||
c: &mut ComputedPropName,
|
||||
) -> Option<Ident> {
|
||||
) -> Option<IdentName> {
|
||||
if !self.options.props {
|
||||
return None;
|
||||
}
|
||||
@ -32,11 +31,9 @@ impl Pure<'_> {
|
||||
"properties: Computed member => member expr with identifier as a prop"
|
||||
);
|
||||
|
||||
Some(Ident {
|
||||
Some(IdentName {
|
||||
span: s.span,
|
||||
ctxt: Default::default(),
|
||||
sym: s.value.clone(),
|
||||
optional: false,
|
||||
})
|
||||
}
|
||||
|
||||
@ -62,11 +59,7 @@ impl Pure<'_> {
|
||||
|| s.value.is_reserved_in_es3()
|
||||
|| is_valid_identifier(&s.value, false)
|
||||
{
|
||||
*p = PropName::Ident(Ident::new(
|
||||
s.value.clone(),
|
||||
s.span,
|
||||
SyntaxContext::empty(),
|
||||
));
|
||||
*p = PropName::Ident(IdentName::new(s.value.clone(), s.span));
|
||||
} else {
|
||||
*p = PropName::Str(s.clone());
|
||||
}
|
||||
@ -89,10 +82,9 @@ impl Pure<'_> {
|
||||
{
|
||||
self.changed = true;
|
||||
report_change!("misc: Optimizing string property name");
|
||||
*name = PropName::Ident(Ident {
|
||||
*name = PropName::Ident(IdentName {
|
||||
span: s.span,
|
||||
sym: s.value.clone(),
|
||||
..Default::default()
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -114,7 +106,7 @@ impl Pure<'_> {
|
||||
pub(super) fn handle_known_computed_member_expr(
|
||||
&mut self,
|
||||
c: &mut ComputedPropName,
|
||||
) -> Option<Ident> {
|
||||
) -> Option<IdentName> {
|
||||
if !self.options.props || !self.options.evaluate {
|
||||
return None;
|
||||
}
|
||||
@ -131,7 +123,7 @@ impl Pure<'_> {
|
||||
|
||||
self.changed = true;
|
||||
|
||||
Some(Ident::new_no_ctxt(s.value.clone(), s.span))
|
||||
Some(IdentName::new(s.value.clone(), s.span))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::collections::{AHashMap, AHashSet};
|
||||
use swc_ecma_ast::{
|
||||
CallExpr, Callee, Expr, Ident, KeyValueProp, Lit, MemberExpr, MemberProp, Program, Prop,
|
||||
CallExpr, Callee, Expr, IdentName, KeyValueProp, Lit, MemberExpr, MemberProp, Program, Prop,
|
||||
PropName, Str, SuperProp, SuperPropExpr,
|
||||
};
|
||||
use swc_ecma_visit::{standard_only_visit_mut, VisitMut, VisitMutWith};
|
||||
@ -188,7 +188,7 @@ fn is_object_property_call(call: &CallExpr) -> bool {
|
||||
match &**callee {
|
||||
Expr::Member(MemberExpr {
|
||||
obj,
|
||||
prop: MemberProp::Ident(Ident { sym, .. }),
|
||||
prop: MemberProp::Ident(IdentName { sym, .. }),
|
||||
..
|
||||
}) if *sym == *"defineProperty" => {
|
||||
if obj.is_ident_ref_to("Object") {
|
||||
@ -223,7 +223,7 @@ struct Mangler<'a> {
|
||||
}
|
||||
|
||||
impl Mangler<'_> {
|
||||
fn mangle_ident(&mut self, ident: &mut Ident) {
|
||||
fn mangle_ident(&mut self, ident: &mut IdentName) {
|
||||
if let Some(mangled) = self.state.gen_name(&ident.sym) {
|
||||
ident.sym = mangled;
|
||||
}
|
||||
@ -260,7 +260,7 @@ impl VisitMut for Mangler<'_> {
|
||||
prop.visit_mut_children_with(self);
|
||||
|
||||
if let Prop::Shorthand(ident) = prop {
|
||||
let mut new_ident = ident.clone();
|
||||
let mut new_ident = IdentName::from(ident.clone());
|
||||
|
||||
self.mangle_ident(&mut new_ident);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use rustc_hash::FxHashSet;
|
||||
use swc_atoms::Atom;
|
||||
use swc_common::{util::take::Take, Span, Spanned, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::{stack_size::maybe_grow_default, ModuleItemLike, StmtLike, Value};
|
||||
@ -179,7 +180,7 @@ impl ExprOptExt for Expr {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn contains_leaping_continue_with_label<N>(n: &N, label: Id) -> bool
|
||||
pub(crate) fn contains_leaping_continue_with_label<N>(n: &N, label: Atom) -> bool
|
||||
where
|
||||
N: VisitWith<LeapFinder>,
|
||||
{
|
||||
@ -206,7 +207,7 @@ pub(crate) struct LeapFinder {
|
||||
found_await: bool,
|
||||
found_yield: bool,
|
||||
found_continue_with_label: bool,
|
||||
target_label: Option<Id>,
|
||||
target_label: Option<Atom>,
|
||||
}
|
||||
|
||||
impl Visit for LeapFinder {
|
||||
@ -231,7 +232,7 @@ impl Visit for LeapFinder {
|
||||
self.found_continue_with_label |= self
|
||||
.target_label
|
||||
.as_ref()
|
||||
.map_or(false, |l| *l == label.to_id());
|
||||
.map_or(false, |l| *l == label.sym);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ impl<I: Tokens> Parser<I> {
|
||||
let declare_token = if declare {
|
||||
// Handle declare(){}
|
||||
if self.is_class_method() {
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"declare".into(),
|
||||
span!(self, start),
|
||||
)));
|
||||
@ -423,7 +423,7 @@ impl<I: Tokens> Parser<I> {
|
||||
{
|
||||
// Property named `declare`
|
||||
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"declare".into(),
|
||||
span!(self, start),
|
||||
)));
|
||||
@ -471,7 +471,7 @@ impl<I: Tokens> Parser<I> {
|
||||
if let Some(accessor_token) = accessor_token {
|
||||
// Handle accessor(){}
|
||||
if self.is_class_method() {
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"accessor".into(),
|
||||
accessor_token,
|
||||
)));
|
||||
@ -497,7 +497,7 @@ impl<I: Tokens> Parser<I> {
|
||||
{
|
||||
// Property named `accessor`
|
||||
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"accessor".into(),
|
||||
accessor_token,
|
||||
)));
|
||||
@ -522,7 +522,7 @@ impl<I: Tokens> Parser<I> {
|
||||
if let Some(static_token) = static_token {
|
||||
// Handle static(){}
|
||||
if self.is_class_method() {
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"static".into(),
|
||||
static_token,
|
||||
)));
|
||||
@ -553,7 +553,7 @@ impl<I: Tokens> Parser<I> {
|
||||
// {}
|
||||
let is_parsing_static_blocks = is!(self, '{');
|
||||
if !is_parsing_static_blocks {
|
||||
let key = Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = Key::Public(PropName::Ident(IdentName::new(
|
||||
"static".into(),
|
||||
static_token,
|
||||
)));
|
||||
@ -753,8 +753,8 @@ impl<I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
trace_cur!(self, parse_class_member_with_is_static__normal_class_member);
|
||||
let mut key = if readonly.is_some() && is_one_of!(self, '!', ':') {
|
||||
Key::Public(PropName::Ident(Ident::new_no_ctxt(
|
||||
let key = if readonly.is_some() && is_one_of!(self, '!', ':') {
|
||||
Key::Public(PropName::Ident(IdentName::new(
|
||||
"readonly".into(),
|
||||
readonly.unwrap(),
|
||||
)))
|
||||
@ -763,10 +763,6 @@ impl<I: Tokens> Parser<I> {
|
||||
};
|
||||
let is_optional = self.input.syntax().typescript() && eat!(self, '?');
|
||||
|
||||
if let Key::Public(PropName::Ident(i)) = &mut key {
|
||||
i.optional = is_optional;
|
||||
}
|
||||
|
||||
if self.is_class_method() {
|
||||
// handle a(){} / get(){} / set(){} / async(){}
|
||||
|
||||
@ -1733,7 +1729,7 @@ impl IsSimpleParameterList for Vec<ParamOrTsParamProp> {
|
||||
fn is_constructor(key: &Key) -> bool {
|
||||
matches!(
|
||||
&key,
|
||||
Key::Public(PropName::Ident(Ident {
|
||||
Key::Public(PropName::Ident(IdentName {
|
||||
sym: constructor,
|
||||
..
|
||||
})) | Key::Public(PropName::Str(Str {
|
||||
|
@ -1423,7 +1423,7 @@ impl<I: Tokens> Parser<I> {
|
||||
return Ok((
|
||||
Box::new(match obj {
|
||||
callee @ Callee::Import(_) => match prop {
|
||||
MemberProp::Ident(Ident { sym, .. }) => {
|
||||
MemberProp::Ident(IdentName { sym, .. }) => {
|
||||
if !self.ctx().can_be_module {
|
||||
let span = span!(self, start);
|
||||
self.emit_err(span, SyntaxError::ImportMetaInScript);
|
||||
|
@ -173,7 +173,7 @@ fn new_expr_should_not_eat_too_much() {
|
||||
Box::new(Expr::Member(MemberExpr {
|
||||
span,
|
||||
obj: member_expr("new Date()"),
|
||||
prop: MemberProp::Ident(Ident::new_no_ctxt("toString".into(), span)),
|
||||
prop: MemberProp::Ident(IdentName::new("toString".into(), span)),
|
||||
}))
|
||||
);
|
||||
}
|
||||
@ -439,10 +439,9 @@ fn super_expr() {
|
||||
callee: Callee::Expr(Box::new(Expr::SuperProp(SuperPropExpr {
|
||||
span,
|
||||
obj: Super { span },
|
||||
prop: SuperProp::Ident(Ident {
|
||||
prop: SuperProp::Ident(IdentName {
|
||||
span,
|
||||
sym: "foo".into(),
|
||||
..Default::default()
|
||||
})
|
||||
}))),
|
||||
..Default::default()
|
||||
|
@ -6,7 +6,7 @@ use super::*;
|
||||
use crate::token::{IdentLike, Keyword};
|
||||
|
||||
impl<I: Tokens> Parser<I> {
|
||||
pub(super) fn parse_maybe_private_name(&mut self) -> PResult<Either<PrivateName, Ident>> {
|
||||
pub(super) fn parse_maybe_private_name(&mut self) -> PResult<Either<PrivateName, IdentName>> {
|
||||
let is_private = is!(self, '#');
|
||||
|
||||
if is_private {
|
||||
@ -52,7 +52,7 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
/// Use this when spec says "IdentifierName".
|
||||
/// This allows idents like `catch`.
|
||||
pub(super) fn parse_ident_name(&mut self) -> PResult<Ident> {
|
||||
pub(super) fn parse_ident_name(&mut self) -> PResult<IdentName> {
|
||||
let in_type = self.ctx().in_type;
|
||||
|
||||
let start = cur_pos!(self);
|
||||
@ -71,7 +71,7 @@ impl<I: Tokens> Parser<I> {
|
||||
_ => syntax_error!(self, SyntaxError::ExpectedIdent),
|
||||
};
|
||||
|
||||
Ok(Ident::new_no_ctxt(w, span!(self, start)))
|
||||
Ok(IdentName::new(w, span!(self, start)))
|
||||
}
|
||||
|
||||
// https://tc39.es/ecma262/#prod-ModuleExportName
|
||||
@ -81,7 +81,7 @@ impl<I: Tokens> Parser<I> {
|
||||
Lit::Str(str_lit) => ModuleExportName::Str(str_lit),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
Ok(&Word(..)) => ModuleExportName::Ident(self.parse_ident_name()?),
|
||||
Ok(&Word(..)) => ModuleExportName::Ident(self.parse_ident_name()?.into()),
|
||||
_ => {
|
||||
unexpected!(self, "identifier or string");
|
||||
}
|
||||
|
@ -30,14 +30,16 @@ impl<I: Tokens> Parser<I> {
|
||||
pub(super) fn parse_jsx_namespaced_name(&mut self) -> PResult<JSXAttrName> {
|
||||
debug_assert!(self.input.syntax().jsx());
|
||||
trace_cur!(self, parse_jsx_namespaced_name);
|
||||
let start = cur_pos!(self);
|
||||
|
||||
let ns = self.parse_jsx_ident()?;
|
||||
let ns = self.parse_jsx_ident()?.into();
|
||||
if !eat!(self, ':') {
|
||||
return Ok(JSXAttrName::Ident(ns));
|
||||
}
|
||||
|
||||
let name = self.parse_jsx_ident()?;
|
||||
let name = self.parse_jsx_ident().map(IdentName::from)?;
|
||||
Ok(JSXAttrName::JSXNamespacedName(JSXNamespacedName {
|
||||
span: Span::new(start, name.span.hi),
|
||||
ns,
|
||||
name,
|
||||
}))
|
||||
@ -48,14 +50,16 @@ impl<I: Tokens> Parser<I> {
|
||||
pub(super) fn parse_jsx_element_name(&mut self) -> PResult<JSXElementName> {
|
||||
debug_assert!(self.input.syntax().jsx());
|
||||
trace_cur!(self, parse_jsx_element_name);
|
||||
let start = cur_pos!(self);
|
||||
|
||||
let mut node = match self.parse_jsx_namespaced_name()? {
|
||||
JSXAttrName::Ident(i) => JSXElementName::Ident(i),
|
||||
JSXAttrName::Ident(i) => JSXElementName::Ident(i.into()),
|
||||
JSXAttrName::JSXNamespacedName(i) => JSXElementName::JSXNamespacedName(i),
|
||||
};
|
||||
while eat!(self, '.') {
|
||||
let prop = self.parse_jsx_ident()?;
|
||||
let prop = self.parse_jsx_ident().map(IdentName::from)?;
|
||||
let new_node = JSXElementName::JSXMemberExpr(JSXMemberExpr {
|
||||
span: span!(self, start),
|
||||
obj: match node {
|
||||
JSXElementName::Ident(i) => JSXObject::Ident(i),
|
||||
JSXElementName::JSXMemberExpr(i) => JSXObject::JSXMemberExpr(Box::new(i)),
|
||||
@ -448,11 +452,11 @@ fn get_qualified_jsx_name(name: &JSXElementName) -> JsWord {
|
||||
}
|
||||
match *name {
|
||||
JSXElementName::Ident(ref i) => i.sym.clone(),
|
||||
JSXElementName::JSXNamespacedName(JSXNamespacedName { ref ns, ref name }) => {
|
||||
format!("{}:{}", ns.sym, name.sym).into()
|
||||
}
|
||||
JSXElementName::JSXMemberExpr(JSXMemberExpr { ref obj, ref prop }) => {
|
||||
format!("{}.{}", get_qualified_obj_name(obj), prop.sym).into()
|
||||
}
|
||||
JSXElementName::JSXNamespacedName(JSXNamespacedName {
|
||||
ref ns, ref name, ..
|
||||
}) => format!("{}:{}", ns.sym, name.sym).into(),
|
||||
JSXElementName::JSXMemberExpr(JSXMemberExpr {
|
||||
ref obj, ref prop, ..
|
||||
}) => format!("{}.{}", get_qualified_obj_name(obj), prop.sym).into(),
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ fn escape_in_attr() {
|
||||
span,
|
||||
attrs: vec![JSXAttrOrSpread::JSXAttr(JSXAttr {
|
||||
span,
|
||||
name: JSXAttrName::Ident(Ident::new_no_ctxt("id".into(), span)),
|
||||
name: JSXAttrName::Ident(IdentName::new("id".into(), span)),
|
||||
value: Some(JSXAttrValue::Lit(Lit::Str(Str {
|
||||
span,
|
||||
value: "w < w".into(),
|
||||
@ -97,7 +97,7 @@ fn issue_584() {
|
||||
name: JSXElementName::Ident(Ident::new_no_ctxt("test".into(), span)),
|
||||
attrs: vec![JSXAttrOrSpread::JSXAttr(JSXAttr {
|
||||
span,
|
||||
name: JSXAttrName::Ident(Ident::new_no_ctxt("other".into(), span)),
|
||||
name: JSXAttrName::Ident(IdentName::new("other".into(), span)),
|
||||
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
||||
span,
|
||||
expr: JSXExpr::Expr(Box::new(Expr::Lit(Lit::Num(Number {
|
||||
|
@ -77,7 +77,7 @@ impl<I: Tokens> Parser<I> {
|
||||
_ => unreachable!(),
|
||||
},
|
||||
Word(..) => match bump!(p) {
|
||||
Word(w) => PropName::Ident(Ident::new_no_ctxt(w.into(), span!(p, start))),
|
||||
Word(w) => PropName::Ident(IdentName::new(w.into(), span!(p, start))),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
tok!('[') => {
|
||||
@ -250,8 +250,10 @@ impl<I: Tokens> ParseObject<Box<Expr>> for Parser<I> {
|
||||
|
||||
if eat!(self, '=') {
|
||||
let value = self.include_in_expr(true).parse_assignment_expr()?;
|
||||
let span = span!(self, start);
|
||||
return Ok(PropOrSpread::Prop(Box::new(Prop::Assign(AssignProp {
|
||||
key: ident,
|
||||
span,
|
||||
key: ident.into(),
|
||||
value,
|
||||
}))));
|
||||
}
|
||||
|
@ -935,6 +935,10 @@ mod tests {
|
||||
Ident::new_no_ctxt(s.into(), span)
|
||||
}
|
||||
|
||||
fn ident_name(s: &str) -> IdentName {
|
||||
IdentName::new(s.into(), span)
|
||||
}
|
||||
|
||||
fn rest() -> Option<Pat> {
|
||||
Some(Pat::Rest(RestPat {
|
||||
span,
|
||||
@ -1173,7 +1177,7 @@ mod tests {
|
||||
span,
|
||||
props: vec![
|
||||
prop(
|
||||
PropName::Ident(ident("$")),
|
||||
PropName::Ident(ident_name("$")),
|
||||
"num",
|
||||
Expr::Lit(Lit::Num(Number {
|
||||
span,
|
||||
@ -1208,7 +1212,7 @@ mod tests {
|
||||
}))
|
||||
),
|
||||
prop(
|
||||
PropName::Ident(ident("_")),
|
||||
PropName::Ident(ident_name("_")),
|
||||
"under",
|
||||
Expr::Array(ArrayLit {
|
||||
span,
|
||||
|
@ -96,7 +96,7 @@ impl<I: Tokens> Parser<I> {
|
||||
local = self.parse_imported_default_binding()?;
|
||||
} else if peeked_is!(self, '=') {
|
||||
type_only = true;
|
||||
local = self.parse_ident_name()?;
|
||||
local = self.parse_ident_name().map(From::from)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -215,7 +215,7 @@ impl<I: Tokens> Parser<I> {
|
||||
// `import { type as as } from 'mod'`
|
||||
// `import { type as as as } from 'mod'`
|
||||
if self.syntax().typescript() && orig_name.sym == "type" && is!(self, IdentName) {
|
||||
let possibly_orig_name = self.parse_ident_name()?;
|
||||
let possibly_orig_name = self.parse_ident_name().map(Ident::from)?;
|
||||
if possibly_orig_name.sym == "as" {
|
||||
// `import { type as } from 'mod'`
|
||||
if !is!(self, IdentName) {
|
||||
@ -400,7 +400,12 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
// export import A = B
|
||||
return self
|
||||
.parse_ts_import_equals_decl(start, id, /* is_export */ true, is_type_only)
|
||||
.parse_ts_import_equals_decl(
|
||||
start,
|
||||
id.into(),
|
||||
/* is_export */ true,
|
||||
is_type_only,
|
||||
)
|
||||
.map(From::from);
|
||||
}
|
||||
|
||||
@ -740,7 +745,7 @@ impl<I: Tokens> Parser<I> {
|
||||
// `export { type as as }`
|
||||
// `export { type as as as }`
|
||||
if self.syntax().typescript() && orig_ident.sym == "type" && is!(self, IdentName) {
|
||||
let possibly_orig = self.parse_ident_name()?;
|
||||
let possibly_orig = self.parse_ident_name().map(Ident::from)?;
|
||||
if possibly_orig.sym == "as" {
|
||||
// `export { type as }`
|
||||
if !is!(self, IdentName) {
|
||||
@ -756,12 +761,12 @@ impl<I: Tokens> Parser<I> {
|
||||
});
|
||||
}
|
||||
|
||||
let maybe_as = self.parse_ident_name()?;
|
||||
let maybe_as = self.parse_ident_name().map(Ident::from)?;
|
||||
if maybe_as.sym == "as" {
|
||||
if is!(self, IdentName) {
|
||||
// `export { type as as as }`
|
||||
// `export { type as as foo }`
|
||||
let exported = self.parse_ident_name()?;
|
||||
let exported = self.parse_ident_name().map(Ident::from)?;
|
||||
|
||||
if type_only {
|
||||
self.emit_err(orig_ident.span, SyntaxError::TS2207);
|
||||
|
@ -186,6 +186,7 @@ impl<I: Tokens> Parser<I> {
|
||||
fn parse_ts_entity_name(&mut self, allow_reserved_words: bool) -> PResult<TsEntityName> {
|
||||
debug_assert!(self.input.syntax().typescript());
|
||||
trace_cur!(self, parse_ts_entity_name);
|
||||
let start = cur_pos!(self);
|
||||
|
||||
let init = self.parse_ident_name()?;
|
||||
if &*init.sym == "void" {
|
||||
@ -193,7 +194,7 @@ impl<I: Tokens> Parser<I> {
|
||||
let dot_span = span!(self, dot_start);
|
||||
self.emit_err(dot_span, SyntaxError::TS1005)
|
||||
}
|
||||
let mut entity = TsEntityName::Ident(init);
|
||||
let mut entity = TsEntityName::Ident(init.into());
|
||||
while eat!(self, '.') {
|
||||
let dot_start = cur_pos!(self);
|
||||
if !is!(self, '#') && !is!(self, IdentName) {
|
||||
@ -205,9 +206,10 @@ impl<I: Tokens> Parser<I> {
|
||||
let right = if allow_reserved_words {
|
||||
self.parse_ident_name()?
|
||||
} else {
|
||||
self.parse_ident(false, false)?
|
||||
self.parse_ident(false, false)?.into()
|
||||
};
|
||||
entity = TsEntityName::TsQualifiedName(Box::new(TsQualifiedName { left, right }));
|
||||
let span = span!(self, start);
|
||||
entity = TsEntityName::TsQualifiedName(Box::new(TsQualifiedName { span, left, right }));
|
||||
}
|
||||
|
||||
Ok(entity)
|
||||
@ -430,7 +432,7 @@ impl<I: Tokens> Parser<I> {
|
||||
};
|
||||
}
|
||||
|
||||
let name = self.in_type().parse_ident_name()?;
|
||||
let name = self.in_type().parse_ident_name()?.into();
|
||||
let constraint = self.eat_then_parse_ts_type(&tok!("extends"))?;
|
||||
let default = self.eat_then_parse_ts_type(&tok!('='))?;
|
||||
|
||||
@ -525,7 +527,7 @@ impl<I: Tokens> Parser<I> {
|
||||
let node = Box::new(TsType::TsTypePredicate(TsTypePredicate {
|
||||
span: span!(p, type_pred_start),
|
||||
asserts: has_type_pred_asserts,
|
||||
param_name: TsThisTypeOrIdent::Ident(type_pred_var),
|
||||
param_name: TsThisTypeOrIdent::Ident(type_pred_var.into()),
|
||||
type_ann,
|
||||
}));
|
||||
|
||||
@ -761,7 +763,10 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
TsEnumMemberId::Ident(Ident::new_no_ctxt(js_word!(""), span!(self, start)))
|
||||
}
|
||||
_ => self.parse_ident_name().map(TsEnumMemberId::from)?,
|
||||
_ => self
|
||||
.parse_ident_name()
|
||||
.map(Ident::from)
|
||||
.map(TsEnumMemberId::from)?,
|
||||
};
|
||||
|
||||
let init = if eat!(self, '=') {
|
||||
@ -801,7 +806,7 @@ impl<I: Tokens> Parser<I> {
|
||||
span: span!(self, start),
|
||||
declare: false,
|
||||
is_const,
|
||||
id,
|
||||
id: id.into(),
|
||||
members,
|
||||
}))
|
||||
}
|
||||
@ -854,7 +859,7 @@ impl<I: Tokens> Parser<I> {
|
||||
Ok(Box::new(TsModuleDecl {
|
||||
span: span!(self, start),
|
||||
declare: false,
|
||||
id: TsModuleName::Ident(id),
|
||||
id: TsModuleName::Ident(id.into()),
|
||||
body: Some(body),
|
||||
global: false,
|
||||
}))
|
||||
@ -869,7 +874,7 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
let (global, id) = if is!(self, "global") {
|
||||
let id = self.parse_ident_name()?;
|
||||
(true, TsModuleName::Ident(id))
|
||||
(true, TsModuleName::Ident(id.into()))
|
||||
} else if matches!(*cur!(self, true), Token::Str { .. }) {
|
||||
let id = self.parse_lit().map(|lit| match lit {
|
||||
Lit::Str(s) => TsModuleName::Str(s),
|
||||
@ -1022,7 +1027,7 @@ impl<I: Tokens> Parser<I> {
|
||||
// Note: TS uses parseLeftHandSideExpressionOrHigher,
|
||||
// then has grammar errors later if it's not an EntityName.
|
||||
|
||||
let ident = Box::new(Expr::Ident(self.parse_ident_name()?));
|
||||
let ident = Box::new(Expr::Ident(self.parse_ident_name()?.into()));
|
||||
let expr = self.parse_subscripts(Callee::Expr(ident), true, true)?;
|
||||
if !matches!(
|
||||
&*expr,
|
||||
@ -1099,7 +1104,7 @@ impl<I: Tokens> Parser<I> {
|
||||
Ok(Box::new(TsInterfaceDecl {
|
||||
span: span!(self, start),
|
||||
declare: false,
|
||||
id,
|
||||
id: id.into(),
|
||||
type_params,
|
||||
extends,
|
||||
body,
|
||||
@ -1120,7 +1125,7 @@ impl<I: Tokens> Parser<I> {
|
||||
Ok(Box::new(TsTypeAliasDecl {
|
||||
declare: false,
|
||||
span: span!(self, start),
|
||||
id,
|
||||
id: id.into(),
|
||||
type_params,
|
||||
type_ann,
|
||||
}))
|
||||
@ -1387,7 +1392,7 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
Box::new(Expr::PrivateName(e))
|
||||
}
|
||||
Either::Right(e) => Box::new(Expr::Ident(e)),
|
||||
Either::Right(e) => Box::new(Expr::Ident(e.into())),
|
||||
}),
|
||||
};
|
||||
|
||||
@ -1604,7 +1609,7 @@ impl<I: Tokens> Parser<I> {
|
||||
|
||||
Ok(TsTypeParam {
|
||||
span: span!(self, start),
|
||||
name,
|
||||
name: name.into(),
|
||||
is_in: false,
|
||||
is_out: false,
|
||||
is_const: false,
|
||||
@ -1723,7 +1728,7 @@ impl<I: Tokens> Parser<I> {
|
||||
None
|
||||
};
|
||||
|
||||
let mut ident = p.parse_ident_name()?;
|
||||
let mut ident = p.parse_ident_name().map(Ident::from)?;
|
||||
if eat!(p, '?') {
|
||||
ident.optional = true;
|
||||
ident.span = ident.span.with_hi(p.input.prev_span().hi);
|
||||
@ -2254,7 +2259,7 @@ impl<I: Tokens> Parser<I> {
|
||||
});
|
||||
let type_param = TsTypeParam {
|
||||
span: type_param_name.span(),
|
||||
name: type_param_name,
|
||||
name: type_param_name.into(),
|
||||
is_in: false,
|
||||
is_out: false,
|
||||
is_const: false,
|
||||
|
@ -62,12 +62,6 @@
|
||||
,-[$DIR/tests/comments/exprs/array/blockStmt/input.js:1:1]
|
||||
1 | React.useEffect(() => {
|
||||
: ^^^^^
|
||||
2 | // @refresh reset
|
||||
`----
|
||||
x Ident
|
||||
,-[$DIR/tests/comments/exprs/array/blockStmt/input.js:1:1]
|
||||
1 | React.useEffect(() => {
|
||||
: ^^^^^^^^^
|
||||
2 | // @refresh reset
|
||||
`----
|
||||
x ExprOrSpread
|
||||
|
@ -63,11 +63,6 @@
|
||||
1 | /*#__PURE__*/ (console.log('simple'))
|
||||
: ^^^^^^^
|
||||
`----
|
||||
x Ident
|
||||
,-[$DIR/tests/comments/exprs/paren-pure/1/input.js:1:1]
|
||||
1 | /*#__PURE__*/ (console.log('simple'))
|
||||
: ^^^
|
||||
`----
|
||||
x ExprOrSpread
|
||||
,-[$DIR/tests/comments/exprs/paren-pure/1/input.js:1:1]
|
||||
1 | /*#__PURE__*/ (console.log('simple'))
|
||||
|
@ -73,13 +73,6 @@
|
||||
9 | // a
|
||||
10 | console.log(1);
|
||||
: ^^^^^^^
|
||||
11 | // b
|
||||
`----
|
||||
x Ident
|
||||
,-[$DIR/tests/comments/issue-4876/input.js:10:1]
|
||||
9 | // a
|
||||
10 | console.log(1);
|
||||
: ^^^
|
||||
11 | // b
|
||||
`----
|
||||
x ExprOrSpread
|
||||
|
@ -102,7 +102,7 @@ impl Fold for Normalizer {
|
||||
}
|
||||
|
||||
match n {
|
||||
PropName::Ident(Ident { span, sym, .. }) => PropName::Str(Str {
|
||||
PropName::Ident(IdentName { span, sym, .. }) => PropName::Str(Str {
|
||||
span,
|
||||
value: sym,
|
||||
raw: None,
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 38,
|
||||
"end": 42
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "attr",
|
||||
"optional": false
|
||||
"value": "attr"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -66,9 +66,7 @@
|
||||
"start": 31,
|
||||
"end": 34
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
@ -125,9 +123,7 @@
|
||||
"start": 56,
|
||||
"end": 59
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
@ -203,9 +199,7 @@
|
||||
"start": 81,
|
||||
"end": 84
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
|
@ -70,9 +70,7 @@
|
||||
"start": 31,
|
||||
"end": 34
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
@ -132,9 +130,7 @@
|
||||
"start": 56,
|
||||
"end": 59
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
@ -213,9 +209,7 @@
|
||||
"start": 81,
|
||||
"end": 84
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "foo",
|
||||
"optional": false
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
|
@ -56,9 +56,7 @@
|
||||
"start": 22,
|
||||
"end": 26
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "with",
|
||||
"optional": false
|
||||
"value": "with"
|
||||
},
|
||||
"value": {
|
||||
"type": "ObjectExpression",
|
||||
@ -75,9 +73,7 @@
|
||||
"start": 30,
|
||||
"end": 34
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 38
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "for",
|
||||
"optional": false
|
||||
"value": "for"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -125,9 +123,7 @@
|
||||
"start": 86,
|
||||
"end": 89
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "for",
|
||||
"optional": false
|
||||
"value": "for"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -94,9 +94,7 @@
|
||||
"start": 41,
|
||||
"end": 45
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "with",
|
||||
"optional": false
|
||||
"value": "with"
|
||||
},
|
||||
"value": {
|
||||
"type": "ObjectExpression",
|
||||
@ -113,9 +111,7 @@
|
||||
"start": 49,
|
||||
"end": 53
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 30,
|
||||
"end": 34
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -134,9 +132,7 @@
|
||||
"start": 90,
|
||||
"end": 94
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 40,
|
||||
"end": 44
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -36,9 +36,7 @@
|
||||
"start": 33,
|
||||
"end": 37
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -66,9 +66,7 @@
|
||||
"start": 43,
|
||||
"end": 47
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -65,9 +65,7 @@
|
||||
"start": 45,
|
||||
"end": 49
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -66,9 +66,7 @@
|
||||
"start": 50,
|
||||
"end": 54
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -57,9 +57,7 @@
|
||||
"start": 43,
|
||||
"end": 47
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -79,9 +77,7 @@
|
||||
"start": 57,
|
||||
"end": 61
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "BooleanLiteral",
|
||||
@ -100,9 +96,7 @@
|
||||
"start": 69,
|
||||
"end": 80
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "startAtLine",
|
||||
"optional": false
|
||||
"value": "startAtLine"
|
||||
},
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
|
@ -57,9 +57,7 @@
|
||||
"start": 43,
|
||||
"end": 47
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -57,9 +57,7 @@
|
||||
"start": 43,
|
||||
"end": 47
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -79,9 +77,7 @@
|
||||
"start": 57,
|
||||
"end": 71
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "hasOwnProperty",
|
||||
"optional": false
|
||||
"value": "hasOwnProperty"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -37,9 +37,7 @@
|
||||
"start": 19,
|
||||
"end": 23
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -37,9 +37,7 @@
|
||||
"start": 19,
|
||||
"end": 23
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -77,9 +75,7 @@
|
||||
"start": 49,
|
||||
"end": 53
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "BooleanLiteral",
|
||||
@ -98,9 +94,7 @@
|
||||
"start": 61,
|
||||
"end": 72
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "startAtLine",
|
||||
"optional": false
|
||||
"value": "startAtLine"
|
||||
},
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -77,9 +75,7 @@
|
||||
"start": 49,
|
||||
"end": 63
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "hasOwnProperty",
|
||||
"optional": false
|
||||
"value": "hasOwnProperty"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -56,9 +56,7 @@
|
||||
"start": 22,
|
||||
"end": 28
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "assert",
|
||||
"optional": false
|
||||
"value": "assert"
|
||||
},
|
||||
"value": {
|
||||
"type": "ObjectExpression",
|
||||
@ -75,9 +73,7 @@
|
||||
"start": 32,
|
||||
"end": 36
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 37,
|
||||
"end": 40
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "for",
|
||||
"optional": false
|
||||
"value": "for"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -125,9 +123,7 @@
|
||||
"start": 90,
|
||||
"end": 93
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "for",
|
||||
"optional": false
|
||||
"value": "for"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -94,9 +94,7 @@
|
||||
"start": 41,
|
||||
"end": 47
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "assert",
|
||||
"optional": false
|
||||
"value": "assert"
|
||||
},
|
||||
"value": {
|
||||
"type": "ObjectExpression",
|
||||
@ -113,9 +111,7 @@
|
||||
"start": 51,
|
||||
"end": 55
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 32,
|
||||
"end": 36
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -134,9 +132,7 @@
|
||||
"start": 94,
|
||||
"end": 98
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -55,9 +55,7 @@
|
||||
"start": 42,
|
||||
"end": 46
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -36,9 +36,7 @@
|
||||
"start": 35,
|
||||
"end": 39
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -66,9 +66,7 @@
|
||||
"start": 45,
|
||||
"end": 49
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -65,9 +65,7 @@
|
||||
"start": 47,
|
||||
"end": 51
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -66,9 +66,7 @@
|
||||
"start": 52,
|
||||
"end": 56
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
@ -57,9 +57,7 @@
|
||||
"start": 45,
|
||||
"end": 49
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "type",
|
||||
"optional": false
|
||||
"value": "type"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
@ -79,9 +77,7 @@
|
||||
"start": 59,
|
||||
"end": 63
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "BooleanLiteral",
|
||||
@ -100,9 +96,7 @@
|
||||
"start": 71,
|
||||
"end": 82
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "startAtLine",
|
||||
"optional": false
|
||||
"value": "startAtLine"
|
||||
},
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
|
@ -57,9 +57,7 @@
|
||||
"start": 45,
|
||||
"end": 49
|
||||
},
|
||||
"ctxt": 0,
|
||||
"value": "lazy",
|
||||
"optional": false
|
||||
"value": "lazy"
|
||||
},
|
||||
"value": {
|
||||
"type": "StringLiteral",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user