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
161 changes: 1 addition & 160 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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> {
/// LexicalDeclaration[In, Yield, Await] :
/// LetOrConst BindingList[?In, ?Yield, ?Await] ;
Expand All @@ -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] ;
Expand All @@ -931,31 +893,13 @@ 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 {
self.test.is_none()
}
}

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> {
#[allow(missing_docs)]
pub fn get_identifier(&self) -> Option<Atom<'a>> {
Expand Down Expand Up @@ -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<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.
#[inline]
pub fn name(&self) -> Option<Atom<'a>> {
Expand Down Expand Up @@ -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<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`.
pub fn get_expression(&self) -> Option<&Expression<'a>> {
if self.expression {
Expand All @@ -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<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.
///
/// For example,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 1 addition & 8 deletions crates/oxc_ast/src/ast_impl/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![warn(missing_docs)]
use std::fmt;

use oxc_span::{Atom, Span};
use oxc_span::Atom;

use crate::ast::*;

Expand All @@ -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 {
Expand Down
14 changes: 1 addition & 13 deletions crates/oxc_ast/src/ast_impl/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
28 changes: 2 additions & 26 deletions crates/oxc_ast/src/ast_impl/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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<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
/// semantics (as determined by [`TSModuleDeclarationBody::is_strict`]).
pub fn is_strict(&self) -> bool {
Expand Down