fix(ast)!: rename BigintLiteral to BigIntLiteral (#2659)

This matches the case for the name in Babel. (in ESTree everything is a
`Literal`)
This commit is contained in:
Arnaud Barré 2024-03-10 06:31:51 +01:00 committed by GitHub
parent a01cf9f115
commit c3477de64e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 15 additions and 15 deletions

View file

@ -63,7 +63,7 @@ pub enum Expression<'a> {
BooleanLiteral(Box<'a, BooleanLiteral>),
NullLiteral(Box<'a, NullLiteral>),
NumericLiteral(Box<'a, NumericLiteral<'a>>),
BigintLiteral(Box<'a, BigintLiteral<'a>>),
BigintLiteral(Box<'a, BigIntLiteral<'a>>),
RegExpLiteral(Box<'a, RegExpLiteral<'a>>),
StringLiteral(Box<'a, StringLiteral<'a>>),
TemplateLiteral(Box<'a, TemplateLiteral<'a>>),

View file

@ -108,7 +108,7 @@ impl<'a> Hash for NumericLiteral<'a> {
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
pub struct BigintLiteral<'a> {
pub struct BigIntLiteral<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub span: Span,
pub raw: Atom<'a>,
@ -116,7 +116,7 @@ pub struct BigintLiteral<'a> {
pub base: BigintBase,
}
impl<'a> BigintLiteral<'a> {
impl<'a> BigIntLiteral<'a> {
pub fn is_zero(&self) -> bool {
self.raw == "0n"
}

View file

@ -82,7 +82,7 @@ pub enum TSLiteral<'a> {
BooleanLiteral(Box<'a, BooleanLiteral>),
NullLiteral(Box<'a, NullLiteral>),
NumericLiteral(Box<'a, NumericLiteral<'a>>),
BigintLiteral(Box<'a, BigintLiteral<'a>>),
BigintLiteral(Box<'a, BigIntLiteral<'a>>),
RegExpLiteral(Box<'a, RegExpLiteral<'a>>),
StringLiteral(Box<'a, StringLiteral<'a>>),
TemplateLiteral(Box<'a, TemplateLiteral<'a>>),

View file

@ -140,8 +140,8 @@ impl<'a> AstBuilder<'a> {
BooleanLiteral { span, value }
}
pub fn bigint_literal(&self, span: Span, raw: Atom<'a>, base: BigintBase) -> BigintLiteral<'a> {
BigintLiteral { span, raw, base }
pub fn bigint_literal(&self, span: Span, raw: Atom<'a>, base: BigintBase) -> BigIntLiteral<'a> {
BigIntLiteral { span, raw, base }
}
pub fn template_literal(
@ -199,7 +199,7 @@ impl<'a> AstBuilder<'a> {
Expression::NumericLiteral(self.alloc(literal))
}
pub fn literal_bigint_expression(&self, literal: BigintLiteral<'a>) -> Expression<'a> {
pub fn literal_bigint_expression(&self, literal: BigIntLiteral<'a>) -> Expression<'a> {
Expression::BigintLiteral(self.alloc(literal))
}

View file

@ -49,7 +49,7 @@ pub enum AstKind<'a> {
StringLiteral(&'a StringLiteral<'a>),
BooleanLiteral(&'a BooleanLiteral),
NullLiteral(&'a NullLiteral),
BigintLiteral(&'a BigintLiteral<'a>),
BigintLiteral(&'a BigIntLiteral<'a>),
RegExpLiteral(&'a RegExpLiteral<'a>),
TemplateLiteral(&'a TemplateLiteral<'a>),

View file

@ -1278,7 +1278,7 @@ pub trait Visit<'a>: Sized {
self.leave_node(kind);
}
fn visit_bigint_literal(&mut self, lit: &BigintLiteral<'a>) {
fn visit_bigint_literal(&mut self, lit: &BigIntLiteral<'a>) {
let kind = AstKind::BigintLiteral(self.alloc(lit));
self.enter_node(kind);
self.leave_node(kind);

View file

@ -1272,7 +1272,7 @@ pub trait VisitMut<'a>: Sized {
self.leave_node(kind);
}
fn visit_bigint_literal(&mut self, lit: &mut BigintLiteral<'a>) {
fn visit_bigint_literal(&mut self, lit: &mut BigIntLiteral<'a>) {
let kind = AstKind::BigintLiteral(self.alloc(lit));
self.enter_node(kind);
self.leave_node(kind);

View file

@ -1164,7 +1164,7 @@ fn print_non_negative_float<const MINIFY: bool>(value: f64, _p: &Codegen<{ MINIF
result
}
impl<'a, const MINIFY: bool> Gen<MINIFY> for BigintLiteral<'a> {
impl<'a, const MINIFY: bool> Gen<MINIFY> for BigIntLiteral<'a> {
fn gen(&self, p: &mut Codegen<{ MINIFY }>, _ctx: Context) {
p.add_source_mapping(self.span.start);
if self.raw.contains('_') {

View file

@ -1,6 +1,6 @@
use lazy_static::lazy_static;
use oxc_ast::{
ast::{BigintLiteral, NumericLiteral},
ast::{BigIntLiteral, NumericLiteral},
AstKind,
};
use oxc_diagnostics::{
@ -162,7 +162,7 @@ impl NumericSeparatorsStyle {
}
}
fn format_bigint(&self, number: &BigintLiteral, raw: &str) -> String {
fn format_bigint(&self, number: &BigIntLiteral, raw: &str) -> String {
use oxc_syntax::BigintBase;
let raw_without_bigint_n_suffix = &raw[..raw.len() - 1];

View file

@ -310,7 +310,7 @@ impl<'a> ParserImpl<'a> {
Ok(NumericLiteral::new(self.end_span(span), value, src, base))
}
pub(crate) fn parse_literal_bigint(&mut self) -> Result<BigintLiteral<'a>> {
pub(crate) fn parse_literal_bigint(&mut self) -> Result<BigIntLiteral<'a>> {
let span = self.start_span();
let base = match self.cur_kind() {
Kind::Decimal => BigintBase::Decimal,

View file

@ -1360,7 +1360,7 @@ impl<'a> Format<'a> for NumericLiteral<'a> {
}
}
impl<'a> Format<'a> for BigintLiteral<'a> {
impl<'a> Format<'a> for BigIntLiteral<'a> {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
let text = self.span.source_text(p.source_text);
// Perf: avoid a memory allocation from `to_ascii_lowercase`.