Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::cell::Cell;
use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, UnstableAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, SourceType, Span};
use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Ident, SourceType, Span};
use oxc_syntax::{
operator::{
AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
Expand Down Expand Up @@ -234,7 +234,7 @@ pub use match_expression;
pub struct IdentifierName<'a> {
pub span: Span,
#[estree(json_safe)]
pub name: Atom<'a>,
pub name: Ident<'a>,
}

/// `x` inside `func` in `const x = 0; function func() { console.log(x); }`
Expand All @@ -254,7 +254,7 @@ pub struct IdentifierReference<'a> {
pub span: Span,
/// The name of the identifier being referenced.
#[estree(json_safe)]
pub name: Atom<'a>,
pub name: Ident<'a>,
/// Reference ID
///
/// Identifies what identifier this refers to, and how it is used. This is
Expand Down Expand Up @@ -283,7 +283,7 @@ pub struct BindingIdentifier<'a> {
pub span: Span,
/// The identifier name being bound.
#[estree(json_safe)]
pub name: Atom<'a>,
pub name: Ident<'a>,
/// Unique identifier for this binding.
///
/// This gets initialized during [`semantic analysis`] in the bind step. If
Expand All @@ -309,7 +309,7 @@ pub struct BindingIdentifier<'a> {
pub struct LabelIdentifier<'a> {
pub span: Span,
#[estree(json_safe)]
pub name: Atom<'a>,
pub name: Ident<'a>,
}

/// `this` in `return this.prop;`
Expand Down Expand Up @@ -2282,7 +2282,7 @@ pub enum MethodDefinitionKind {
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct PrivateIdentifier<'a> {
pub span: Span,
pub name: Atom<'a>,
pub name: Ident<'a>,
}

/// Class Static Block
Expand Down
18 changes: 9 additions & 9 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
fmt::{self, Display},
};

use oxc_span::{Atom, GetSpan, Span};
use oxc_span::{Atom, GetSpan, Ident, Span};
use oxc_syntax::{operator::UnaryOperator, scope::ScopeFlags};

