mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
refactor(ast)!: remove unused new methods (#6789)
This commit is contained in:
parent
4d2d214ec7
commit
718ccded34
4 changed files with 5 additions and 207 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
// FIXME: lots of methods are missing docs. If you have time, it would be a huge help to add some :)
|
// FIXME: lots of methods are missing docs. If you have time, it would be a huge help to add some :)
|
||||||
#![warn(missing_docs)]
|
#![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_allocator::{Address, Box, FromIn, GetAddress, Vec};
|
||||||
use oxc_span::{Atom, GetSpan, Span};
|
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<ForStatementInit<'a>>,
|
|
||||||
test: Option<Expression<'a>>,
|
|
||||||
update: Option<Expression<'a>>,
|
|
||||||
body: Statement<'a>,
|
|
||||||
) -> Self {
|
|
||||||
Self { span, init, test, update, body, scope_id: Cell::default() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ForStatementInit<'a> {
|
impl<'a> ForStatementInit<'a> {
|
||||||
/// LexicalDeclaration[In, Yield, Await] :
|
/// LexicalDeclaration[In, Yield, Await] :
|
||||||
/// LetOrConst BindingList[?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> {
|
impl<'a> ForStatementLeft<'a> {
|
||||||
/// LexicalDeclaration[In, Yield, Await] :
|
/// LexicalDeclaration[In, Yield, Await] :
|
||||||
/// LetOrConst BindingList[?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> {
|
impl<'a> SwitchCase<'a> {
|
||||||
/// `true` for `default:` cases.
|
/// `true` for `default:` cases.
|
||||||
pub fn is_default_case(&self) -> bool {
|
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<CatchParameter<'a>>,
|
|
||||||
body: Box<'a, BlockStatement<'a>>,
|
|
||||||
) -> Self {
|
|
||||||
Self { span, param, body, scope_id: Cell::default() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> BindingPattern<'a> {
|
impl<'a> BindingPattern<'a> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn get_identifier(&self) -> Option<Atom<'a>> {
|
pub fn get_identifier(&self) -> Option<Atom<'a>> {
|
||||||
|
|
@ -1032,36 +976,6 @@ impl<'a> ArrayPattern<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Function<'a> {
|
impl<'a> Function<'a> {
|
||||||
#![allow(clippy::too_many_arguments, missing_docs)]
|
|
||||||
pub fn new(
|
|
||||||
r#type: FunctionType,
|
|
||||||
span: Span,
|
|
||||||
id: Option<BindingIdentifier<'a>>,
|
|
||||||
generator: bool,
|
|
||||||
r#async: bool,
|
|
||||||
declare: bool,
|
|
||||||
this_param: Option<Box<'a, TSThisParameter<'a>>>,
|
|
||||||
params: Box<'a, FormalParameters<'a>>,
|
|
||||||
body: Option<Box<'a, FunctionBody<'a>>>,
|
|
||||||
type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
|
||||||
return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
|
||||||
) -> 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.
|
/// Returns this [`Function`]'s name, if it has one.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn name(&self) -> Option<Atom<'a>> {
|
pub fn name(&self) -> Option<Atom<'a>> {
|
||||||
|
|
@ -1196,28 +1110,6 @@ impl<'a> FunctionBody<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ArrowFunctionExpression<'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<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
|
||||||
return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
span,
|
|
||||||
expression,
|
|
||||||
r#async,
|
|
||||||
params,
|
|
||||||
body,
|
|
||||||
type_parameters,
|
|
||||||
return_type,
|
|
||||||
scope_id: Cell::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get expression part of `ArrowFunctionExpression`: `() => expression_part`.
|
/// Get expression part of `ArrowFunctionExpression`: `() => expression_part`.
|
||||||
pub fn get_expression(&self) -> Option<&Expression<'a>> {
|
pub fn get_expression(&self) -> Option<&Expression<'a>> {
|
||||||
if self.expression {
|
if self.expression {
|
||||||
|
|
@ -1230,36 +1122,6 @@ impl<'a> ArrowFunctionExpression<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Class<'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<BindingIdentifier<'a>>,
|
|
||||||
super_class: Option<Expression<'a>>,
|
|
||||||
body: Box<'a, ClassBody<'a>>,
|
|
||||||
type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
|
||||||
super_type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
|
||||||
implements: Option<Vec<'a, TSClassImplements<'a>>>,
|
|
||||||
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.
|
/// `true` if this [`Class`] is an expression.
|
||||||
///
|
///
|
||||||
/// For example,
|
/// 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> {
|
impl<'a> ModuleDeclaration<'a> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn is_typescript_syntax(&self) -> bool {
|
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> {
|
impl<'a> ExportDefaultDeclarationKind<'a> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use oxc_span::{Atom, Span};
|
use oxc_span::Atom;
|
||||||
|
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
||||||
|
|
@ -15,13 +15,6 @@ export type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression;
|
||||||
|
|
||||||
// 1.2 JSX Elements
|
// 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> {
|
impl<'a> fmt::Display for JSXIdentifier<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,11 @@ use std::{
|
||||||
|
|
||||||
use oxc_allocator::CloneIn;
|
use oxc_allocator::CloneIn;
|
||||||
use oxc_regular_expression::ast::Pattern;
|
use oxc_regular_expression::ast::Pattern;
|
||||||
use oxc_span::{cmp::ContentEq, hash::ContentHash, Span};
|
use oxc_span::{cmp::ContentEq, hash::ContentHash};
|
||||||
|
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
||||||
impl BooleanLiteral {
|
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.
|
/// `"true"` or `"false"` depending on this boolean's value.
|
||||||
pub fn as_str(&self) -> &'static str {
|
pub fn as_str(&self) -> &'static str {
|
||||||
if self.value {
|
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 {
|
impl fmt::Display for NullLiteral {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
|
|
||||||
|
|
@ -4,25 +4,12 @@
|
||||||
//! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)
|
//! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
use std::{cell::Cell, fmt};
|
use std::fmt;
|
||||||
|
|
||||||
use oxc_allocator::Vec;
|
use oxc_span::Atom;
|
||||||
use oxc_span::{Atom, Span};
|
|
||||||
|
|
||||||
use crate::ast::*;
|
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> {
|
impl<'a> TSEnumMemberName<'a> {
|
||||||
/// Get the name of this enum member if it can be determined statically.
|
/// Get the name of this enum member if it can be determined statically.
|
||||||
pub fn static_name(&self) -> Option<&'a str> {
|
pub fn static_name(&self) -> Option<&'a str> {
|
||||||
|
|
@ -187,17 +174,6 @@ impl fmt::Display for TSAccessibility {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TSModuleDeclaration<'a> {
|
impl<'a> TSModuleDeclaration<'a> {
|
||||||
/// Create a new module declaration with no bound scope.
|
|
||||||
pub fn new(
|
|
||||||
span: Span,
|
|
||||||
id: TSModuleDeclarationName<'a>,
|
|
||||||
body: Option<TSModuleDeclarationBody<'a>>,
|
|
||||||
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
|
/// Returns `true` if this module's body exists and uses strict mode
|
||||||
/// semantics (as determined by [`TSModuleDeclarationBody::is_strict`]).
|
/// semantics (as determined by [`TSModuleDeclarationBody::is_strict`]).
|
||||||
pub fn is_strict(&self) -> bool {
|
pub fn is_strict(&self) -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue