Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
refactor(js_ungram): normalize BigInt to Bigint (#4139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Feb 3, 2023
1 parent 5ef7a1d commit 8a229d4
Show file tree
Hide file tree
Showing 29 changed files with 210 additions and 210 deletions.
20 changes: 10 additions & 10 deletions crates/rome_js_factory/src/generated/node_factory.rs

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

16 changes: 8 additions & 8 deletions crates/rome_js_factory/src/generated/syntax_factory.rs

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

48 changes: 24 additions & 24 deletions crates/rome_js_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5426,36 +5426,36 @@ impl IntoFormat<JsFormatContext> for rome_js_syntax::JsNumberLiteralExpression {
FormatOwnedWithRule :: new (self , crate :: js :: expressions :: number_literal_expression :: FormatJsNumberLiteralExpression :: default ())
}
}
impl FormatRule<rome_js_syntax::JsBigIntLiteralExpression>
for crate::js::expressions::big_int_literal_expression::FormatJsBigIntLiteralExpression
impl FormatRule<rome_js_syntax::JsBigintLiteralExpression>
for crate::js::expressions::bigint_literal_expression::FormatJsBigintLiteralExpression
{
type Context = JsFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &rome_js_syntax::JsBigIntLiteralExpression,
node: &rome_js_syntax::JsBigintLiteralExpression,
f: &mut JsFormatter,
) -> FormatResult<()> {
FormatNodeRule::<rome_js_syntax::JsBigIntLiteralExpression>::fmt(self, node, f)
FormatNodeRule::<rome_js_syntax::JsBigintLiteralExpression>::fmt(self, node, f)
}
}
impl AsFormat<JsFormatContext> for rome_js_syntax::JsBigIntLiteralExpression {
impl AsFormat<JsFormatContext> for rome_js_syntax::JsBigintLiteralExpression {
type Format<'a> = FormatRefWithRule<
'a,
rome_js_syntax::JsBigIntLiteralExpression,
crate::js::expressions::big_int_literal_expression::FormatJsBigIntLiteralExpression,
rome_js_syntax::JsBigintLiteralExpression,
crate::js::expressions::bigint_literal_expression::FormatJsBigintLiteralExpression,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule :: new (self , crate :: js :: expressions :: big_int_literal_expression :: FormatJsBigIntLiteralExpression :: default ())
FormatRefWithRule :: new (self , crate :: js :: expressions :: bigint_literal_expression :: FormatJsBigintLiteralExpression :: default ())
}
}
impl IntoFormat<JsFormatContext> for rome_js_syntax::JsBigIntLiteralExpression {
impl IntoFormat<JsFormatContext> for rome_js_syntax::JsBigintLiteralExpression {
type Format = FormatOwnedWithRule<
rome_js_syntax::JsBigIntLiteralExpression,
crate::js::expressions::big_int_literal_expression::FormatJsBigIntLiteralExpression,
rome_js_syntax::JsBigintLiteralExpression,
crate::js::expressions::bigint_literal_expression::FormatJsBigintLiteralExpression,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule :: new (self , crate :: js :: expressions :: big_int_literal_expression :: FormatJsBigIntLiteralExpression :: default ())
FormatOwnedWithRule :: new (self , crate :: js :: expressions :: bigint_literal_expression :: FormatJsBigintLiteralExpression :: default ())
}
}
impl FormatRule<rome_js_syntax::JsBooleanLiteralExpression>
Expand Down Expand Up @@ -7474,41 +7474,41 @@ impl IntoFormat<JsFormatContext> for rome_js_syntax::TsNumberLiteralType {
)
}
}
impl FormatRule<rome_js_syntax::TsBigIntLiteralType>
for crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType
impl FormatRule<rome_js_syntax::TsBigintLiteralType>
for crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType
{
type Context = JsFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &rome_js_syntax::TsBigIntLiteralType,
node: &rome_js_syntax::TsBigintLiteralType,
f: &mut JsFormatter,
) -> FormatResult<()> {
FormatNodeRule::<rome_js_syntax::TsBigIntLiteralType>::fmt(self, node, f)
FormatNodeRule::<rome_js_syntax::TsBigintLiteralType>::fmt(self, node, f)
}
}
impl AsFormat<JsFormatContext> for rome_js_syntax::TsBigIntLiteralType {
impl AsFormat<JsFormatContext> for rome_js_syntax::TsBigintLiteralType {
type Format<'a> = FormatRefWithRule<
'a,
rome_js_syntax::TsBigIntLiteralType,
crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType,
rome_js_syntax::TsBigintLiteralType,
crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType::default(),
crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType::default(),
)
}
}
impl IntoFormat<JsFormatContext> for rome_js_syntax::TsBigIntLiteralType {
impl IntoFormat<JsFormatContext> for rome_js_syntax::TsBigintLiteralType {
type Format = FormatOwnedWithRule<
rome_js_syntax::TsBigIntLiteralType,
crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType,
rome_js_syntax::TsBigintLiteralType,
crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType::default(),
crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType::default(),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/src/js/any/literal_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl FormatRule<AnyJsLiteralExpression> for FormatAnyJsLiteralExpression {
match node {
AnyJsLiteralExpression::JsStringLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsNumberLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsBigIntLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsBigintLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsBooleanLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsNullLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsRegexLiteralExpression(node) => node.format().fmt(f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ use std::borrow::Cow;
use crate::prelude::*;

use crate::parentheses::NeedsParentheses;
use rome_js_syntax::JsBigIntLiteralExpressionFields;
use rome_js_syntax::{JsBigIntLiteralExpression, JsSyntaxNode};
use rome_js_syntax::JsBigintLiteralExpressionFields;
use rome_js_syntax::{JsBigintLiteralExpression, JsSyntaxNode};

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsBigIntLiteralExpression;
pub(crate) struct FormatJsBigintLiteralExpression;

impl FormatNodeRule<JsBigIntLiteralExpression> for FormatJsBigIntLiteralExpression {
impl FormatNodeRule<JsBigintLiteralExpression> for FormatJsBigintLiteralExpression {
fn fmt_fields(
&self,
node: &JsBigIntLiteralExpression,
node: &JsBigintLiteralExpression,
f: &mut JsFormatter,
) -> FormatResult<()> {
let JsBigIntLiteralExpressionFields { value_token } = node.as_fields();
let JsBigintLiteralExpressionFields { value_token } = node.as_fields();
let value_token = value_token?;

let original = value_token.text_trimmed();
Expand All @@ -35,12 +35,12 @@ impl FormatNodeRule<JsBigIntLiteralExpression> for FormatJsBigIntLiteralExpressi
}
}

fn needs_parentheses(&self, item: &JsBigIntLiteralExpression) -> bool {
fn needs_parentheses(&self, item: &JsBigintLiteralExpression) -> bool {
item.needs_parentheses()
}
}

impl NeedsParentheses for JsBigIntLiteralExpression {
impl NeedsParentheses for JsBigintLiteralExpression {
#[inline(always)]
fn needs_parentheses(&self) -> bool {
false
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/src/js/expressions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub(crate) mod array_expression;
pub(crate) mod arrow_function_expression;
pub(crate) mod assignment_expression;
pub(crate) mod await_expression;
pub(crate) mod big_int_literal_expression;
pub(crate) mod bigint_literal_expression;
pub(crate) mod binary_expression;
pub(crate) mod boolean_literal_expression;
pub(crate) mod call_arguments;
Expand Down
8 changes: 4 additions & 4 deletions crates/rome_js_formatter/src/parentheses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl NeedsParentheses for AnyJsLiteralExpression {
#[inline]
fn needs_parentheses(&self) -> bool {
match self {
AnyJsLiteralExpression::JsBigIntLiteralExpression(big_int) => {
AnyJsLiteralExpression::JsBigintLiteralExpression(big_int) => {
big_int.needs_parentheses()
}
AnyJsLiteralExpression::JsBooleanLiteralExpression(boolean) => {
Expand All @@ -89,7 +89,7 @@ impl NeedsParentheses for AnyJsLiteralExpression {
#[inline]
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
match self {
AnyJsLiteralExpression::JsBigIntLiteralExpression(big_int) => {
AnyJsLiteralExpression::JsBigintLiteralExpression(big_int) => {
big_int.needs_parentheses_with_parent(parent)
}
AnyJsLiteralExpression::JsBooleanLiteralExpression(boolean) => {
Expand Down Expand Up @@ -945,7 +945,7 @@ impl NeedsParentheses for AnyTsType {
match self {
AnyTsType::TsAnyType(ty) => ty.needs_parentheses(),
AnyTsType::TsArrayType(ty) => ty.needs_parentheses(),
AnyTsType::TsBigIntLiteralType(ty) => ty.needs_parentheses(),
AnyTsType::TsBigintLiteralType(ty) => ty.needs_parentheses(),
AnyTsType::TsBigintType(ty) => ty.needs_parentheses(),
AnyTsType::TsBooleanLiteralType(ty) => ty.needs_parentheses(),
AnyTsType::TsBooleanType(ty) => ty.needs_parentheses(),
Expand Down Expand Up @@ -985,7 +985,7 @@ impl NeedsParentheses for AnyTsType {
match self {
AnyTsType::TsAnyType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsArrayType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsBigIntLiteralType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsBigintLiteralType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsBigintType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsBooleanLiteralType(ty) => ty.needs_parentheses_with_parent(parent),
AnyTsType::TsBooleanType(ty) => ty.needs_parentheses_with_parent(parent),
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/src/ts/any/ts_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl FormatRule<AnyTsType> for FormatAnyTsType {
AnyTsType::TsNonPrimitiveType(node) => node.format().fmt(f),
AnyTsType::TsThisType(node) => node.format().fmt(f),
AnyTsType::TsNumberLiteralType(node) => node.format().fmt(f),
AnyTsType::TsBigIntLiteralType(node) => node.format().fmt(f),
AnyTsType::TsBigintLiteralType(node) => node.format().fmt(f),
AnyTsType::TsStringLiteralType(node) => node.format().fmt(f),
AnyTsType::TsNullLiteralType(node) => node.format().fmt(f),
AnyTsType::TsBooleanLiteralType(node) => node.format().fmt(f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::ts::bogus::bogus_type::FormatTsBogusType;
use crate::ts::module::import_type::FormatTsImportType;
use crate::ts::types::any_type::FormatTsAnyType;
use crate::ts::types::array_type::FormatTsArrayType;
use crate::ts::types::big_int_literal_type::FormatTsBigIntLiteralType;
use crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType;
use crate::ts::types::bigint_type::FormatTsBigintType;
use crate::ts::types::boolean_literal_type::FormatTsBooleanLiteralType;
use crate::ts::types::boolean_type::FormatTsBooleanType;
Expand Down Expand Up @@ -97,8 +97,8 @@ impl Format<JsFormatContext> for FormatTypeVariant<'_> {
match node {
AnyTsType::TsAnyType(ty) => FormatTsAnyType::default().fmt_node(ty, f),
AnyTsType::TsArrayType(ty) => FormatTsArrayType::default().fmt_node(ty, f),
AnyTsType::TsBigIntLiteralType(ty) => {
FormatTsBigIntLiteralType::default().fmt_node(ty, f)
AnyTsType::TsBigintLiteralType(ty) => {
FormatTsBigintLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsBigintType(ty) => FormatTsBigintType::default().fmt_node(ty, f),
AnyTsType::TsBooleanLiteralType(ty) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::token::string::ToAsciiLowercaseCow;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsBigIntLiteralType, TsBigIntLiteralTypeFields};
use rome_js_syntax::{JsSyntaxNode, TsBigintLiteralType, TsBigintLiteralTypeFields};

#[derive(Debug, Clone, Default)]
pub struct FormatTsBigIntLiteralType;
pub struct FormatTsBigintLiteralType;

impl FormatNodeRule<TsBigIntLiteralType> for FormatTsBigIntLiteralType {
fn fmt_fields(&self, node: &TsBigIntLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBigIntLiteralTypeFields {
impl FormatNodeRule<TsBigintLiteralType> for FormatTsBigintLiteralType {
fn fmt_fields(&self, node: &TsBigintLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBigintLiteralTypeFields {
minus_token,
literal_token,
} = node.as_fields();
Expand All @@ -34,12 +34,12 @@ impl FormatNodeRule<TsBigIntLiteralType> for FormatTsBigIntLiteralType {
}
}

fn needs_parentheses(&self, item: &TsBigIntLiteralType) -> bool {
fn needs_parentheses(&self, item: &TsBigintLiteralType) -> bool {
item.needs_parentheses()
}
}

impl NeedsParentheses for TsBigIntLiteralType {
impl NeedsParentheses for TsBigintLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/src/ts/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub(crate) mod any_type;
pub(crate) mod array_type;
pub(crate) mod asserts_return_type;
pub(crate) mod big_int_literal_type;
pub(crate) mod bigint_literal_type;
pub(crate) mod bigint_type;
pub(crate) mod boolean_literal_type;
pub(crate) mod boolean_type;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_formatter/src/utils/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(crate) fn is_simple_type(ty: &AnyTsType) -> bool {
| AnyTsType::TsBooleanType(_)
| AnyTsType::TsBooleanLiteralType(_)
| AnyTsType::TsBigintType(_)
| AnyTsType::TsBigIntLiteralType(_)
| AnyTsType::TsBigintLiteralType(_)
| AnyTsType::TsStringType(_)
| AnyTsType::TsStringLiteralType(_)
| AnyTsType::TsSymbolType(_)
Expand Down
Loading

0 comments on commit 8a229d4

Please sign in to comment.