use crate::ast::*;
Expand Down Expand Up @@ -502,7 +502,7 @@ impl<'a> PropertyKey<'a> {
///
/// - `#a: 1` in `class C { #a: 1 }` would return `a`
/// - `a: 1` in `{ a: 1 }` would return `None`
pub fn private_name(&self) -> Option<Atom<'a>> {
pub fn private_name(&self) -> Option<Ident<'a>> {
match self {
Self::PrivateIdentifier(ident) => Some(ident.name),
_ => None,
Expand Down Expand Up @@ -1259,7 +1259,7 @@ impl<'a> BindingPattern<'a> {
/// - calling on `a = 1` in `let a = 1` would return `Some("a")`
/// - calling on `a = 1` in `let {a = 1} = c` would return `Some("a")`
/// - calling on `a: b` in `let {a: b} = c` would return `None`
pub fn get_identifier_name(&self) -> Option<Atom<'a>> {
pub fn get_identifier_name(&self) -> Option<Ident<'a>> {
match self {
Self::BindingIdentifier(ident) => Some(ident.name),
Self::AssignmentPattern(assign) => assign.left.get_identifier_name(),
Expand Down Expand Up @@ -1424,7 +1424,7 @@ impl ArrayPattern<'_> {
impl<'a> Function<'a> {
/// Returns this [`Function`]'s name, if it has one.
#[inline]
pub fn name(&self) -> Option<Atom<'a>> {
pub fn name(&self) -> Option<Ident<'a>> {
self.id.as_ref().map(|id| id.name)
}

Expand Down Expand Up @@ -1580,7 +1580,7 @@ impl<'a> ArrowFunctionExpression<'a> {
impl<'a> Class<'a> {
/// Returns this [`Class`]'s name, if it has one.
#[inline]
pub fn name(&self) -> Option<Atom<'a>> {
pub fn name(&self) -> Option<Ident<'a>> {
self.id.as_ref().map(|id| id.name)
}

Expand Down Expand Up @@ -1927,7 +1927,7 @@ impl<'a> ImportAttributeKey<'a> {
/// Returns the string value of this import attribute key.
pub fn as_atom(&self) -> Atom<'a> {
match self {
Self::Identifier(identifier) => identifier.name,
Self::Identifier(identifier) => identifier.name.into(),
Self::StringLiteral(literal) => literal.value,
}
}
Expand Down Expand Up @@ -1988,8 +1988,8 @@ impl<'a> ModuleExportName<'a> {
/// - `export { foo as "anything" }` => `"anything"`
pub fn name(&self) -> Atom<'a> {
match self {
Self::IdentifierName(identifier) => identifier.name,
Self::IdentifierReference(identifier) => identifier.name,
Self::IdentifierName(identifier) => identifier.name.into(),
Self::IdentifierReference(identifier) => identifier.name.into(),
Self::StringLiteral(literal) => literal.value,
}
}
Expand All @@ -2001,7 +2001,7 @@ impl<'a> ModuleExportName<'a> {
/// - `export { foo }` => `Some("foo")`
/// - `export { foo as bar }` => `Some("bar")`
/// - `export { foo as "anything" }` => `None`
pub fn identifier_name(&self) -> Option<Atom<'a>> {
pub fn identifier_name(&self) -> Option<Ident<'a>> {
match self {
Self::IdentifierName(identifier) => Some(identifier.name),
Self::IdentifierReference(identifier) => Some(identifier.name),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a> JSXElementName<'a> {
pub fn get_identifier_name(&self) -> Option<Atom<'a>> {
match self {
Self::Identifier(id) => Some(id.as_ref().name),
Self::IdentifierReference(id) => Some(id.as_ref().name),
Self::IdentifierReference(id) => Some(id.as_ref().name.into()),
_ => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/ast_impl/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a> TSEnumMemberName<'a> {
/// Panics if `self` is a `TemplateString` with no quasi.
pub fn static_name(&self) -> Atom<'a> {
match self {
Self::Identifier(ident) => ident.name,
Self::Identifier(ident) => ident.name.into(),
Self::String(lit) | Self::ComputedString(lit) => lit.value,
Self::ComputedTemplateString(template) => template
.single_quasi()
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<'a> TSModuleDeclarationName<'a> {
/// Get the static name of this module declaration name.
pub fn name(&self) -> Atom<'a> {
match self {
Self::Identifier(ident) => ident.name,
Self::Identifier(ident) => ident.name.into(),
Self::StringLiteral(lit) => lit.value,
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! including type checking, conversions, and tree traversal helpers.

use oxc_allocator::{Address, GetAddress, UnstableAddress};
use oxc_span::{Atom, GetSpan};
use oxc_span::{Atom, GetSpan, Ident};

use super::{AstKind, ast::*};

Expand Down Expand Up @@ -174,7 +174,7 @@ impl<'a> AstKind<'a> {
///
/// Returns the identifier name if this is any kind of identifier node,
/// `None` otherwise.
pub fn identifier_name(self) -> Option<Atom<'a>> {
pub fn identifier_name(self) -> Option<Ident<'a>> {
match self {
Self::BindingIdentifier(ident) => Some(ident.name),
Self::IdentifierReference(ident) => Some(ident.name),
Expand Down Expand Up @@ -392,7 +392,7 @@ impl AstKind<'_> {
Self::VariableDeclaration(_) => "VariableDeclaration".into(),
Self::VariableDeclarator(v) => format!(
"VariableDeclarator({})",
v.id.get_identifier_name().unwrap_or(Atom::from(DESTRUCTURE.as_ref()))
v.id.get_identifier_name().unwrap_or(Ident::from(DESTRUCTURE.as_ref()))
)
.into(),

Expand Down Expand Up @@ -474,7 +474,7 @@ impl AstKind<'_> {
Self::FormalParameters(_) => "FormalParameters".into(),
Self::FormalParameter(p) => format!(
"FormalParameter({})",
p.pattern.get_identifier_name().unwrap_or(Atom::from(DESTRUCTURE.as_ref()))
p.pattern.get_identifier_name().unwrap_or(Ident::from(DESTRUCTURE.as_ref()))
)
.into(),
Self::FormalParameterRest(_) => "FormalParameterRest".into(),
Expand Down Expand Up @@ -629,7 +629,7 @@ impl<'a> MemberExpressionKind<'a> {
pub fn static_property_name(&self) -> Option<Atom<'a>> {
match self {
Self::Computed(member_expr) => member_expr.static_property_name(),
Self::Static(member_expr) => Some(member_expr.property.name),
Self::Static(member_expr) => Some(member_expr.property.name.into()),
Self::PrivateField(_) => None,
}
}
Expand Down
Loading
Loading