diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index ec9791e1b94c1..6ec29227da979 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1,6 +1,6 @@ // FIXME: lots of methods are missing docs. If you have time, it would be a huge help to add some :) #![warn(missing_docs)] -use std::{borrow::Cow, cell::Cell, fmt}; +use std::{borrow::Cow, fmt}; use oxc_allocator::{Address, Box, FromIn, GetAddress, Vec}; use oxc_span::{Atom, GetSpan, Span}; @@ -877,19 +877,6 @@ impl fmt::Display for VariableDeclarationKind { } } -impl<'a> ForStatement<'a> { - #[allow(missing_docs)] - pub fn new( - span: Span, - init: Option>, - test: Option>, - update: Option>, - body: Statement<'a>, - ) -> Self { - Self { span, init, test, update, body, scope_id: Cell::default() } - } -} - impl<'a> ForStatementInit<'a> { /// LexicalDeclaration[In, Yield, Await] : /// LetOrConst BindingList[?In, ?Yield, ?Await] ; @@ -898,31 +885,6 @@ impl<'a> ForStatementInit<'a> { } } -impl<'a> ForInStatement<'a> { - #[allow(missing_docs)] - pub fn new( - span: Span, - left: ForStatementLeft<'a>, - right: Expression<'a>, - body: Statement<'a>, - ) -> Self { - Self { span, left, right, body, scope_id: Cell::default() } - } -} - -impl<'a> ForOfStatement<'a> { - #[allow(missing_docs)] - pub fn new( - span: Span, - r#await: bool, - left: ForStatementLeft<'a>, - right: Expression<'a>, - body: Statement<'a>, - ) -> Self { - Self { span, r#await, left, right, body, scope_id: Cell::default() } - } -} - impl<'a> ForStatementLeft<'a> { /// LexicalDeclaration[In, Yield, Await] : /// LetOrConst BindingList[?In, ?Yield, ?Await] ; @@ -931,13 +893,6 @@ impl<'a> ForStatementLeft<'a> { } } -impl<'a> SwitchStatement<'a> { - #[allow(missing_docs)] - pub fn new(span: Span, discriminant: Expression<'a>, cases: Vec<'a, SwitchCase<'a>>) -> Self { - Self { span, discriminant, cases, scope_id: Cell::default() } - } -} - impl<'a> SwitchCase<'a> { /// `true` for `default:` cases. pub fn is_default_case(&self) -> bool { @@ -945,17 +900,6 @@ impl<'a> SwitchCase<'a> { } } -impl<'a> CatchClause<'a> { - #[allow(missing_docs)] - pub fn new( - span: Span, - param: Option>, - body: Box<'a, BlockStatement<'a>>, - ) -> Self { - Self { span, param, body, scope_id: Cell::default() } - } -} - impl<'a> BindingPattern<'a> { #[allow(missing_docs)] pub fn get_identifier(&self) -> Option> { @@ -1032,36 +976,6 @@ impl<'a> ArrayPattern<'a> { } impl<'a> Function<'a> { - #![allow(clippy::too_many_arguments, missing_docs)] - pub fn new( - r#type: FunctionType, - span: Span, - id: Option>, - generator: bool, - r#async: bool, - declare: bool, - this_param: Option>>, - params: Box<'a, FormalParameters<'a>>, - body: Option>>, - type_parameters: Option>>, - return_type: Option>>, - ) -> Self { - Self { - r#type, - span, - id, - generator, - r#async, - declare, - this_param, - params, - body, - type_parameters, - return_type, - scope_id: Cell::default(), - } - } - /// Returns this [`Function`]'s name, if it has one. #[inline] pub fn name(&self) -> Option> { @@ -1196,28 +1110,6 @@ impl<'a> FunctionBody<'a> { } impl<'a> ArrowFunctionExpression<'a> { - #[allow(missing_docs)] - pub fn new( - span: Span, - expression: bool, - r#async: bool, - params: Box<'a, FormalParameters<'a>>, - body: Box<'a, FunctionBody<'a>>, - type_parameters: Option>>, - return_type: Option>>, - ) -> Self { - Self { - span, - expression, - r#async, - params, - body, - type_parameters, - return_type, - scope_id: Cell::default(), - } - } - /// Get expression part of `ArrowFunctionExpression`: `() => expression_part`. pub fn get_expression(&self) -> Option<&Expression<'a>> { if self.expression { @@ -1230,36 +1122,6 @@ impl<'a> ArrowFunctionExpression<'a> { } impl<'a> Class<'a> { - #[allow(clippy::too_many_arguments, missing_docs)] - pub fn new( - r#type: ClassType, - span: Span, - decorators: Vec<'a, Decorator<'a>>, - id: Option>, - super_class: Option>, - body: Box<'a, ClassBody<'a>>, - type_parameters: Option>>, - super_type_parameters: Option>>, - implements: Option>>, - r#abstract: bool, - declare: bool, - ) -> Self { - Self { - r#type, - span, - decorators, - id, - super_class, - body, - type_parameters, - super_type_parameters, - implements, - r#abstract, - declare, - scope_id: Cell::default(), - } - } - /// `true` if this [`Class`] is an expression. /// /// For example, @@ -1481,20 +1343,6 @@ impl MethodDefinitionType { } } -impl<'a> PrivateIdentifier<'a> { - #[allow(missing_docs)] - pub fn new(span: Span, name: Atom<'a>) -> Self { - Self { span, name } - } -} - -impl<'a> StaticBlock<'a> { - #[allow(missing_docs)] - pub fn new(span: Span, body: Vec<'a, Statement<'a>>) -> Self { - Self { span, body, scope_id: Cell::default() } - } -} - impl<'a> ModuleDeclaration<'a> { #[allow(missing_docs)] pub fn is_typescript_syntax(&self) -> bool { @@ -1610,13 +1458,6 @@ impl<'a> ExportAllDeclaration<'a> { } } -impl<'a> ExportSpecifier<'a> { - #[allow(missing_docs)] - pub fn new(span: Span, local: ModuleExportName<'a>, exported: ModuleExportName<'a>) -> Self { - Self { span, local, exported, export_kind: ImportOrExportKind::Value } - } -} - impl<'a> ExportDefaultDeclarationKind<'a> { #[allow(missing_docs)] #[inline] diff --git a/crates/oxc_ast/src/ast_impl/jsx.rs b/crates/oxc_ast/src/ast_impl/jsx.rs index 651a6b3d6dbd0..46ff98cf3a959 100644 --- a/crates/oxc_ast/src/ast_impl/jsx.rs +++ b/crates/oxc_ast/src/ast_impl/jsx.rs @@ -2,7 +2,7 @@ #![warn(missing_docs)] use std::fmt; -use oxc_span::{Atom, Span}; +use oxc_span::Atom; use crate::ast::*; @@ -15,13 +15,6 @@ export type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression; // 1.2 JSX Elements -impl<'a> JSXIdentifier<'a> { - /// Create a new JSX identifier with the given `name`. - pub fn new(span: Span, name: Atom<'a>) -> Self { - Self { span, name } - } -} - impl<'a> fmt::Display for JSXIdentifier<'a> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/oxc_ast/src/ast_impl/literal.rs b/crates/oxc_ast/src/ast_impl/literal.rs index 0e12ff1cb3614..b71c52c2661a7 100644 --- a/crates/oxc_ast/src/ast_impl/literal.rs +++ b/crates/oxc_ast/src/ast_impl/literal.rs @@ -9,16 +9,11 @@ use std::{ use oxc_allocator::CloneIn; use oxc_regular_expression::ast::Pattern; -use oxc_span::{cmp::ContentEq, hash::ContentHash, Span}; +use oxc_span::{cmp::ContentEq, hash::ContentHash}; use crate::ast::*; impl BooleanLiteral { - /// Create a new boolean literal representing the given `value`. - pub fn new(span: Span, value: bool) -> Self { - Self { span, value } - } - /// `"true"` or `"false"` depending on this boolean's value. pub fn as_str(&self) -> &'static str { if self.value { @@ -43,13 +38,6 @@ impl ContentHash for NullLiteral { } } -impl NullLiteral { - /// Create a new `null` literal at the given location. - pub fn new(span: Span) -> Self { - Self { span } - } -} - impl fmt::Display for NullLiteral { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/oxc_ast/src/ast_impl/ts.rs b/crates/oxc_ast/src/ast_impl/ts.rs index 8e1d37e909c3f..e26e95c79c283 100644 --- a/crates/oxc_ast/src/ast_impl/ts.rs +++ b/crates/oxc_ast/src/ast_impl/ts.rs @@ -4,25 +4,12 @@ //! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md) #![warn(missing_docs)] -use std::{cell::Cell, fmt}; +use std::fmt; -use oxc_allocator::Vec; -use oxc_span::{Atom, Span}; +use oxc_span::Atom; use crate::ast::*; -impl<'a> TSEnumDeclaration<'a> { - /// Create a new enum declaration. - pub fn new( - span: Span, - id: BindingIdentifier<'a>, - members: Vec<'a, TSEnumMember<'a>>, - r#const: bool, - declare: bool, - ) -> Self { - Self { span, id, members, r#const, declare, scope_id: Cell::default() } - } -} impl<'a> TSEnumMemberName<'a> { /// Get the name of this enum member if it can be determined statically. pub fn static_name(&self) -> Option<&'a str> { @@ -187,17 +174,6 @@ impl fmt::Display for TSAccessibility { } impl<'a> TSModuleDeclaration<'a> { - /// Create a new module declaration with no bound scope. - pub fn new( - span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - ) -> Self { - Self { span, id, body, kind, declare, scope_id: Cell::default() } - } - /// Returns `true` if this module's body exists and uses strict mode /// semantics (as determined by [`TSModuleDeclarationBody::is_strict`]). pub fn is_strict(&self) -> bool {