diff --git a/.github/generated/ast_changes_watch_list.yml b/.github/generated/ast_changes_watch_list.yml index 7ce02d990a698..b4c071e8b4c27 100644 --- a/.github/generated/ast_changes_watch_list.yml +++ b/.github/generated/ast_changes_watch_list.yml @@ -43,8 +43,8 @@ src: - 'crates/oxc_ast_visit/src/generated/utf8_to_utf16_converter.rs' - 'crates/oxc_ast_visit/src/generated/visit.rs' - 'crates/oxc_ast_visit/src/generated/visit_mut.rs' - - 'crates/oxc_formatter/src/generated/ast_nodes.rs' - - 'crates/oxc_formatter/src/generated/format.rs' + - 'crates/oxc_formatter/src/ast_nodes/generated/ast_nodes.rs' + - 'crates/oxc_formatter/src/ast_nodes/generated/format.rs' - 'crates/oxc_linter/src/generated/assert_layouts.rs' - 'crates/oxc_linter/src/lib.rs' - 'crates/oxc_regular_expression/src/ast.rs' diff --git a/crates/oxc_formatter/src/generated/ast_nodes.rs b/crates/oxc_formatter/src/ast_nodes/generated/ast_nodes.rs similarity index 78% rename from crates/oxc_formatter/src/generated/ast_nodes.rs rename to crates/oxc_formatter/src/ast_nodes/generated/ast_nodes.rs index 1d76027dd52b0..35399664ae11e 100644 --- a/crates/oxc_formatter/src/generated/ast_nodes.rs +++ b/crates/oxc_formatter/src/ast_nodes/generated/ast_nodes.rs @@ -1,13 +1,13 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/generators/formatter/ast_nodes.rs`. -#![expect(clippy::elidable_lifetime_names)] use std::{fmt, mem::transmute, ops::Deref}; use oxc_allocator::{Allocator, Box, Vec}; use oxc_ast::ast::*; use oxc_span::{GetSpan, SPAN}; +use crate::ast_nodes::AstNode; use crate::{ formatter::{ Buffer, Format, FormatResult, Formatter, @@ -797,59 +797,6 @@ impl<'a> AstNodes<'a> { } } -pub struct AstNode<'a, T> { - pub(super) inner: &'a T, - pub parent: &'a AstNodes<'a>, - pub(super) allocator: &'a Allocator, - pub(super) following_span: Option, -} -impl GetSpan for &AstNode<'_, T> { - fn span(&self) -> Span { - self.inner.span() - } -} - -impl<'a, T: fmt::Debug> fmt::Debug for AstNode<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("AstNode") - .field("inner", &self.inner) - .field("parent", &self.parent.debug_name()) - .finish_non_exhaustive() - } -} - -impl<'a, T> Deref for AstNode<'a, T> { - type Target = T; - fn deref(&self) -> &'a Self::Target { - self.inner - } -} - -impl<'a, T> AsRef for AstNode<'a, T> { - fn as_ref(&self) -> &'a T { - self.inner - } -} - -impl<'a> AstNode<'a, Program<'a>> { - pub fn new(inner: &'a Program<'a>, parent: &'a AstNodes<'a>, allocator: &'a Allocator) -> Self { - AstNode { inner, parent, allocator, following_span: None } - } -} - -impl<'a, T> AstNode<'a, Option> { - pub fn as_ref(&self) -> Option<&'a AstNode<'a, T>> { - self.allocator - .alloc(self.inner.as_ref().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: self.following_span, - })) - .as_ref() - } -} - impl<'a> AstNode<'a, Program<'a>> { #[inline] pub fn source_type(&self) -> SourceType { @@ -916,13 +863,6 @@ impl<'a> AstNode<'a, Program<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Program<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Expression<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -1252,13 +1192,6 @@ impl<'a> AstNode<'a, Expression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Expression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, IdentifierName<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -1274,13 +1207,6 @@ impl<'a> AstNode<'a, IdentifierName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, IdentifierName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, IdentifierReference<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -1296,13 +1222,6 @@ impl<'a> AstNode<'a, IdentifierReference<'a>> { } } -impl<'a> GetSpan for AstNode<'a, IdentifierReference<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BindingIdentifier<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -1318,13 +1237,6 @@ impl<'a> AstNode<'a, BindingIdentifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BindingIdentifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, LabelIdentifier<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -1340,13 +1252,6 @@ impl<'a> AstNode<'a, LabelIdentifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, LabelIdentifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ThisExpression> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -1357,13 +1262,6 @@ impl<'a> AstNode<'a, ThisExpression> { } } -impl<'a> GetSpan for AstNode<'a, ThisExpression> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ArrayExpression<'a>> { #[inline] pub fn elements(&self) -> &AstNode<'a, Vec<'a, ArrayExpressionElement<'a>>> { @@ -1385,13 +1283,6 @@ impl<'a> AstNode<'a, ArrayExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ArrayExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ArrayExpressionElement<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -1429,13 +1320,6 @@ impl<'a> AstNode<'a, ArrayExpressionElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ArrayExpressionElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Elision> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -1446,13 +1330,6 @@ impl<'a> AstNode<'a, Elision> { } } -impl<'a> GetSpan for AstNode<'a, Elision> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ObjectExpression<'a>> { #[inline] pub fn properties(&self) -> &AstNode<'a, Vec<'a, ObjectPropertyKind<'a>>> { @@ -1474,13 +1351,6 @@ impl<'a> AstNode<'a, ObjectExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ObjectExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ObjectPropertyKind<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -1507,13 +1377,6 @@ impl<'a> AstNode<'a, ObjectPropertyKind<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ObjectPropertyKind<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ObjectProperty<'a>> { #[inline] pub fn kind(&self) -> PropertyKind { @@ -1566,13 +1429,6 @@ impl<'a> AstNode<'a, ObjectProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ObjectProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, PropertyKey<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -1610,13 +1466,6 @@ impl<'a> AstNode<'a, PropertyKey<'a>> { } } -impl<'a> GetSpan for AstNode<'a, PropertyKey<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TemplateLiteral<'a>> { #[inline] pub fn quasis(&self) -> &AstNode<'a, Vec<'a, TemplateElement<'a>>> { @@ -1650,13 +1499,6 @@ impl<'a> AstNode<'a, TemplateLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TemplateLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TaggedTemplateExpression<'a>> { #[inline] pub fn tag(&self) -> &AstNode<'a, Expression<'a>> { @@ -1708,13 +1550,6 @@ impl<'a> AstNode<'a, TaggedTemplateExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TaggedTemplateExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TemplateElement<'a>> { #[inline] pub fn value(&self) -> &TemplateElementValue<'a> { @@ -1740,13 +1575,6 @@ impl<'a> AstNode<'a, TemplateElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TemplateElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, MemberExpression<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -1781,13 +1609,6 @@ impl<'a> AstNode<'a, MemberExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, MemberExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ComputedMemberExpression<'a>> { #[inline] pub fn object(&self) -> &AstNode<'a, Expression<'a>> { @@ -1825,13 +1646,6 @@ impl<'a> AstNode<'a, ComputedMemberExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ComputedMemberExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, StaticMemberExpression<'a>> { #[inline] pub fn object(&self) -> &AstNode<'a, Expression<'a>> { @@ -1869,13 +1683,6 @@ impl<'a> AstNode<'a, StaticMemberExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, StaticMemberExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, PrivateFieldExpression<'a>> { #[inline] pub fn object(&self) -> &AstNode<'a, Expression<'a>> { @@ -1913,13 +1720,6 @@ impl<'a> AstNode<'a, PrivateFieldExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, PrivateFieldExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, CallExpression<'a>> { #[inline] pub fn callee(&self) -> &AstNode<'a, Expression<'a>> { @@ -1982,13 +1782,6 @@ impl<'a> AstNode<'a, CallExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, CallExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, NewExpression<'a>> { #[inline] pub fn callee(&self) -> &AstNode<'a, Expression<'a>> { @@ -2046,13 +1839,6 @@ impl<'a> AstNode<'a, NewExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, NewExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, MetaProperty<'a>> { #[inline] pub fn meta(&self) -> &AstNode<'a, IdentifierName<'a>> { @@ -2085,13 +1871,6 @@ impl<'a> AstNode<'a, MetaProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, MetaProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, SpreadElement<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, Expression<'a>> { @@ -2113,13 +1892,6 @@ impl<'a> AstNode<'a, SpreadElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, SpreadElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Argument<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2147,13 +1919,6 @@ impl<'a> AstNode<'a, Argument<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Argument<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, UpdateExpression<'a>> { #[inline] pub fn operator(&self) -> UpdateOperator { @@ -2185,13 +1950,6 @@ impl<'a> AstNode<'a, UpdateExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, UpdateExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, UnaryExpression<'a>> { #[inline] pub fn operator(&self) -> UnaryOperator { @@ -2218,13 +1976,6 @@ impl<'a> AstNode<'a, UnaryExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, UnaryExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BinaryExpression<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, Expression<'a>> { @@ -2262,13 +2013,6 @@ impl<'a> AstNode<'a, BinaryExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BinaryExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, PrivateInExpression<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, PrivateIdentifier<'a>> { @@ -2301,13 +2045,6 @@ impl<'a> AstNode<'a, PrivateInExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, PrivateInExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, LogicalExpression<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, Expression<'a>> { @@ -2345,13 +2082,6 @@ impl<'a> AstNode<'a, LogicalExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, LogicalExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ConditionalExpression<'a>> { #[inline] pub fn test(&self) -> &AstNode<'a, Expression<'a>> { @@ -2395,13 +2125,6 @@ impl<'a> AstNode<'a, ConditionalExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ConditionalExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentExpression<'a>> { #[inline] pub fn operator(&self) -> AssignmentOperator { @@ -2439,13 +2162,6 @@ impl<'a> AstNode<'a, AssignmentExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTarget<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2478,13 +2194,6 @@ impl<'a> AstNode<'a, AssignmentTarget<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTarget<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, SimpleAssignmentTarget<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2546,13 +2255,6 @@ impl<'a> AstNode<'a, SimpleAssignmentTarget<'a>> { } } -impl<'a> GetSpan for AstNode<'a, SimpleAssignmentTarget<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetPattern<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2579,13 +2281,6 @@ impl<'a> AstNode<'a, AssignmentTargetPattern<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetPattern<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ArrayAssignmentTarget<'a>> { #[inline] pub fn elements(&self) -> &AstNode<'a, Vec<'a, Option>>> { @@ -2620,13 +2315,6 @@ impl<'a> AstNode<'a, ArrayAssignmentTarget<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ArrayAssignmentTarget<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ObjectAssignmentTarget<'a>> { #[inline] pub fn properties(&self) -> &AstNode<'a, Vec<'a, AssignmentTargetProperty<'a>>> { @@ -2662,13 +2350,6 @@ impl<'a> AstNode<'a, ObjectAssignmentTarget<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ObjectAssignmentTarget<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetRest<'a>> { #[inline] pub fn target(&self) -> &AstNode<'a, AssignmentTarget<'a>> { @@ -2690,13 +2371,6 @@ impl<'a> AstNode<'a, AssignmentTargetRest<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetRest<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetMaybeDefault<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2726,13 +2400,6 @@ impl<'a> AstNode<'a, AssignmentTargetMaybeDefault<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetMaybeDefault<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetWithDefault<'a>> { #[inline] pub fn binding(&self) -> &AstNode<'a, AssignmentTarget<'a>> { @@ -2769,13 +2436,6 @@ impl<'a> AstNode<'a, AssignmentTargetWithDefault<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetWithDefault<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetProperty<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -2802,13 +2462,6 @@ impl<'a> AstNode<'a, AssignmentTargetProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetPropertyIdentifier<'a>> { #[inline] pub fn binding(&self) -> &AstNode<'a, IdentifierReference<'a>> { @@ -2849,13 +2502,6 @@ impl<'a> AstNode<'a, AssignmentTargetPropertyIdentifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetPropertyIdentifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentTargetPropertyProperty<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, PropertyKey<'a>> { @@ -2897,13 +2543,6 @@ impl<'a> AstNode<'a, AssignmentTargetPropertyProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentTargetPropertyProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, SequenceExpression<'a>> { #[inline] pub fn expressions(&self) -> &AstNode<'a, Vec<'a, Expression<'a>>> { @@ -2925,13 +2564,6 @@ impl<'a> AstNode<'a, SequenceExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, SequenceExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Super> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -2942,13 +2574,6 @@ impl<'a> AstNode<'a, Super> { } } -impl<'a> GetSpan for AstNode<'a, Super> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AwaitExpression<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, Expression<'a>> { @@ -2970,13 +2595,6 @@ impl<'a> AstNode<'a, AwaitExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AwaitExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ChainExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, ChainElement<'a>> { @@ -2998,13 +2616,6 @@ impl<'a> AstNode<'a, ChainExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ChainExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ChainElement<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -3042,13 +2653,6 @@ impl<'a> AstNode<'a, ChainElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ChainElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ParenthesizedExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -3070,13 +2674,6 @@ impl<'a> AstNode<'a, ParenthesizedExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ParenthesizedExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Statement<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -3245,13 +2842,6 @@ impl<'a> AstNode<'a, Statement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Statement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Directive<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, StringLiteral<'a>> { @@ -3278,13 +2868,6 @@ impl<'a> AstNode<'a, Directive<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Directive<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Hashbang<'a>> { #[inline] pub fn value(&self) -> Atom<'a> { @@ -3300,13 +2883,6 @@ impl<'a> AstNode<'a, Hashbang<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Hashbang<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BlockStatement<'a>> { #[inline] pub fn body(&self) -> &AstNode<'a, Vec<'a, Statement<'a>>> { @@ -3328,13 +2904,6 @@ impl<'a> AstNode<'a, BlockStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BlockStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Declaration<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -3407,13 +2976,6 @@ impl<'a> AstNode<'a, Declaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Declaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, VariableDeclaration<'a>> { #[inline] pub fn kind(&self) -> VariableDeclarationKind { @@ -3445,13 +3007,6 @@ impl<'a> AstNode<'a, VariableDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, VariableDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, VariableDeclarator<'a>> { #[inline] pub fn kind(&self) -> VariableDeclarationKind { @@ -3496,13 +3051,6 @@ impl<'a> AstNode<'a, VariableDeclarator<'a>> { } } -impl<'a> GetSpan for AstNode<'a, VariableDeclarator<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, EmptyStatement> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -3513,14 +3061,7 @@ impl<'a> AstNode<'a, EmptyStatement> { } } -impl<'a> GetSpan for AstNode<'a, EmptyStatement> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - -impl<'a> AstNode<'a, ExpressionStatement<'a>> { +impl<'a> AstNode<'a, ExpressionStatement<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { let following_span = None; @@ -3541,13 +3082,6 @@ impl<'a> AstNode<'a, ExpressionStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExpressionStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, IfStatement<'a>> { #[inline] pub fn test(&self) -> &AstNode<'a, Expression<'a>> { @@ -3593,13 +3127,6 @@ impl<'a> AstNode<'a, IfStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, IfStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, DoWhileStatement<'a>> { #[inline] pub fn body(&self) -> &AstNode<'a, Statement<'a>> { @@ -3632,13 +3159,6 @@ impl<'a> AstNode<'a, DoWhileStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, DoWhileStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, WhileStatement<'a>> { #[inline] pub fn test(&self) -> &AstNode<'a, Expression<'a>> { @@ -3671,13 +3191,6 @@ impl<'a> AstNode<'a, WhileStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, WhileStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ForStatement<'a>> { #[inline] pub fn init(&self) -> Option<&AstNode<'a, ForStatementInit<'a>>> { @@ -3745,13 +3258,6 @@ impl<'a> AstNode<'a, ForStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ForStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ForStatementInit<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -3781,13 +3287,6 @@ impl<'a> AstNode<'a, ForStatementInit<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ForStatementInit<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ForInStatement<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, ForStatementLeft<'a>> { @@ -3831,13 +3330,6 @@ impl<'a> AstNode<'a, ForInStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ForInStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ForStatementLeft<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -3867,13 +3359,6 @@ impl<'a> AstNode<'a, ForStatementLeft<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ForStatementLeft<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ForOfStatement<'a>> { #[inline] pub fn r#await(&self) -> bool { @@ -3922,13 +3407,6 @@ impl<'a> AstNode<'a, ForOfStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ForOfStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ContinueStatement<'a>> { #[inline] pub fn label(&self) -> Option<&AstNode<'a, LabelIdentifier<'a>>> { @@ -3952,13 +3430,6 @@ impl<'a> AstNode<'a, ContinueStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ContinueStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BreakStatement<'a>> { #[inline] pub fn label(&self) -> Option<&AstNode<'a, LabelIdentifier<'a>>> { @@ -3982,13 +3453,6 @@ impl<'a> AstNode<'a, BreakStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BreakStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ReturnStatement<'a>> { #[inline] pub fn argument(&self) -> Option<&AstNode<'a, Expression<'a>>> { @@ -4012,13 +3476,6 @@ impl<'a> AstNode<'a, ReturnStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ReturnStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, WithStatement<'a>> { #[inline] pub fn object(&self) -> &AstNode<'a, Expression<'a>> { @@ -4051,13 +3508,6 @@ impl<'a> AstNode<'a, WithStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, WithStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, SwitchStatement<'a>> { #[inline] pub fn discriminant(&self) -> &AstNode<'a, Expression<'a>> { @@ -4090,13 +3540,6 @@ impl<'a> AstNode<'a, SwitchStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, SwitchStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, SwitchCase<'a>> { #[inline] pub fn test(&self) -> Option<&AstNode<'a, Expression<'a>>> { @@ -4132,13 +3575,6 @@ impl<'a> AstNode<'a, SwitchCase<'a>> { } } -impl<'a> GetSpan for AstNode<'a, SwitchCase<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, LabeledStatement<'a>> { #[inline] pub fn label(&self) -> &AstNode<'a, LabelIdentifier<'a>> { @@ -4171,13 +3607,6 @@ impl<'a> AstNode<'a, LabeledStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, LabeledStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ThrowStatement<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, Expression<'a>> { @@ -4199,13 +3628,6 @@ impl<'a> AstNode<'a, ThrowStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ThrowStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TryStatement<'a>> { #[inline] pub fn block(&self) -> &AstNode<'a, BlockStatement<'a>> { @@ -4258,13 +3680,6 @@ impl<'a> AstNode<'a, TryStatement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TryStatement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, CatchClause<'a>> { #[inline] pub fn param(&self) -> Option<&AstNode<'a, CatchParameter<'a>>> { @@ -4299,13 +3714,6 @@ impl<'a> AstNode<'a, CatchClause<'a>> { } } -impl<'a> GetSpan for AstNode<'a, CatchClause<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, CatchParameter<'a>> { #[inline] pub fn pattern(&self) -> &AstNode<'a, BindingPattern<'a>> { @@ -4327,13 +3735,6 @@ impl<'a> AstNode<'a, CatchParameter<'a>> { } } -impl<'a> GetSpan for AstNode<'a, CatchParameter<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, DebuggerStatement> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -4344,13 +3745,6 @@ impl<'a> AstNode<'a, DebuggerStatement> { } } -impl<'a> GetSpan for AstNode<'a, DebuggerStatement> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BindingPattern<'a>> { #[inline] pub fn kind(&self) -> &AstNode<'a, BindingPatternKind<'a>> { @@ -4391,13 +3785,6 @@ impl<'a> AstNode<'a, BindingPattern<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BindingPattern<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BindingPatternKind<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -4440,13 +3827,6 @@ impl<'a> AstNode<'a, BindingPatternKind<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BindingPatternKind<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AssignmentPattern<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, BindingPattern<'a>> { @@ -4479,13 +3859,6 @@ impl<'a> AstNode<'a, AssignmentPattern<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AssignmentPattern<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ObjectPattern<'a>> { #[inline] pub fn properties(&self) -> &AstNode<'a, Vec<'a, BindingProperty<'a>>> { @@ -4520,13 +3893,6 @@ impl<'a> AstNode<'a, ObjectPattern<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ObjectPattern<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BindingProperty<'a>> { #[inline] pub fn key(&self) -> &AstNode<'a, PropertyKey<'a>> { @@ -4569,13 +3935,6 @@ impl<'a> AstNode<'a, BindingProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BindingProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ArrayPattern<'a>> { #[inline] pub fn elements(&self) -> &AstNode<'a, Vec<'a, Option>>> { @@ -4610,13 +3969,6 @@ impl<'a> AstNode<'a, ArrayPattern<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ArrayPattern<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BindingRestElement<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, BindingPattern<'a>> { @@ -4638,13 +3990,6 @@ impl<'a> AstNode<'a, BindingRestElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BindingRestElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Function<'a>> { #[inline] pub fn r#type(&self) -> FunctionType { @@ -4778,13 +4123,6 @@ impl<'a> AstNode<'a, Function<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Function<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, FormalParameters<'a>> { #[inline] pub fn kind(&self) -> FormalParameterKind { @@ -4824,13 +4162,6 @@ impl<'a> AstNode<'a, FormalParameters<'a>> { } } -impl<'a> GetSpan for AstNode<'a, FormalParameters<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, FormalParameter<'a>> { #[inline] pub fn decorators(&self) -> &AstNode<'a, Vec<'a, Decorator<'a>>> { @@ -4878,13 +4209,6 @@ impl<'a> AstNode<'a, FormalParameter<'a>> { } } -impl<'a> GetSpan for AstNode<'a, FormalParameter<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, FunctionBody<'a>> { #[inline] pub fn directives(&self) -> &AstNode<'a, Vec<'a, Directive<'a>>> { @@ -4918,13 +4242,6 @@ impl<'a> AstNode<'a, FunctionBody<'a>> { } } -impl<'a> GetSpan for AstNode<'a, FunctionBody<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ArrowFunctionExpression<'a>> { #[inline] pub fn expression(&self) -> bool { @@ -5010,13 +4327,6 @@ impl<'a> AstNode<'a, ArrowFunctionExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ArrowFunctionExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, YieldExpression<'a>> { #[inline] pub fn delegate(&self) -> bool { @@ -5045,13 +4355,6 @@ impl<'a> AstNode<'a, YieldExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, YieldExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Class<'a>> { #[inline] pub fn r#type(&self) -> ClassType { @@ -5197,13 +4500,6 @@ impl<'a> AstNode<'a, Class<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Class<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ClassBody<'a>> { #[inline] pub fn body(&self) -> &AstNode<'a, Vec<'a, ClassElement<'a>>> { @@ -5225,13 +4521,6 @@ impl<'a> AstNode<'a, ClassBody<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ClassBody<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ClassElement<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -5280,13 +4569,6 @@ impl<'a> AstNode<'a, ClassElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ClassElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, MethodDefinition<'a>> { #[inline] pub fn r#type(&self) -> MethodDefinitionType { @@ -5365,13 +4647,6 @@ impl<'a> AstNode<'a, MethodDefinition<'a>> { } } -impl<'a> GetSpan for AstNode<'a, MethodDefinition<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, PropertyDefinition<'a>> { #[inline] pub fn r#type(&self) -> PropertyDefinitionType { @@ -5481,13 +4756,6 @@ impl<'a> AstNode<'a, PropertyDefinition<'a>> { } } -impl<'a> GetSpan for AstNode<'a, PropertyDefinition<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, PrivateIdentifier<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -5503,13 +4771,6 @@ impl<'a> AstNode<'a, PrivateIdentifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, PrivateIdentifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, StaticBlock<'a>> { #[inline] pub fn body(&self) -> &AstNode<'a, Vec<'a, Statement<'a>>> { @@ -5531,13 +4792,6 @@ impl<'a> AstNode<'a, StaticBlock<'a>> { } } -impl<'a> GetSpan for AstNode<'a, StaticBlock<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ModuleDeclaration<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -5596,13 +4850,6 @@ impl<'a> AstNode<'a, ModuleDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ModuleDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, AccessorProperty<'a>> { #[inline] pub fn r#type(&self) -> AccessorPropertyType { @@ -5697,13 +4944,6 @@ impl<'a> AstNode<'a, AccessorProperty<'a>> { } } -impl<'a> GetSpan for AstNode<'a, AccessorProperty<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportExpression<'a>> { #[inline] pub fn source(&self) -> &AstNode<'a, Expression<'a>> { @@ -5743,13 +4983,6 @@ impl<'a> AstNode<'a, ImportExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportDeclaration<'a>> { #[inline] pub fn specifiers(&self) -> Option<&AstNode<'a, Vec<'a, ImportDeclarationSpecifier<'a>>>> { @@ -5807,13 +5040,6 @@ impl<'a> AstNode<'a, ImportDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportDeclarationSpecifier<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -5848,13 +5074,6 @@ impl<'a> AstNode<'a, ImportDeclarationSpecifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportDeclarationSpecifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportSpecifier<'a>> { #[inline] pub fn imported(&self) -> &AstNode<'a, ModuleExportName<'a>> { @@ -5892,13 +5111,6 @@ impl<'a> AstNode<'a, ImportSpecifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportSpecifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportDefaultSpecifier<'a>> { #[inline] pub fn local(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -5920,13 +5132,6 @@ impl<'a> AstNode<'a, ImportDefaultSpecifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportDefaultSpecifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportNamespaceSpecifier<'a>> { #[inline] pub fn local(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -5948,13 +5153,6 @@ impl<'a> AstNode<'a, ImportNamespaceSpecifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportNamespaceSpecifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, WithClause<'a>> { #[inline] pub fn keyword(&self) -> WithClauseKeyword { @@ -5981,13 +5179,6 @@ impl<'a> AstNode<'a, WithClause<'a>> { } } -impl<'a> GetSpan for AstNode<'a, WithClause<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportAttribute<'a>> { #[inline] pub fn key(&self) -> &AstNode<'a, ImportAttributeKey<'a>> { @@ -6020,13 +5211,6 @@ impl<'a> AstNode<'a, ImportAttribute<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportAttribute<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ImportAttributeKey<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -6053,13 +5237,6 @@ impl<'a> AstNode<'a, ImportAttributeKey<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ImportAttributeKey<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ExportNamedDeclaration<'a>> { #[inline] pub fn declaration(&self) -> Option<&AstNode<'a, Declaration<'a>>> { @@ -6139,13 +5316,6 @@ impl<'a> AstNode<'a, ExportNamedDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExportNamedDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ExportDefaultDeclaration<'a>> { #[inline] pub fn declaration(&self) -> &AstNode<'a, ExportDefaultDeclarationKind<'a>> { @@ -6167,13 +5337,6 @@ impl<'a> AstNode<'a, ExportDefaultDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExportDefaultDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ExportAllDeclaration<'a>> { #[inline] pub fn exported(&self) -> Option<&AstNode<'a, ModuleExportName<'a>>> { @@ -6226,13 +5389,6 @@ impl<'a> AstNode<'a, ExportAllDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExportAllDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ExportSpecifier<'a>> { #[inline] pub fn local(&self) -> &AstNode<'a, ModuleExportName<'a>> { @@ -6270,13 +5426,6 @@ impl<'a> AstNode<'a, ExportSpecifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExportSpecifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ExportDefaultDeclarationKind<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -6322,13 +5471,6 @@ impl<'a> AstNode<'a, ExportDefaultDeclarationKind<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ExportDefaultDeclarationKind<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, ModuleExportName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -6363,13 +5505,6 @@ impl<'a> AstNode<'a, ModuleExportName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, ModuleExportName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, V8IntrinsicExpression<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, IdentifierName<'a>> { @@ -6403,13 +5538,6 @@ impl<'a> AstNode<'a, V8IntrinsicExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, V8IntrinsicExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, BooleanLiteral> { #[inline] pub fn value(&self) -> bool { @@ -6425,13 +5553,6 @@ impl<'a> AstNode<'a, BooleanLiteral> { } } -impl<'a> GetSpan for AstNode<'a, BooleanLiteral> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, NullLiteral> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -6442,13 +5563,6 @@ impl<'a> AstNode<'a, NullLiteral> { } } -impl<'a> GetSpan for AstNode<'a, NullLiteral> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, NumericLiteral<'a>> { #[inline] pub fn value(&self) -> f64 { @@ -6474,13 +5588,6 @@ impl<'a> AstNode<'a, NumericLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, NumericLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, StringLiteral<'a>> { #[inline] pub fn value(&self) -> Atom<'a> { @@ -6506,17 +5613,10 @@ impl<'a> AstNode<'a, StringLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, StringLiteral<'a>> { +impl<'a> AstNode<'a, BigIntLiteral<'a>> { #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - -impl<'a> AstNode<'a, BigIntLiteral<'a>> { - #[inline] - pub fn value(&self) -> Atom<'a> { - self.inner.value + pub fn value(&self) -> Atom<'a> { + self.inner.value } #[inline] @@ -6538,13 +5638,6 @@ impl<'a> AstNode<'a, BigIntLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, BigIntLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, RegExpLiteral<'a>> { #[inline] pub fn regex(&self) -> &RegExp<'a> { @@ -6565,13 +5658,6 @@ impl<'a> AstNode<'a, RegExpLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, RegExpLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXElement<'a>> { #[inline] pub fn opening_element(&self) -> &AstNode<'a, JSXOpeningElement<'a>> { @@ -6624,13 +5710,6 @@ impl<'a> AstNode<'a, JSXElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXOpeningElement<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, JSXElementName<'a>> { @@ -6683,13 +5762,6 @@ impl<'a> AstNode<'a, JSXOpeningElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXOpeningElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXClosingElement<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, JSXElementName<'a>> { @@ -6711,13 +5783,6 @@ impl<'a> AstNode<'a, JSXClosingElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXClosingElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXFragment<'a>> { #[inline] pub fn opening_fragment(&self) -> &AstNode<'a, JSXOpeningFragment> { @@ -6766,13 +5831,6 @@ impl<'a> AstNode<'a, JSXFragment<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXFragment<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXOpeningFragment> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -6783,13 +5841,6 @@ impl<'a> AstNode<'a, JSXOpeningFragment> { } } -impl<'a> GetSpan for AstNode<'a, JSXOpeningFragment> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXClosingFragment> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -6800,13 +5851,6 @@ impl<'a> AstNode<'a, JSXClosingFragment> { } } -impl<'a> GetSpan for AstNode<'a, JSXClosingFragment> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXElementName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -6857,13 +5901,6 @@ impl<'a> AstNode<'a, JSXElementName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXElementName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXNamespacedName<'a>> { #[inline] pub fn namespace(&self) -> &AstNode<'a, JSXIdentifier<'a>> { @@ -6896,13 +5933,6 @@ impl<'a> AstNode<'a, JSXNamespacedName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXNamespacedName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXMemberExpression<'a>> { #[inline] pub fn object(&self) -> &AstNode<'a, JSXMemberExpressionObject<'a>> { @@ -6935,13 +5965,6 @@ impl<'a> AstNode<'a, JSXMemberExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXMemberExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXMemberExpressionObject<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -6976,13 +5999,6 @@ impl<'a> AstNode<'a, JSXMemberExpressionObject<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXMemberExpressionObject<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXExpressionContainer<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, JSXExpression<'a>> { @@ -7004,13 +6020,6 @@ impl<'a> AstNode<'a, JSXExpressionContainer<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXExpressionContainer<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXExpression<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7040,13 +6049,6 @@ impl<'a> AstNode<'a, JSXExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXEmptyExpression> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -7057,13 +6059,6 @@ impl<'a> AstNode<'a, JSXEmptyExpression> { } } -impl<'a> GetSpan for AstNode<'a, JSXEmptyExpression> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXAttributeItem<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7090,13 +6085,6 @@ impl<'a> AstNode<'a, JSXAttributeItem<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXAttributeItem<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXAttribute<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, JSXAttributeName<'a>> { @@ -7131,13 +6119,6 @@ impl<'a> AstNode<'a, JSXAttribute<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXAttribute<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXSpreadAttribute<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, Expression<'a>> { @@ -7159,13 +6140,6 @@ impl<'a> AstNode<'a, JSXSpreadAttribute<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXSpreadAttribute<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXAttributeName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7192,13 +6166,6 @@ impl<'a> AstNode<'a, JSXAttributeName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXAttributeName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXAttributeValue<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7239,13 +6206,6 @@ impl<'a> AstNode<'a, JSXAttributeValue<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXAttributeValue<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXIdentifier<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -7261,13 +6221,6 @@ impl<'a> AstNode<'a, JSXIdentifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXIdentifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXChild<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7310,13 +6263,6 @@ impl<'a> AstNode<'a, JSXChild<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXChild<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXSpreadChild<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -7338,13 +6284,6 @@ impl<'a> AstNode<'a, JSXSpreadChild<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXSpreadChild<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSXText<'a>> { #[inline] pub fn value(&self) -> Atom<'a> { @@ -7365,13 +6304,6 @@ impl<'a> AstNode<'a, JSXText<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSXText<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSThisParameter<'a>> { #[inline] pub fn this_span(&self) -> Span { @@ -7400,13 +6332,6 @@ impl<'a> AstNode<'a, TSThisParameter<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSThisParameter<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSEnumDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -7449,13 +6374,6 @@ impl<'a> AstNode<'a, TSEnumDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSEnumDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSEnumBody<'a>> { #[inline] pub fn members(&self) -> &AstNode<'a, Vec<'a, TSEnumMember<'a>>> { @@ -7477,13 +6395,6 @@ impl<'a> AstNode<'a, TSEnumBody<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSEnumBody<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSEnumMember<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, TSEnumMemberName<'a>> { @@ -7519,13 +6430,6 @@ impl<'a> AstNode<'a, TSEnumMember<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSEnumMember<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSEnumMemberName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7566,13 +6470,6 @@ impl<'a> AstNode<'a, TSEnumMemberName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSEnumMemberName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeAnnotation<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -7594,13 +6491,6 @@ impl<'a> AstNode<'a, TSTypeAnnotation<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeAnnotation<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSLiteralType<'a>> { #[inline] pub fn literal(&self) -> &AstNode<'a, TSLiteral<'a>> { @@ -7622,13 +6512,6 @@ impl<'a> AstNode<'a, TSLiteralType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSLiteralType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSLiteral<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7683,13 +6566,6 @@ impl<'a> AstNode<'a, TSLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSType<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -7966,13 +6842,6 @@ impl<'a> AstNode<'a, TSType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSConditionalType<'a>> { #[inline] pub fn check_type(&self) -> &AstNode<'a, TSType<'a>> { @@ -8027,13 +6896,6 @@ impl<'a> AstNode<'a, TSConditionalType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSConditionalType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSUnionType<'a>> { #[inline] pub fn types(&self) -> &AstNode<'a, Vec<'a, TSType<'a>>> { @@ -8055,13 +6917,6 @@ impl<'a> AstNode<'a, TSUnionType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSUnionType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSIntersectionType<'a>> { #[inline] pub fn types(&self) -> &AstNode<'a, Vec<'a, TSType<'a>>> { @@ -8083,13 +6938,6 @@ impl<'a> AstNode<'a, TSIntersectionType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSIntersectionType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSParenthesizedType<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -8111,13 +6959,6 @@ impl<'a> AstNode<'a, TSParenthesizedType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSParenthesizedType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeOperator<'a>> { #[inline] pub fn operator(&self) -> TSTypeOperatorOperator { @@ -8144,13 +6985,6 @@ impl<'a> AstNode<'a, TSTypeOperator<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeOperator<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSArrayType<'a>> { #[inline] pub fn element_type(&self) -> &AstNode<'a, TSType<'a>> { @@ -8172,13 +7006,6 @@ impl<'a> AstNode<'a, TSArrayType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSArrayType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSIndexedAccessType<'a>> { #[inline] pub fn object_type(&self) -> &AstNode<'a, TSType<'a>> { @@ -8211,13 +7038,6 @@ impl<'a> AstNode<'a, TSIndexedAccessType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSIndexedAccessType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTupleType<'a>> { #[inline] pub fn element_types(&self) -> &AstNode<'a, Vec<'a, TSTupleElement<'a>>> { @@ -8239,13 +7059,6 @@ impl<'a> AstNode<'a, TSTupleType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTupleType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNamedTupleMember<'a>> { #[inline] pub fn label(&self) -> &AstNode<'a, IdentifierName<'a>> { @@ -8283,13 +7096,6 @@ impl<'a> AstNode<'a, TSNamedTupleMember<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSNamedTupleMember<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSOptionalType<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -8311,13 +7117,6 @@ impl<'a> AstNode<'a, TSOptionalType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSOptionalType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSRestType<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -8339,13 +7138,6 @@ impl<'a> AstNode<'a, TSRestType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSRestType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTupleElement<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -8381,13 +7173,6 @@ impl<'a> AstNode<'a, TSTupleElement<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTupleElement<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSAnyKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8398,13 +7183,6 @@ impl<'a> AstNode<'a, TSAnyKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSAnyKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSStringKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8415,13 +7193,6 @@ impl<'a> AstNode<'a, TSStringKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSStringKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSBooleanKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8432,13 +7203,6 @@ impl<'a> AstNode<'a, TSBooleanKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSBooleanKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNumberKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8449,13 +7213,6 @@ impl<'a> AstNode<'a, TSNumberKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSNumberKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNeverKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8466,13 +7223,6 @@ impl<'a> AstNode<'a, TSNeverKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSNeverKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSIntrinsicKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8483,13 +7233,6 @@ impl<'a> AstNode<'a, TSIntrinsicKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSIntrinsicKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSUnknownKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8500,13 +7243,6 @@ impl<'a> AstNode<'a, TSUnknownKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSUnknownKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNullKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8517,13 +7253,6 @@ impl<'a> AstNode<'a, TSNullKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSNullKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSUndefinedKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8534,13 +7263,6 @@ impl<'a> AstNode<'a, TSUndefinedKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSUndefinedKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSVoidKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8551,13 +7273,6 @@ impl<'a> AstNode<'a, TSVoidKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSVoidKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSSymbolKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8568,13 +7283,6 @@ impl<'a> AstNode<'a, TSSymbolKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSSymbolKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSThisType> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8585,13 +7293,6 @@ impl<'a> AstNode<'a, TSThisType> { } } -impl<'a> GetSpan for AstNode<'a, TSThisType> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSObjectKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8602,13 +7303,6 @@ impl<'a> AstNode<'a, TSObjectKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSObjectKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSBigIntKeyword> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -8619,13 +7313,6 @@ impl<'a> AstNode<'a, TSBigIntKeyword> { } } -impl<'a> GetSpan for AstNode<'a, TSBigIntKeyword> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeReference<'a>> { #[inline] pub fn type_name(&self) -> &AstNode<'a, TSTypeName<'a>> { @@ -8661,13 +7348,6 @@ impl<'a> AstNode<'a, TSTypeReference<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeReference<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -8702,13 +7382,6 @@ impl<'a> AstNode<'a, TSTypeName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSQualifiedName<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, TSTypeName<'a>> { @@ -8741,13 +7414,6 @@ impl<'a> AstNode<'a, TSQualifiedName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSQualifiedName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeParameterInstantiation<'a>> { #[inline] pub fn params(&self) -> &AstNode<'a, Vec<'a, TSType<'a>>> { @@ -8771,14 +7437,7 @@ impl<'a> AstNode<'a, TSTypeParameterInstantiation<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeParameterInstantiation<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - -impl<'a> AstNode<'a, TSTypeParameter<'a>> { +impl<'a> AstNode<'a, TSTypeParameter<'a>> { #[inline] pub fn name(&self) -> &AstNode<'a, BindingIdentifier<'a>> { let following_span = self @@ -8846,13 +7505,6 @@ impl<'a> AstNode<'a, TSTypeParameter<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeParameter<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeParameterDeclaration<'a>> { #[inline] pub fn params(&self) -> &AstNode<'a, Vec<'a, TSTypeParameter<'a>>> { @@ -8876,13 +7528,6 @@ impl<'a> AstNode<'a, TSTypeParameterDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeParameterDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeAliasDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -8939,13 +7584,6 @@ impl<'a> AstNode<'a, TSTypeAliasDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeAliasDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSClassImplements<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, TSTypeName<'a>> { @@ -8981,13 +7619,6 @@ impl<'a> AstNode<'a, TSClassImplements<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSClassImplements<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSInterfaceDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -9057,13 +7688,6 @@ impl<'a> AstNode<'a, TSInterfaceDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSInterfaceDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSInterfaceBody<'a>> { #[inline] pub fn body(&self) -> &AstNode<'a, Vec<'a, TSSignature<'a>>> { @@ -9085,13 +7709,6 @@ impl<'a> AstNode<'a, TSInterfaceBody<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSInterfaceBody<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSPropertySignature<'a>> { #[inline] pub fn computed(&self) -> bool { @@ -9142,13 +7759,6 @@ impl<'a> AstNode<'a, TSPropertySignature<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSPropertySignature<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSSignature<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -9199,13 +7809,6 @@ impl<'a> AstNode<'a, TSSignature<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSSignature<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSIndexSignature<'a>> { #[inline] pub fn parameters(&self) -> &AstNode<'a, Vec<'a, TSIndexSignatureName<'a>>> { @@ -9248,13 +7851,6 @@ impl<'a> AstNode<'a, TSIndexSignature<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSIndexSignature<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSCallSignatureDeclaration<'a>> { #[inline] pub fn type_parameters(&self) -> Option<&AstNode<'a, TSTypeParameterDeclaration<'a>>> { @@ -9335,13 +7931,6 @@ impl<'a> AstNode<'a, TSCallSignatureDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSCallSignatureDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSMethodSignature<'a>> { #[inline] pub fn key(&self) -> &AstNode<'a, PropertyKey<'a>> { @@ -9440,13 +8029,6 @@ impl<'a> AstNode<'a, TSMethodSignature<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSMethodSignature<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSConstructSignatureDeclaration<'a>> { #[inline] pub fn type_parameters(&self) -> Option<&AstNode<'a, TSTypeParameterDeclaration<'a>>> { @@ -9505,13 +8087,6 @@ impl<'a> AstNode<'a, TSConstructSignatureDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSConstructSignatureDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSIndexSignatureName<'a>> { #[inline] pub fn name(&self) -> Atom<'a> { @@ -9538,13 +8113,6 @@ impl<'a> AstNode<'a, TSIndexSignatureName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSIndexSignatureName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSInterfaceHeritage<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -9580,13 +8148,6 @@ impl<'a> AstNode<'a, TSInterfaceHeritage<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSInterfaceHeritage<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypePredicate<'a>> { #[inline] pub fn parameter_name(&self) -> &AstNode<'a, TSTypePredicateName<'a>> { @@ -9627,13 +8188,6 @@ impl<'a> AstNode<'a, TSTypePredicate<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypePredicate<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypePredicateName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -9658,13 +8212,6 @@ impl<'a> AstNode<'a, TSTypePredicateName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypePredicateName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSModuleDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, TSModuleDeclarationName<'a>> { @@ -9709,13 +8256,6 @@ impl<'a> AstNode<'a, TSModuleDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSModuleDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSModuleDeclarationName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -9742,13 +8282,6 @@ impl<'a> AstNode<'a, TSModuleDeclarationName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSModuleDeclarationName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSModuleDeclarationBody<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -9775,13 +8308,6 @@ impl<'a> AstNode<'a, TSModuleDeclarationBody<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSModuleDeclarationBody<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSModuleBlock<'a>> { #[inline] pub fn directives(&self) -> &AstNode<'a, Vec<'a, Directive<'a>>> { @@ -9814,13 +8340,6 @@ impl<'a> AstNode<'a, TSModuleBlock<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSModuleBlock<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeLiteral<'a>> { #[inline] pub fn members(&self) -> &AstNode<'a, Vec<'a, TSSignature<'a>>> { @@ -9842,13 +8361,6 @@ impl<'a> AstNode<'a, TSTypeLiteral<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeLiteral<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSInferType<'a>> { #[inline] pub fn type_parameter(&self) -> &AstNode<'a, TSTypeParameter<'a>> { @@ -9870,13 +8382,6 @@ impl<'a> AstNode<'a, TSInferType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSInferType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeQuery<'a>> { #[inline] pub fn expr_name(&self) -> &AstNode<'a, TSTypeQueryExprName<'a>> { @@ -9912,13 +8417,6 @@ impl<'a> AstNode<'a, TSTypeQuery<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeQuery<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeQueryExprName<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -9948,13 +8446,6 @@ impl<'a> AstNode<'a, TSTypeQueryExprName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeQueryExprName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSImportType<'a>> { #[inline] pub fn argument(&self) -> &AstNode<'a, TSType<'a>> { @@ -10029,13 +8520,6 @@ impl<'a> AstNode<'a, TSImportType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSImportType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSImportTypeQualifier<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -10062,13 +8546,6 @@ impl<'a> AstNode<'a, TSImportTypeQualifier<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSImportTypeQualifier<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSImportTypeQualifiedName<'a>> { #[inline] pub fn left(&self) -> &AstNode<'a, TSImportTypeQualifier<'a>> { @@ -10101,13 +8578,6 @@ impl<'a> AstNode<'a, TSImportTypeQualifiedName<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSImportTypeQualifiedName<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSFunctionType<'a>> { #[inline] pub fn type_parameters(&self) -> Option<&AstNode<'a, TSTypeParameterDeclaration<'a>>> { @@ -10171,13 +8641,6 @@ impl<'a> AstNode<'a, TSFunctionType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSFunctionType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSConstructorType<'a>> { #[inline] pub fn r#abstract(&self) -> bool { @@ -10228,13 +8691,6 @@ impl<'a> AstNode<'a, TSConstructorType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSConstructorType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSMappedType<'a>> { #[inline] pub fn type_parameter(&self) -> &AstNode<'a, TSTypeParameter<'a>> { @@ -10299,13 +8755,6 @@ impl<'a> AstNode<'a, TSMappedType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSMappedType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTemplateLiteralType<'a>> { #[inline] pub fn quasis(&self) -> &AstNode<'a, Vec<'a, TemplateElement<'a>>> { @@ -10338,13 +8787,6 @@ impl<'a> AstNode<'a, TSTemplateLiteralType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTemplateLiteralType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSAsExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10377,13 +8819,6 @@ impl<'a> AstNode<'a, TSAsExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSAsExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSSatisfiesExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10416,13 +8851,6 @@ impl<'a> AstNode<'a, TSSatisfiesExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSSatisfiesExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSTypeAssertion<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -10455,13 +8883,6 @@ impl<'a> AstNode<'a, TSTypeAssertion<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSTypeAssertion<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSImportEqualsDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, BindingIdentifier<'a>> { @@ -10499,13 +8920,6 @@ impl<'a> AstNode<'a, TSImportEqualsDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSImportEqualsDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSModuleReference<'a>> { #[inline] pub fn as_ast_nodes(&self) -> &AstNodes<'a> { @@ -10535,13 +8949,6 @@ impl<'a> AstNode<'a, TSModuleReference<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSModuleReference<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSExternalModuleReference<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, StringLiteral<'a>> { @@ -10563,13 +8970,6 @@ impl<'a> AstNode<'a, TSExternalModuleReference<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSExternalModuleReference<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNonNullExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10591,13 +8991,6 @@ impl<'a> AstNode<'a, TSNonNullExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSNonNullExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, Decorator<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10619,13 +9012,6 @@ impl<'a> AstNode<'a, Decorator<'a>> { } } -impl<'a> GetSpan for AstNode<'a, Decorator<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSExportAssignment<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10647,13 +9033,6 @@ impl<'a> AstNode<'a, TSExportAssignment<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSExportAssignment<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSNamespaceExportDeclaration<'a>> { #[inline] pub fn id(&self) -> &AstNode<'a, IdentifierName<'a>> { @@ -10677,13 +9056,6 @@ impl<'a> AstNode<'a, TSNamespaceExportDeclaration<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSNamespaceExportDeclaration<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, TSInstantiationExpression<'a>> { #[inline] pub fn expression(&self) -> &AstNode<'a, Expression<'a>> { @@ -10716,13 +9088,6 @@ impl<'a> AstNode<'a, TSInstantiationExpression<'a>> { } } -impl<'a> GetSpan for AstNode<'a, TSInstantiationExpression<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSDocNullableType<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -10749,13 +9114,6 @@ impl<'a> AstNode<'a, JSDocNullableType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSDocNullableType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSDocNonNullableType<'a>> { #[inline] pub fn type_annotation(&self) -> &AstNode<'a, TSType<'a>> { @@ -10782,13 +9140,6 @@ impl<'a> AstNode<'a, JSDocNonNullableType<'a>> { } } -impl<'a> GetSpan for AstNode<'a, JSDocNonNullableType<'a>> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - impl<'a> AstNode<'a, JSDocUnknownType> { pub fn format_leading_comments(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> { format_leading_comments(self.span()).fmt(f) @@ -10798,1718 +9149,3 @@ impl<'a> AstNode<'a, JSDocUnknownType> { format_trailing_comments(self.parent.span(), self.inner.span(), self.following_span).fmt(f) } } - -impl<'a> GetSpan for AstNode<'a, JSDocUnknownType> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } -} - -pub struct AstNodeIterator<'a, T> { - inner: std::iter::Peekable>, - parent: &'a AstNodes<'a>, - allocator: &'a Allocator, -} - -impl<'a> AstNode<'a, Vec<'a, Expression<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Expression<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Expression<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Expression<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Expression<'a>> { - type Item = &'a AstNode<'a, Expression<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Expression<'a>>> { - type Item = &'a AstNode<'a, Expression<'a>>; - type IntoIter = AstNodeIterator<'a, Expression<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ArrayExpressionElement<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ArrayExpressionElement<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ArrayExpressionElement<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ArrayExpressionElement<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ArrayExpressionElement<'a>> { - type Item = &'a AstNode<'a, ArrayExpressionElement<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ArrayExpressionElement<'a>>> { - type Item = &'a AstNode<'a, ArrayExpressionElement<'a>>; - type IntoIter = AstNodeIterator<'a, ArrayExpressionElement<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ObjectPropertyKind<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ObjectPropertyKind<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ObjectPropertyKind<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ObjectPropertyKind<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ObjectPropertyKind<'a>> { - type Item = &'a AstNode<'a, ObjectPropertyKind<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ObjectPropertyKind<'a>>> { - type Item = &'a AstNode<'a, ObjectPropertyKind<'a>>; - type IntoIter = AstNodeIterator<'a, ObjectPropertyKind<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TemplateElement<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TemplateElement<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TemplateElement<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TemplateElement<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TemplateElement<'a>> { - type Item = &'a AstNode<'a, TemplateElement<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TemplateElement<'a>>> { - type Item = &'a AstNode<'a, TemplateElement<'a>>; - type IntoIter = AstNodeIterator<'a, TemplateElement<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Argument<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Argument<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Argument<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Argument<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Argument<'a>> { - type Item = &'a AstNode<'a, Argument<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Argument<'a>>> { - type Item = &'a AstNode<'a, Argument<'a>>; - type IntoIter = AstNodeIterator<'a, Argument<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, AssignmentTargetProperty<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, AssignmentTargetProperty<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, AssignmentTargetProperty<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, AssignmentTargetProperty<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, AssignmentTargetProperty<'a>> { - type Item = &'a AstNode<'a, AssignmentTargetProperty<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, AssignmentTargetProperty<'a>>> { - type Item = &'a AstNode<'a, AssignmentTargetProperty<'a>>; - type IntoIter = AstNodeIterator<'a, AssignmentTargetProperty<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Statement<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Statement<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Statement<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Statement<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Statement<'a>> { - type Item = &'a AstNode<'a, Statement<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Statement<'a>>> { - type Item = &'a AstNode<'a, Statement<'a>>; - type IntoIter = AstNodeIterator<'a, Statement<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Directive<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Directive<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Directive<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Directive<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Directive<'a>> { - type Item = &'a AstNode<'a, Directive<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Directive<'a>>> { - type Item = &'a AstNode<'a, Directive<'a>>; - type IntoIter = AstNodeIterator<'a, Directive<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, VariableDeclarator<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, VariableDeclarator<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, VariableDeclarator<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, VariableDeclarator<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, VariableDeclarator<'a>> { - type Item = &'a AstNode<'a, VariableDeclarator<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, VariableDeclarator<'a>>> { - type Item = &'a AstNode<'a, VariableDeclarator<'a>>; - type IntoIter = AstNodeIterator<'a, VariableDeclarator<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, SwitchCase<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, SwitchCase<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, SwitchCase<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, SwitchCase<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, SwitchCase<'a>> { - type Item = &'a AstNode<'a, SwitchCase<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, SwitchCase<'a>>> { - type Item = &'a AstNode<'a, SwitchCase<'a>>; - type IntoIter = AstNodeIterator<'a, SwitchCase<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, BindingProperty<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, BindingProperty<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, BindingProperty<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, BindingProperty<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, BindingProperty<'a>> { - type Item = &'a AstNode<'a, BindingProperty<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, BindingProperty<'a>>> { - type Item = &'a AstNode<'a, BindingProperty<'a>>; - type IntoIter = AstNodeIterator<'a, BindingProperty<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, FormalParameter<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, FormalParameter<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, FormalParameter<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, FormalParameter<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, FormalParameter<'a>> { - type Item = &'a AstNode<'a, FormalParameter<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, FormalParameter<'a>>> { - type Item = &'a AstNode<'a, FormalParameter<'a>>; - type IntoIter = AstNodeIterator<'a, FormalParameter<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ClassElement<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ClassElement<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ClassElement<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ClassElement<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ClassElement<'a>> { - type Item = &'a AstNode<'a, ClassElement<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ClassElement<'a>>> { - type Item = &'a AstNode<'a, ClassElement<'a>>; - type IntoIter = AstNodeIterator<'a, ClassElement<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ImportDeclarationSpecifier<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ImportDeclarationSpecifier<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ImportDeclarationSpecifier<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ImportDeclarationSpecifier<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ImportDeclarationSpecifier<'a>> { - type Item = &'a AstNode<'a, ImportDeclarationSpecifier<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ImportDeclarationSpecifier<'a>>> { - type Item = &'a AstNode<'a, ImportDeclarationSpecifier<'a>>; - type IntoIter = AstNodeIterator<'a, ImportDeclarationSpecifier<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ImportAttribute<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ImportAttribute<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ImportAttribute<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ImportAttribute<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ImportAttribute<'a>> { - type Item = &'a AstNode<'a, ImportAttribute<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ImportAttribute<'a>>> { - type Item = &'a AstNode<'a, ImportAttribute<'a>>; - type IntoIter = AstNodeIterator<'a, ImportAttribute<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, ExportSpecifier<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, ExportSpecifier<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, ExportSpecifier<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, ExportSpecifier<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, ExportSpecifier<'a>> { - type Item = &'a AstNode<'a, ExportSpecifier<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, ExportSpecifier<'a>>> { - type Item = &'a AstNode<'a, ExportSpecifier<'a>>; - type IntoIter = AstNodeIterator<'a, ExportSpecifier<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, JSXAttributeItem<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, JSXAttributeItem<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, JSXAttributeItem<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, JSXAttributeItem<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, JSXAttributeItem<'a>> { - type Item = &'a AstNode<'a, JSXAttributeItem<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, JSXAttributeItem<'a>>> { - type Item = &'a AstNode<'a, JSXAttributeItem<'a>>; - type IntoIter = AstNodeIterator<'a, JSXAttributeItem<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, JSXChild<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, JSXChild<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, JSXChild<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, JSXChild<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, JSXChild<'a>> { - type Item = &'a AstNode<'a, JSXChild<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, JSXChild<'a>>> { - type Item = &'a AstNode<'a, JSXChild<'a>>; - type IntoIter = AstNodeIterator<'a, JSXChild<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSEnumMember<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSEnumMember<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSEnumMember<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSEnumMember<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSEnumMember<'a>> { - type Item = &'a AstNode<'a, TSEnumMember<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSEnumMember<'a>>> { - type Item = &'a AstNode<'a, TSEnumMember<'a>>; - type IntoIter = AstNodeIterator<'a, TSEnumMember<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSType<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSType<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSType<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSType<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSType<'a>> { - type Item = &'a AstNode<'a, TSType<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSType<'a>>> { - type Item = &'a AstNode<'a, TSType<'a>>; - type IntoIter = AstNodeIterator<'a, TSType<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSTupleElement<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSTupleElement<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSTupleElement<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSTupleElement<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSTupleElement<'a>> { - type Item = &'a AstNode<'a, TSTupleElement<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSTupleElement<'a>>> { - type Item = &'a AstNode<'a, TSTupleElement<'a>>; - type IntoIter = AstNodeIterator<'a, TSTupleElement<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSTypeParameter<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSTypeParameter<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSTypeParameter<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSTypeParameter<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSTypeParameter<'a>> { - type Item = &'a AstNode<'a, TSTypeParameter<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSTypeParameter<'a>>> { - type Item = &'a AstNode<'a, TSTypeParameter<'a>>; - type IntoIter = AstNodeIterator<'a, TSTypeParameter<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSClassImplements<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSClassImplements<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSClassImplements<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSClassImplements<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSClassImplements<'a>> { - type Item = &'a AstNode<'a, TSClassImplements<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSClassImplements<'a>>> { - type Item = &'a AstNode<'a, TSClassImplements<'a>>; - type IntoIter = AstNodeIterator<'a, TSClassImplements<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSSignature<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSSignature<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSSignature<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSSignature<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSSignature<'a>> { - type Item = &'a AstNode<'a, TSSignature<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSSignature<'a>>> { - type Item = &'a AstNode<'a, TSSignature<'a>>; - type IntoIter = AstNodeIterator<'a, TSSignature<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSIndexSignatureName<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSIndexSignatureName<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSIndexSignatureName<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSIndexSignatureName<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSIndexSignatureName<'a>> { - type Item = &'a AstNode<'a, TSIndexSignatureName<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSIndexSignatureName<'a>>> { - type Item = &'a AstNode<'a, TSIndexSignatureName<'a>>; - type IntoIter = AstNodeIterator<'a, TSIndexSignatureName<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, TSInterfaceHeritage<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, TSInterfaceHeritage<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, TSInterfaceHeritage<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, TSInterfaceHeritage<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, TSInterfaceHeritage<'a>> { - type Item = &'a AstNode<'a, TSInterfaceHeritage<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, TSInterfaceHeritage<'a>>> { - type Item = &'a AstNode<'a, TSInterfaceHeritage<'a>>; - type IntoIter = AstNodeIterator<'a, TSInterfaceHeritage<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Decorator<'a>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Decorator<'a>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Decorator<'a>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter.next().map(GetSpan::span), - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Decorator<'a>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Decorator<'a>> { - type Item = &'a AstNode<'a, Decorator<'a>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek().copied().map(GetSpan::span); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Decorator<'a>>> { - type Item = &'a AstNode<'a, Decorator<'a>>; - type IntoIter = AstNodeIterator<'a, Decorator<'a>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Option>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Option>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Option>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| { - AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter - .next() - .map(|next| next.as_ref().map(GetSpan::span)) - .unwrap_or_default(), - } - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Option>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Option>> { - type Item = &'a AstNode<'a, Option>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self - .inner - .peek() - .copied() - .map(|next| next.as_ref().map(GetSpan::span)) - .unwrap_or_default(); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Option>>> { - type Item = &'a AstNode<'a, Option>>; - type IntoIter = AstNodeIterator<'a, Option>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::>> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} - -impl<'a> AstNode<'a, Vec<'a, Option>>> { - pub fn iter(&self) -> AstNodeIterator<'a, Option>> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - - pub fn first(&self) -> Option<&'a AstNode<'a, Option>>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| { - AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter - .next() - .map(|next| next.as_ref().map(GetSpan::span)) - .unwrap_or_default(), - } - })) - .as_ref() - } - - pub fn last(&self) -> Option<&'a AstNode<'a, Option>>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } -} - -impl<'a> Iterator for AstNodeIterator<'a, Option>> { - type Item = &'a AstNode<'a, Option>>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self - .inner - .peek() - .copied() - .map(|next| next.as_ref().map(GetSpan::span)) - .unwrap_or_default(); - AstNode { parent: self.parent, inner, allocator, following_span } - })) - .as_ref() - } -} - -impl<'a> IntoIterator for &AstNode<'a, Vec<'a, Option>>> { - type Item = &'a AstNode<'a, Option>>; - type IntoIter = AstNodeIterator<'a, Option>>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::>> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } -} diff --git a/crates/oxc_formatter/src/generated/format.rs b/crates/oxc_formatter/src/ast_nodes/generated/format.rs similarity index 99% rename from crates/oxc_formatter/src/generated/format.rs rename to crates/oxc_formatter/src/ast_nodes/generated/format.rs index 43dc89c2778ae..d649f3b5744ad 100644 --- a/crates/oxc_formatter/src/generated/format.rs +++ b/crates/oxc_formatter/src/ast_nodes/generated/format.rs @@ -5,9 +5,10 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; +use super::ast_nodes::transmute_self; use crate::{ + ast_nodes::{AstNode, AstNodes}, formatter::{Buffer, Format, FormatResult, Formatter, trivia::FormatTrailingComments}, - generated::ast_nodes::{AstNode, AstNodes, transmute_self}, parentheses::NeedsParentheses, utils::{suppressed::FormatSuppressedNode, typecast::format_type_cast_comment_node}, write::{FormatFunctionOptions, FormatJsArrowFunctionExpressionOptions, FormatWrite}, diff --git a/crates/oxc_formatter/src/ast_nodes/generated/mod.rs b/crates/oxc_formatter/src/ast_nodes/generated/mod.rs new file mode 100644 index 0000000000000..2261e64ea5ebd --- /dev/null +++ b/crates/oxc_formatter/src/ast_nodes/generated/mod.rs @@ -0,0 +1,2 @@ +pub mod ast_nodes; +mod format; diff --git a/crates/oxc_formatter/src/ast_nodes/iterator.rs b/crates/oxc_formatter/src/ast_nodes/iterator.rs new file mode 100644 index 0000000000000..2a85a5f3d9b97 --- /dev/null +++ b/crates/oxc_formatter/src/ast_nodes/iterator.rs @@ -0,0 +1,183 @@ +//! Iterator implementations for `Vec` in AstNode. +//! +//! This module provides two macros for generating iterator implementations: +//! - `impl_ast_node_vec!` - For non-Option types (uses `.map()`) +//! - `impl_ast_node_vec_for_option!` - For Option types (uses `.and_then()`) + +use oxc_allocator::{Allocator, Vec}; +use oxc_ast::ast::*; +use oxc_span::{GetSpan, Span}; + +use super::{AstNode, AstNodes}; + +pub struct AstNodeIterator<'a, T> { + inner: std::iter::Peekable>, + parent: &'a AstNodes<'a>, + allocator: &'a Allocator, +} + +macro_rules! impl_ast_node_vec { + ($type:ty) => { + impl<'a> AstNode<'a, Vec<'a, $type>> { + pub fn iter(&self) -> AstNodeIterator<'a, $type> { + AstNodeIterator { + inner: self.inner.iter().peekable(), + parent: self.parent, + allocator: self.allocator, + } + } + + pub fn first(&self) -> Option<&'a AstNode<'a, $type>> { + let mut inner_iter = self.inner.iter(); + self.allocator + .alloc(inner_iter.next().map(|inner| AstNode { + inner, + parent: self.parent, + allocator: self.allocator, + following_span: inner_iter.next().map(GetSpan::span), + })) + .as_ref() + } + + pub fn last(&self) -> Option<&'a AstNode<'a, $type>> { + self.allocator + .alloc(self.inner.last().map(|inner| AstNode { + inner, + parent: self.parent, + allocator: self.allocator, + following_span: None, + })) + .as_ref() + } + } + + impl<'a> Iterator for AstNodeIterator<'a, $type> { + type Item = &'a AstNode<'a, $type>; + fn next(&mut self) -> Option { + let allocator = self.allocator; + allocator + .alloc(self.inner.next().map(|inner| AstNode { + parent: self.parent, + inner, + allocator, + following_span: self.inner.peek().copied().map(GetSpan::span), + })) + .as_ref() + } + } + + impl<'a> IntoIterator for &AstNode<'a, Vec<'a, $type>> { + type Item = &'a AstNode<'a, $type>; + type IntoIter = AstNodeIterator<'a, $type>; + fn into_iter(self) -> Self::IntoIter { + AstNodeIterator::<$type> { + inner: self.inner.iter().peekable(), + parent: self.parent, + allocator: self.allocator, + } + } + } + }; +} + +macro_rules! impl_ast_node_vec_for_option { + ($type:ty) => { + impl<'a> AstNode<'a, Vec<'a, $type>> { + pub fn iter(&self) -> AstNodeIterator<'a, $type> { + AstNodeIterator { + inner: self.inner.iter().peekable(), + parent: self.parent, + allocator: self.allocator, + } + } + + pub fn first(&self) -> Option<&'a AstNode<'a, $type>> { + let mut inner_iter = self.inner.iter(); + self.allocator + .alloc(inner_iter.next().map(|inner| AstNode { + inner, + parent: self.parent, + allocator: self.allocator, + following_span: + inner_iter.next().and_then(|opt| opt.as_ref().map(GetSpan::span)), + })) + .as_ref() + } + + pub fn last(&self) -> Option<&'a AstNode<'a, $type>> { + self.allocator + .alloc(self.inner.last().map(|inner| AstNode { + inner, + parent: self.parent, + allocator: self.allocator, + following_span: None, + })) + .as_ref() + } + } + + impl<'a> Iterator for AstNodeIterator<'a, $type> { + type Item = &'a AstNode<'a, $type>; + fn next(&mut self) -> Option { + let allocator = self.allocator; + allocator + .alloc(self.inner.next().map(|inner| { + AstNode { + parent: self.parent, + inner, + allocator, + following_span: self + .inner + .peek() + .copied() + .and_then(|opt| opt.as_ref().map(GetSpan::span)), + } + })) + .as_ref() + } + } + + impl<'a> IntoIterator for &AstNode<'a, Vec<'a, $type>> { + type Item = &'a AstNode<'a, $type>; + type IntoIter = AstNodeIterator<'a, $type>; + fn into_iter(self) -> Self::IntoIter { + AstNodeIterator::<$type> { + inner: self.inner.iter().peekable(), + parent: self.parent, + allocator: self.allocator, + } + } + } + }; +} + +// Concrete implementations for all Vec types used in the AST +impl_ast_node_vec!(Expression<'a>); +impl_ast_node_vec!(ArrayExpressionElement<'a>); +impl_ast_node_vec!(ObjectPropertyKind<'a>); +impl_ast_node_vec!(TemplateElement<'a>); +impl_ast_node_vec!(Argument<'a>); +impl_ast_node_vec!(AssignmentTargetProperty<'a>); +impl_ast_node_vec!(Statement<'a>); +impl_ast_node_vec!(Directive<'a>); +impl_ast_node_vec!(VariableDeclarator<'a>); +impl_ast_node_vec!(SwitchCase<'a>); +impl_ast_node_vec!(BindingProperty<'a>); +impl_ast_node_vec!(FormalParameter<'a>); +impl_ast_node_vec!(ClassElement<'a>); +impl_ast_node_vec!(ImportDeclarationSpecifier<'a>); +impl_ast_node_vec!(ImportAttribute<'a>); +impl_ast_node_vec!(ExportSpecifier<'a>); +impl_ast_node_vec!(JSXAttributeItem<'a>); +impl_ast_node_vec!(JSXChild<'a>); +impl_ast_node_vec!(TSEnumMember<'a>); +impl_ast_node_vec!(TSType<'a>); +impl_ast_node_vec!(TSTupleElement<'a>); +impl_ast_node_vec!(TSTypeParameter<'a>); +impl_ast_node_vec!(TSClassImplements<'a>); +impl_ast_node_vec!(TSSignature<'a>); +impl_ast_node_vec!(TSIndexSignatureName<'a>); +impl_ast_node_vec!(TSInterfaceHeritage<'a>); +impl_ast_node_vec!(Decorator<'a>); +impl_ast_node_vec_for_option!(Option>); +impl_ast_node_vec_for_option!(Option>); diff --git a/crates/oxc_formatter/src/ast_nodes/mod.rs b/crates/oxc_formatter/src/ast_nodes/mod.rs new file mode 100644 index 0000000000000..59b9c868003af --- /dev/null +++ b/crates/oxc_formatter/src/ast_nodes/mod.rs @@ -0,0 +1,7 @@ +pub mod generated; +mod iterator; +mod node; + +pub use generated::ast_nodes::AstNodes; +pub use iterator::AstNodeIterator; +pub use node::AstNode; diff --git a/crates/oxc_formatter/src/ast_nodes/node.rs b/crates/oxc_formatter/src/ast_nodes/node.rs new file mode 100644 index 0000000000000..492e95e3186b2 --- /dev/null +++ b/crates/oxc_formatter/src/ast_nodes/node.rs @@ -0,0 +1,70 @@ +use core::fmt; +use std::ops::Deref; + +use oxc_allocator::Allocator; +use oxc_ast::ast::Program; +use oxc_span::{GetSpan, Span}; + +use super::AstNodes; + +pub struct AstNode<'a, T> { + pub(super) inner: &'a T, + pub parent: &'a AstNodes<'a>, + pub(super) allocator: &'a Allocator, + pub(super) following_span: Option, +} + +impl fmt::Debug for AstNode<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("AstNode") + .field("inner", &self.inner) + .field("parent", &self.parent.debug_name()) + .field("following_span", &self.following_span) + .finish() + } +} + +impl<'a, T> Deref for AstNode<'a, T> { + type Target = T; + + fn deref(&self) -> &'a Self::Target { + self.inner + } +} + +impl<'a, T> AsRef for AstNode<'a, T> { + fn as_ref(&self) -> &'a T { + self.inner + } +} + +impl<'a, T> AstNode<'a, Option> { + pub fn as_ref(&self) -> Option<&'a AstNode<'a, T>> { + self.allocator + .alloc(self.inner.as_ref().map(|inner| AstNode { + inner, + parent: self.parent, + allocator: self.allocator, + following_span: self.following_span, + })) + .as_ref() + } +} + +impl GetSpan for AstNode<'_, T> { + fn span(&self) -> Span { + self.inner.span() + } +} + +impl GetSpan for &AstNode<'_, T> { + fn span(&self) -> Span { + self.inner.span() + } +} + +impl<'a> AstNode<'a, Program<'a>> { + pub fn new(inner: &'a Program<'a>, parent: &'a AstNodes<'a>, allocator: &'a Allocator) -> Self { + AstNode { inner, parent, allocator, following_span: None } + } +} diff --git a/crates/oxc_formatter/src/formatter/comments.rs b/crates/oxc_formatter/src/formatter/comments.rs index 534fcd4d46cfa..5efa718b47080 100644 --- a/crates/oxc_formatter/src/formatter/comments.rs +++ b/crates/oxc_formatter/src/formatter/comments.rs @@ -323,7 +323,7 @@ impl<'a> Comments<'a> { } if !source_text.all_bytes_match(start, comment.span.start, |b| { - b.is_ascii_whitespace() || matches!(b, b')' | b',' | b';') + b.is_ascii_whitespace() || matches!(b, b')' | b',') }) { return &comments[..idx]; } diff --git a/crates/oxc_formatter/src/formatter/context.rs b/crates/oxc_formatter/src/formatter/context.rs index 5384f385259e0..718d60fba7baa 100644 --- a/crates/oxc_formatter/src/formatter/context.rs +++ b/crates/oxc_formatter/src/formatter/context.rs @@ -8,7 +8,7 @@ use oxc_ast::{ use oxc_span::{GetSpan, SourceType, Span}; use rustc_hash::FxHashMap; -use crate::{formatter::FormatElement, generated::ast_nodes::AstNode, options::FormatOptions}; +use crate::{ast_nodes::AstNode, formatter::FormatElement, options::FormatOptions}; use super::{Comments, SourceText}; diff --git a/crates/oxc_formatter/src/lib.rs b/crates/oxc_formatter/src/lib.rs index 7382c8078a037..c8c08d87b2459 100644 --- a/crates/oxc_formatter/src/lib.rs +++ b/crates/oxc_formatter/src/lib.rs @@ -9,10 +9,7 @@ clippy::struct_field_names )] // FIXME: all these needs to be fixed. -mod generated { - pub mod ast_nodes; - mod format; -} +mod ast_nodes; mod formatter; mod ir_transform; mod options; @@ -40,8 +37,8 @@ pub use crate::service::{ source_type::{enable_jsx_source_type, get_supported_source_type}, }; use crate::{ + ast_nodes::{AstNode, AstNodes}, formatter::{FormatContext, Formatted, format_element::document::Document}, - generated::ast_nodes::{AstNode, AstNodes}, ir_transform::SortImportsTransform, }; diff --git a/crates/oxc_formatter/src/parentheses/assignment.rs b/crates/oxc_formatter/src/parentheses/assignment.rs index ef41770e88025..5e7c150b309ac 100644 --- a/crates/oxc_formatter/src/parentheses/assignment.rs +++ b/crates/oxc_formatter/src/parentheses/assignment.rs @@ -6,6 +6,6 @@ use oxc_syntax::{ }; use crate::{ + ast_nodes::{AstNode, AstNodes}, formatter::Formatter, - generated::ast_nodes::{AstNode, AstNodes}, }; diff --git a/crates/oxc_formatter/src/parentheses/expression.rs b/crates/oxc_formatter/src/parentheses/expression.rs index e4af967873ae6..e4eb88c4f3d61 100644 --- a/crates/oxc_formatter/src/parentheses/expression.rs +++ b/crates/oxc_formatter/src/parentheses/expression.rs @@ -12,8 +12,8 @@ use oxc_syntax::{ use crate::{ Format, + ast_nodes::{AstNode, AstNodes}, formatter::Formatter, - generated::ast_nodes::{AstNode, AstNodes}, write::{BinaryLikeExpression, ExpressionLeftSide, should_flatten}, }; diff --git a/crates/oxc_formatter/src/parentheses/ts_type.rs b/crates/oxc_formatter/src/parentheses/ts_type.rs index 82fad2b01f9ce..32ce00eb09ae9 100644 --- a/crates/oxc_formatter/src/parentheses/ts_type.rs +++ b/crates/oxc_formatter/src/parentheses/ts_type.rs @@ -4,8 +4,8 @@ use oxc_span::GetSpan; use super::NeedsParentheses; use crate::{ Format, + ast_nodes::{AstNode, AstNodes}, formatter::Formatter, - generated::ast_nodes::{AstNode, AstNodes}, write::{BinaryLikeExpression, ExpressionLeftSide, should_flatten}, }; diff --git a/crates/oxc_formatter/src/utils/assignment_like.rs b/crates/oxc_formatter/src/utils/assignment_like.rs index 8f7910733c6f9..7fff0cbb1fc34 100644 --- a/crates/oxc_formatter/src/utils/assignment_like.rs +++ b/crates/oxc_formatter/src/utils/assignment_like.rs @@ -5,13 +5,14 @@ use oxc_span::GetSpan; use unicode_width::UnicodeWidthStr; use crate::{ - FormatOptions, format_args, + FormatOptions, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Buffer, BufferExtensions, Format, FormatResult, Formatter, VecBuffer, prelude::{FormatElements, format_once, line_suffix_boundary, *}, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, options::Expand, parentheses::NeedsParentheses, utils::{ diff --git a/crates/oxc_formatter/src/utils/call_expression.rs b/crates/oxc_formatter/src/utils/call_expression.rs index d8e7cdc946077..3125ee0006b66 100644 --- a/crates/oxc_formatter/src/utils/call_expression.rs +++ b/crates/oxc_formatter/src/utils/call_expression.rs @@ -1,6 +1,6 @@ use oxc_ast::ast::*; -use crate::generated::ast_nodes::{AstNode, AstNodes}; +use crate::ast_nodes::{AstNode, AstNodes}; /// This is a specialized function that checks if the current [call expression] /// resembles a call expression usually used by a testing frameworks. diff --git a/crates/oxc_formatter/src/utils/conditional.rs b/crates/oxc_formatter/src/utils/conditional.rs index dfc1f92c686c3..58f6e1ea49ee4 100644 --- a/crates/oxc_formatter/src/utils/conditional.rs +++ b/crates/oxc_formatter/src/utils/conditional.rs @@ -4,9 +4,10 @@ use oxc_ast::ast::*; use oxc_span::{GetSpan, Span}; use crate::{ - Format, FormatResult, FormatWrite, format_args, + Format, FormatResult, FormatWrite, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{Formatter, prelude::*, trivia::FormatTrailingComments}, - generated::ast_nodes::{AstNode, AstNodes}, utils::format_node_without_trailing_comments::FormatNodeWithoutTrailingComments, write, }; diff --git a/crates/oxc_formatter/src/utils/jsx.rs b/crates/oxc_formatter/src/utils/jsx.rs index 18f28bc5abc95..5bb5b9cae54ea 100644 --- a/crates/oxc_formatter/src/utils/jsx.rs +++ b/crates/oxc_formatter/src/utils/jsx.rs @@ -8,9 +8,10 @@ use oxc_span::{GetSpan, Span}; use crate::QuoteStyle; use crate::formatter::Comments; use crate::{ - FormatResult, format_args, + FormatResult, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{Formatter, prelude::*}, - generated::ast_nodes::{AstNode, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/utils/member_chain/chain_member.rs b/crates/oxc_formatter/src/utils/member_chain/chain_member.rs index fcc221d063549..a3d19a2aceaa0 100644 --- a/crates/oxc_formatter/src/utils/member_chain/chain_member.rs +++ b/crates/oxc_formatter/src/utils/member_chain/chain_member.rs @@ -1,13 +1,13 @@ use std::ops::Deref; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Format, FormatResult, Formatter, prelude::*, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, }; use oxc_ast::{AstKind, ast::*}; diff --git a/crates/oxc_formatter/src/utils/member_chain/groups.rs b/crates/oxc_formatter/src/utils/member_chain/groups.rs index cef5efef2886d..7af5cb8c30b26 100644 --- a/crates/oxc_formatter/src/utils/member_chain/groups.rs +++ b/crates/oxc_formatter/src/utils/member_chain/groups.rs @@ -4,8 +4,8 @@ use oxc_span::{GetSpan, Span}; use super::chain_member::ChainMember; use crate::{ + ast_nodes::AstNode, formatter::{Format, FormatResult, Formatter, SourceText, prelude::*}, - generated::ast_nodes::AstNode, parentheses::NeedsParentheses, write, }; diff --git a/crates/oxc_formatter/src/utils/member_chain/mod.rs b/crates/oxc_formatter/src/utils/member_chain/mod.rs index 123e0676705c7..6b25b249f56f6 100644 --- a/crates/oxc_formatter/src/utils/member_chain/mod.rs +++ b/crates/oxc_formatter/src/utils/member_chain/mod.rs @@ -5,9 +5,10 @@ pub mod simple_argument; use std::iter; use crate::{ - JsLabels, best_fitting, + JsLabels, + ast_nodes::{AstNode, AstNodes}, + best_fitting, formatter::{Buffer, Format, FormatResult, Formatter, SourceText, prelude::*}, - generated::ast_nodes::{AstNode, AstNodes}, utils::{ call_expression::is_test_call_expression, is_long_curried_call, diff --git a/crates/oxc_formatter/src/utils/mod.rs b/crates/oxc_formatter/src/utils/mod.rs index 44cfdad6c5f01..e77d0709dce1d 100644 --- a/crates/oxc_formatter/src/utils/mod.rs +++ b/crates/oxc_formatter/src/utils/mod.rs @@ -14,9 +14,10 @@ use oxc_allocator::Address; use oxc_ast::{AstKind, ast::CallExpression}; use crate::{ - Format, FormatResult, FormatTrailingCommas, format_args, + Format, FormatResult, FormatTrailingCommas, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{Formatter, prelude::soft_line_break_or_space}, - generated::ast_nodes::{AstNode, AstNodes}, }; /// Tests if expression is a long curried call diff --git a/crates/oxc_formatter/src/utils/object.rs b/crates/oxc_formatter/src/utils/object.rs index 104472ad3b820..56517c87541a1 100644 --- a/crates/oxc_formatter/src/utils/object.rs +++ b/crates/oxc_formatter/src/utils/object.rs @@ -4,8 +4,8 @@ use unicode_width::UnicodeWidthStr; use crate::{ Buffer, Format, FormatResult, + ast_nodes::{AstNode, AstNodes}, formatter::Formatter, - generated::ast_nodes::{AstNode, AstNodes}, utils::string_utils::{FormatLiteralStringToken, StringLiteralParentKind}, write, }; diff --git a/crates/oxc_formatter/src/utils/typecast.rs b/crates/oxc_formatter/src/utils/typecast.rs index 39352b22dc5f1..801f83f13a423 100644 --- a/crates/oxc_formatter/src/utils/typecast.rs +++ b/crates/oxc_formatter/src/utils/typecast.rs @@ -5,9 +5,10 @@ use oxc_ast::{ use oxc_span::GetSpan; use crate::{ - Buffer, Format, FormatResult, format_args, + Buffer, Format, FormatResult, + ast_nodes::AstNode, + format_args, formatter::{Formatter, SourceText, prelude::*, trivia::FormatLeadingComments}, - generated::ast_nodes::AstNode, write, write::{ FormatFunctionOptions, FormatJsArrowFunctionExpression, diff --git a/crates/oxc_formatter/src/utils/typescript.rs b/crates/oxc_formatter/src/utils/typescript.rs index f79ecc3a5c35b..2432e41667f5b 100644 --- a/crates/oxc_formatter/src/utils/typescript.rs +++ b/crates/oxc_formatter/src/utils/typescript.rs @@ -1,7 +1,7 @@ use oxc_ast::ast::{TSType, TSUnionType}; use oxc_span::GetSpan; -use crate::{formatter::Formatter, generated::ast_nodes::AstNode}; +use crate::{ast_nodes::AstNode, formatter::Formatter}; /// Check if a TSType is a simple type (primitives, keywords, simple references) pub fn is_simple_type(ty: &TSType) -> bool { diff --git a/crates/oxc_formatter/src/write/array_element_list.rs b/crates/oxc_formatter/src/write/array_element_list.rs index fa38f9d0910a8..8b6babbe86e19 100644 --- a/crates/oxc_formatter/src/write/array_element_list.rs +++ b/crates/oxc_formatter/src/write/array_element_list.rs @@ -4,11 +4,11 @@ use oxc_span::GetSpan; use crate::{ Expand, FormatTrailingCommas, + ast_nodes::AstNode, formatter::{ Buffer, Comments, Format, FormatResult, Formatter, GroupId, prelude::*, separated::FormatSeparatedIter, }, - generated::ast_nodes::AstNode, write, }; diff --git a/crates/oxc_formatter/src/write/array_expression.rs b/crates/oxc_formatter/src/write/array_expression.rs index b99ae303043a9..8f73355c50058 100644 --- a/crates/oxc_formatter/src/write/array_expression.rs +++ b/crates/oxc_formatter/src/write/array_expression.rs @@ -1,8 +1,8 @@ use oxc_ast::ast::*; use crate::{ + ast_nodes::AstNode, formatter::{Buffer, Formatter, prelude::*}, - generated::ast_nodes::AstNode, options::Expand, write, }; diff --git a/crates/oxc_formatter/src/write/array_pattern.rs b/crates/oxc_formatter/src/write/array_pattern.rs index 5f680e883aadd..68215e3dd9663 100644 --- a/crates/oxc_formatter/src/write/array_pattern.rs +++ b/crates/oxc_formatter/src/write/array_pattern.rs @@ -5,8 +5,8 @@ use oxc_span::{GetSpan, Span}; use crate::{ Format, FormatResult, + ast_nodes::{AstNode, AstNodes}, formatter::{Formatter, prelude::*, trivia::format_dangling_comments}, - generated::ast_nodes::{AstNode, AstNodes}, utils::format_node_without_trailing_comments::FormatNodeWithoutTrailingComments, write, write::utils::array::write_array_node, diff --git a/crates/oxc_formatter/src/write/arrow_function_expression.rs b/crates/oxc_formatter/src/write/arrow_function_expression.rs index f4dc6db90fff5..787bd10b2674f 100644 --- a/crates/oxc_formatter/src/write/arrow_function_expression.rs +++ b/crates/oxc_formatter/src/write/arrow_function_expression.rs @@ -4,6 +4,7 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Buffer, Comments, Format, FormatError, FormatResult, Formatter, SourceText, @@ -11,7 +12,6 @@ use crate::{ prelude::*, trivia::{FormatLeadingComments, format_trailing_comments}, }, - generated::ast_nodes::{AstNode, AstNodes}, options::FormatTrailingCommas, utils::assignment_like::AssignmentLikeLayout, write, diff --git a/crates/oxc_formatter/src/write/as_or_satisfies_expression.rs b/crates/oxc_formatter/src/write/as_or_satisfies_expression.rs index f70fc0f4e83e0..6f9dd380de028 100644 --- a/crates/oxc_formatter/src/write/as_or_satisfies_expression.rs +++ b/crates/oxc_formatter/src/write/as_or_satisfies_expression.rs @@ -2,9 +2,9 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{FormatResult, Formatter, prelude::*}, - generated::ast_nodes::{AstNode, AstNodes}, write, write::FormatWrite, }; diff --git a/crates/oxc_formatter/src/write/assignment_pattern_property_list.rs b/crates/oxc_formatter/src/write/assignment_pattern_property_list.rs index dce32b18064dd..fd92d1eee7ca6 100644 --- a/crates/oxc_formatter/src/write/assignment_pattern_property_list.rs +++ b/crates/oxc_formatter/src/write/assignment_pattern_property_list.rs @@ -3,8 +3,8 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodeIterator}, formatter::{Buffer, Format, FormatResult, Formatter, separated::FormatSeparatedIter}, - generated::ast_nodes::{AstNode, AstNodeIterator}, options::{FormatTrailingCommas, TrailingSeparator}, write, }; diff --git a/crates/oxc_formatter/src/write/binary_like_expression.rs b/crates/oxc_formatter/src/write/binary_like_expression.rs index 47f3ba4aa00e5..4791ecb9807e9 100644 --- a/crates/oxc_formatter/src/write/binary_like_expression.rs +++ b/crates/oxc_formatter/src/write/binary_like_expression.rs @@ -10,8 +10,8 @@ use oxc_syntax::{ use crate::{ Format, + ast_nodes::{AstNode, AstNodes}, formatter::{FormatResult, Formatter, trivia::FormatTrailingComments}, - generated::ast_nodes::{AstNode, AstNodes}, parentheses::NeedsParentheses, utils::format_node_without_trailing_comments::FormatNodeWithoutTrailingComments, }; diff --git a/crates/oxc_formatter/src/write/binding_property_list.rs b/crates/oxc_formatter/src/write/binding_property_list.rs index 1502d749332e5..4e2ec23762afb 100644 --- a/crates/oxc_formatter/src/write/binding_property_list.rs +++ b/crates/oxc_formatter/src/write/binding_property_list.rs @@ -3,12 +3,12 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodeIterator}, formatter::{ Buffer, Format, FormatResult, Formatter, prelude::{format_once, soft_line_break_or_space, text}, separated::FormatSeparatedIter, }, - generated::ast_nodes::{AstNode, AstNodeIterator}, options::{FormatTrailingCommas, TrailingSeparator}, write, }; diff --git a/crates/oxc_formatter/src/write/block_statement.rs b/crates/oxc_formatter/src/write/block_statement.rs index 19559a2f0040e..67161f32c815b 100644 --- a/crates/oxc_formatter/src/write/block_statement.rs +++ b/crates/oxc_formatter/src/write/block_statement.rs @@ -4,13 +4,13 @@ use oxc_span::GetSpan; use super::FormatWrite; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Buffer, FormatResult, Formatter, prelude::*, trivia::{DanglingIndentMode, FormatDanglingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/write/call_arguments.rs b/crates/oxc_formatter/src/write/call_arguments.rs index d12fc44be3d7a..8b801bf7ac5f4 100644 --- a/crates/oxc_formatter/src/write/call_arguments.rs +++ b/crates/oxc_formatter/src/write/call_arguments.rs @@ -5,7 +5,9 @@ use oxc_ast::{ast::*, match_expression}; use oxc_span::GetSpan; use crate::{ - Buffer, Format, FormatResult, FormatTrailingCommas, TrailingSeparator, format_args, + Buffer, Format, FormatResult, FormatTrailingCommas, TrailingSeparator, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ BufferExtensions, Comments, FormatElement, FormatError, Formatter, SourceText, VecBuffer, format_element, @@ -16,7 +18,6 @@ use crate::{ separated::FormatSeparatedIter, trivia::{DanglingIndentMode, format_dangling_comments}, }, - generated::ast_nodes::{AstNode, AstNodes}, utils::{ call_expression::is_test_call_expression, is_long_curried_call, member_chain::simple_argument::SimpleArgument, diff --git a/crates/oxc_formatter/src/write/class.rs b/crates/oxc_formatter/src/write/class.rs index 1d2640bf985b9..717a1265b524c 100644 --- a/crates/oxc_formatter/src/write/class.rs +++ b/crates/oxc_formatter/src/write/class.rs @@ -5,14 +5,15 @@ use oxc_ast::{AstKind, ast::*}; use oxc_span::GetSpan; use crate::{ - Semicolons, TrailingSeparator, format_args, + Semicolons, TrailingSeparator, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Buffer, FormatResult, Formatter, prelude::*, separated::FormatSeparatedIter, trivia::{DanglingIndentMode, FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, parentheses::NeedsParentheses, utils::{ assignment_like::AssignmentLike, diff --git a/crates/oxc_formatter/src/write/decorators.rs b/crates/oxc_formatter/src/write/decorators.rs index 031536346e9ed..f33998443fe7d 100644 --- a/crates/oxc_formatter/src/write/decorators.rs +++ b/crates/oxc_formatter/src/write/decorators.rs @@ -3,13 +3,14 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ - Format, FormatResult, format_args, + Format, FormatResult, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Formatter, prelude::*, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/write/export_declarations.rs b/crates/oxc_formatter/src/write/export_declarations.rs index 0d43a7126aa6d..8116ab69a73fc 100644 --- a/crates/oxc_formatter/src/write/export_declarations.rs +++ b/crates/oxc_formatter/src/write/export_declarations.rs @@ -4,13 +4,13 @@ use oxc_span::GetSpan; use crate::{ FormatResult, FormatTrailingCommas, + ast_nodes::{AstNode, AstNodes}, formatter::{ Formatter, prelude::*, separated::FormatSeparatedIter, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, write::{ import_declaration::format_import_and_export_source_with_clause, diff --git a/crates/oxc_formatter/src/write/function.rs b/crates/oxc_formatter/src/write/function.rs index 94e02fc4a87f8..dbe5af0ae012d 100644 --- a/crates/oxc_formatter/src/write/function.rs +++ b/crates/oxc_formatter/src/write/function.rs @@ -8,6 +8,7 @@ use super::{ block_statement::is_empty_block, }; use crate::{ + ast_nodes::AstNode, format_args, formatter::{ Buffer, FormatError, FormatResult, Formatter, @@ -15,7 +16,6 @@ use crate::{ prelude::*, trivia::{DanglingIndentMode, FormatLeadingComments}, }, - generated::ast_nodes::AstNode, write, write::{ arrow_function_expression::FormatMaybeCachedFunctionBody, semicolon::OptionalSemicolon, diff --git a/crates/oxc_formatter/src/write/import_declaration.rs b/crates/oxc_formatter/src/write/import_declaration.rs index de2ebe654cf32..74f2b27a8a467 100644 --- a/crates/oxc_formatter/src/write/import_declaration.rs +++ b/crates/oxc_formatter/src/write/import_declaration.rs @@ -5,6 +5,7 @@ use oxc_syntax::identifier::is_identifier_name; use crate::{ Format, FormatResult, FormatTrailingCommas, JsLabels, QuoteProperties, TrailingSeparator, + ast_nodes::{AstNode, AstNodes}, best_fitting, format_args, formatter::{ Formatter, @@ -12,7 +13,6 @@ use crate::{ separated::FormatSeparatedIter, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, write::semicolon::OptionalSemicolon, }; diff --git a/crates/oxc_formatter/src/write/import_expression.rs b/crates/oxc_formatter/src/write/import_expression.rs index c12930818a1f7..c3891e7561f33 100644 --- a/crates/oxc_formatter/src/write/import_expression.rs +++ b/crates/oxc_formatter/src/write/import_expression.rs @@ -1,9 +1,10 @@ use oxc_ast::ast::*; use crate::{ - Format, FormatResult, TrailingSeparator, best_fitting, format_args, + Format, FormatResult, TrailingSeparator, + ast_nodes::AstNode, + best_fitting, format_args, formatter::{Formatter, prelude::*}, - generated::ast_nodes::AstNode, write, }; diff --git a/crates/oxc_formatter/src/write/intersection_type.rs b/crates/oxc_formatter/src/write/intersection_type.rs index 5de022386b6f7..bab3f6a1c4107 100644 --- a/crates/oxc_formatter/src/write/intersection_type.rs +++ b/crates/oxc_formatter/src/write/intersection_type.rs @@ -3,9 +3,9 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{FormatResult, Formatter, prelude::*}, - generated::ast_nodes::{AstNode, AstNodes}, parentheses::NeedsParentheses, utils::typescript::is_object_like_type, write, diff --git a/crates/oxc_formatter/src/write/jsx/child_list.rs b/crates/oxc_formatter/src/write/jsx/child_list.rs index 442a8c0cc3530..204d7342431e1 100644 --- a/crates/oxc_formatter/src/write/jsx/child_list.rs +++ b/crates/oxc_formatter/src/write/jsx/child_list.rs @@ -3,12 +3,13 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ - FormatResult, format_args, + FormatResult, + ast_nodes::AstNode, + format_args, formatter::{ Comments, FormatContext, FormatElement, Formatter, VecBuffer, prelude::{tag::GroupMode, *}, }, - generated::ast_nodes::AstNode, utils::{ jsx::{ JsxChild, JsxChildrenIterator, JsxRawSpace, JsxSpace, is_meaningful_jsx_text, diff --git a/crates/oxc_formatter/src/write/jsx/element.rs b/crates/oxc_formatter/src/write/jsx/element.rs index 009834a8868d1..e1870d46f7a0f 100644 --- a/crates/oxc_formatter/src/write/jsx/element.rs +++ b/crates/oxc_formatter/src/write/jsx/element.rs @@ -5,9 +5,10 @@ use oxc_ast::ast::{ use oxc_span::{GetSpan, Span}; use crate::{ - FormatResult, best_fitting, format_args, + FormatResult, + ast_nodes::{AstNode, AstNodes}, + best_fitting, format_args, formatter::{Formatter, prelude::*, trivia::FormatTrailingComments}, - generated::ast_nodes::{AstNode, AstNodes}, parentheses::NeedsParentheses, utils::{ jsx::{WrapState, get_wrap_state, is_meaningful_jsx_text}, diff --git a/crates/oxc_formatter/src/write/jsx/mod.rs b/crates/oxc_formatter/src/write/jsx/mod.rs index eb80d9fe8136c..7c25eadfb6cdc 100644 --- a/crates/oxc_formatter/src/write/jsx/mod.rs +++ b/crates/oxc_formatter/src/write/jsx/mod.rs @@ -11,13 +11,14 @@ use opening_element::{FormatOpeningElement, OpeningElementLayout}; use oxc_span::GetSpan; use crate::{ - AttributePosition, Format, FormatResult, format_args, + AttributePosition, Format, FormatResult, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Comments, Formatter, prelude::*, trivia::{DanglingIndentMode, FormatDanglingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/write/jsx/opening_element.rs b/crates/oxc_formatter/src/write/jsx/opening_element.rs index cb58bbac472b9..cf295c59a4e3d 100644 --- a/crates/oxc_formatter/src/write/jsx/opening_element.rs +++ b/crates/oxc_formatter/src/write/jsx/opening_element.rs @@ -7,8 +7,8 @@ use oxc_span::GetSpan; use crate::{ AttributePosition, FormatResult, + ast_nodes::AstNode, formatter::{Formatter, prelude::*, trivia::FormatTrailingComments}, - generated::ast_nodes::AstNode, write, }; diff --git a/crates/oxc_formatter/src/write/mapped_type.rs b/crates/oxc_formatter/src/write/mapped_type.rs index 4afe685004649..295aea1a98b23 100644 --- a/crates/oxc_formatter/src/write/mapped_type.rs +++ b/crates/oxc_formatter/src/write/mapped_type.rs @@ -2,8 +2,8 @@ use oxc_ast::ast::{TSMappedType, TSMappedTypeModifierOperator}; use crate::{ FormatResult, + ast_nodes::AstNode, formatter::{Formatter, SourceText, prelude::*, trivia::FormatLeadingComments}, - generated::ast_nodes::AstNode, write, write::semicolon::OptionalSemicolon, }; diff --git a/crates/oxc_formatter/src/write/member_expression.rs b/crates/oxc_formatter/src/write/member_expression.rs index 75888902f6d92..9d8d59958e473 100644 --- a/crates/oxc_formatter/src/write/member_expression.rs +++ b/crates/oxc_formatter/src/write/member_expression.rs @@ -4,7 +4,9 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ - JsLabels, format_args, + JsLabels, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Buffer, Format, FormatResult, Formatter, buffer::RemoveSoftLinesBuffer, @@ -14,7 +16,6 @@ use crate::{ FormatTrailingComments, format_dangling_comments, }, }, - generated::ast_nodes::{AstNode, AstNodes}, options::Expand, utils::member_chain::chain_member::FormatComputedMemberExpressionWithoutObject, write, diff --git a/crates/oxc_formatter/src/write/mod.rs b/crates/oxc_formatter/src/write/mod.rs index fe9f7b3a81307..25d290120a964 100644 --- a/crates/oxc_formatter/src/write/mod.rs +++ b/crates/oxc_formatter/src/write/mod.rs @@ -48,7 +48,9 @@ use oxc_ast::{AstKind, ast::*}; use oxc_span::GetSpan; use crate::{ - Expand, best_fitting, format_args, + Expand, + ast_nodes::{AstNode, AstNodes}, + best_fitting, format_args, formatter::{ Buffer, Format, FormatResult, Formatter, prelude::*, @@ -59,7 +61,6 @@ use crate::{ FormatTrailingComments, }, }, - generated::ast_nodes::{AstNode, AstNodes}, options::{FormatTrailingCommas, QuoteProperties, Semicolons, TrailingSeparator}, parentheses::NeedsParentheses, utils::{ diff --git a/crates/oxc_formatter/src/write/object_like.rs b/crates/oxc_formatter/src/write/object_like.rs index 42ea1833520ee..c77b1e563aa64 100644 --- a/crates/oxc_formatter/src/write/object_like.rs +++ b/crates/oxc_formatter/src/write/object_like.rs @@ -2,12 +2,12 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, formatter::{ Buffer, Format, FormatResult, Formatter, prelude::{format_with, group, soft_block_indent_with_maybe_space}, trivia::format_dangling_comments, }, - generated::ast_nodes::{AstNode, AstNodes}, options::Expand, write, write::parameters::{get_this_param, should_hug_function_parameters}, diff --git a/crates/oxc_formatter/src/write/object_pattern_like.rs b/crates/oxc_formatter/src/write/object_pattern_like.rs index 43d756cff1d85..100d32ff73286 100644 --- a/crates/oxc_formatter/src/write/object_pattern_like.rs +++ b/crates/oxc_formatter/src/write/object_pattern_like.rs @@ -2,12 +2,12 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, formatter::{ Buffer, Comments, Format, FormatResult, Formatter, prelude::{format_with, group, soft_block_indent_with_maybe_space}, trivia::{DanglingIndentMode, format_dangling_comments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/write/parameters.rs b/crates/oxc_formatter/src/write/parameters.rs index f6851ec4ffb11..94603ba863b00 100644 --- a/crates/oxc_formatter/src/write/parameters.rs +++ b/crates/oxc_formatter/src/write/parameters.rs @@ -2,12 +2,12 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodeIterator, AstNodes}, format_args, formatter::{ Format, FormatResult, Formatter, prelude::*, separated::FormatSeparatedIter, trivia::FormatTrailingComments, }, - generated::ast_nodes::{AstNode, AstNodeIterator, AstNodes}, options::{FormatTrailingCommas, TrailingSeparator}, utils::call_expression::is_test_call_expression, write, diff --git a/crates/oxc_formatter/src/write/program.rs b/crates/oxc_formatter/src/write/program.rs index 8086f10423099..7afb01b72d348 100644 --- a/crates/oxc_formatter/src/write/program.rs +++ b/crates/oxc_formatter/src/write/program.rs @@ -6,9 +6,10 @@ use oxc_span::GetSpan; use oxc_syntax::identifier::{ZWNBSP, is_line_terminator}; use crate::{ - Buffer, Format, FormatResult, FormatTrailingCommas, TrailingSeparator, format_args, + Buffer, Format, FormatResult, FormatTrailingCommas, TrailingSeparator, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{prelude::*, trivia::FormatTrailingComments}, - generated::ast_nodes::{AstNode, AstNodes}, utils::{ call_expression::is_test_call_expression, is_long_curried_call, diff --git a/crates/oxc_formatter/src/write/return_or_throw_statement.rs b/crates/oxc_formatter/src/write/return_or_throw_statement.rs index 3a522f8d35eb2..240a25a8e3175 100644 --- a/crates/oxc_formatter/src/write/return_or_throw_statement.rs +++ b/crates/oxc_formatter/src/write/return_or_throw_statement.rs @@ -3,9 +3,10 @@ use oxc_span::GetSpan; use oxc_syntax::identifier::is_line_terminator; use crate::{ - Format, FormatResult, format_args, + Format, FormatResult, + ast_nodes::AstNode, + format_args, formatter::{Formatter, comments::Comments, prelude::*}, - generated::ast_nodes::AstNode, write, write::{ExpressionLeftSide, semicolon::OptionalSemicolon}, }; diff --git a/crates/oxc_formatter/src/write/semicolon.rs b/crates/oxc_formatter/src/write/semicolon.rs index 3592b94260acc..e2d9b6e16d3a3 100644 --- a/crates/oxc_formatter/src/write/semicolon.rs +++ b/crates/oxc_formatter/src/write/semicolon.rs @@ -1,8 +1,8 @@ use oxc_ast::ast::*; use crate::{ + ast_nodes::AstNode, formatter::{Buffer, Format, FormatResult, Formatter}, - generated::ast_nodes::AstNode, options::Semicolons, write, }; diff --git a/crates/oxc_formatter/src/write/sequence_expression.rs b/crates/oxc_formatter/src/write/sequence_expression.rs index 2b0e5206018d3..8ceb7342d00f3 100644 --- a/crates/oxc_formatter/src/write/sequence_expression.rs +++ b/crates/oxc_formatter/src/write/sequence_expression.rs @@ -2,8 +2,8 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodeIterator, AstNodes}, formatter::{Format, FormatResult, Formatter, prelude::*, separated::FormatSeparatedIter}, - generated::ast_nodes::{AstNode, AstNodeIterator, AstNodes}, write, }; diff --git a/crates/oxc_formatter/src/write/switch_statement.rs b/crates/oxc_formatter/src/write/switch_statement.rs index 895a88c7dc53d..f413d1c1b48f8 100644 --- a/crates/oxc_formatter/src/write/switch_statement.rs +++ b/crates/oxc_formatter/src/write/switch_statement.rs @@ -4,13 +4,14 @@ use oxc_span::GetSpan; use oxc_syntax::identifier::is_identifier_name; use crate::{ - Format, FormatResult, format_args, + Format, FormatResult, + ast_nodes::{AstNode, AstNodes}, + format_args, formatter::{ Formatter, prelude::*, trivia::{DanglingIndentMode, FormatDanglingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, write, write::{semicolon::OptionalSemicolon, utils::statement_body::FormatStatementBody}, }; diff --git a/crates/oxc_formatter/src/write/template.rs b/crates/oxc_formatter/src/write/template.rs index 14677cf5cb77e..5f9a9f913126d 100644 --- a/crates/oxc_formatter/src/write/template.rs +++ b/crates/oxc_formatter/src/write/template.rs @@ -8,7 +8,9 @@ use oxc_span::{GetSpan, Span}; use oxc_syntax::identifier::is_line_terminator; use crate::{ - IndentWidth, format, format_args, + IndentWidth, + ast_nodes::{AstNode, AstNodeIterator}, + format, format_args, formatter::{ Format, FormatElement, FormatResult, Formatter, VecBuffer, buffer::RemoveSoftLinesBuffer, @@ -16,7 +18,6 @@ use crate::{ printer::Printer, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodeIterator}, utils::{ call_expression::is_test_each_pattern, format_node_without_trailing_comments::FormatNodeWithoutTrailingComments, diff --git a/crates/oxc_formatter/src/write/try_statement.rs b/crates/oxc_formatter/src/write/try_statement.rs index d693ce646fbf9..308b406551792 100644 --- a/crates/oxc_formatter/src/write/try_statement.rs +++ b/crates/oxc_formatter/src/write/try_statement.rs @@ -5,6 +5,7 @@ use oxc_syntax::identifier::is_identifier_name; use crate::{ Format, FormatResult, FormatTrailingCommas, QuoteProperties, TrailingSeparator, + ast_nodes::{AstNode, AstNodes}, formatter::{ Formatter, prelude::*, @@ -14,7 +15,6 @@ use crate::{ FormatTrailingComments, }, }, - generated::ast_nodes::{AstNode, AstNodes}, write, write::semicolon::OptionalSemicolon, }; diff --git a/crates/oxc_formatter/src/write/tuple_type.rs b/crates/oxc_formatter/src/write/tuple_type.rs index 604caaa280847..2a6ea31d2ff73 100644 --- a/crates/oxc_formatter/src/write/tuple_type.rs +++ b/crates/oxc_formatter/src/write/tuple_type.rs @@ -3,8 +3,8 @@ use oxc_ast::ast::*; use crate::{ Expand, Format, FormatResult, FormatTrailingCommas, + ast_nodes::AstNode, formatter::{Formatter, prelude::*, trivia::format_dangling_comments}, - generated::ast_nodes::AstNode, write, }; diff --git a/crates/oxc_formatter/src/write/type_parameters.rs b/crates/oxc_formatter/src/write/type_parameters.rs index c950b619aa5a1..f49d4cd410728 100644 --- a/crates/oxc_formatter/src/write/type_parameters.rs +++ b/crates/oxc_formatter/src/write/type_parameters.rs @@ -4,6 +4,7 @@ use oxc_allocator::{Address, Vec}; use oxc_ast::{AstKind, ast::*}; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Buffer, Format, FormatError, FormatResult, Formatter, GroupId, @@ -11,7 +12,6 @@ use crate::{ separated::FormatSeparatedIter, trivia::{DanglingIndentMode, FormatDanglingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, options::{FormatTrailingCommas, TrailingSeparator}, utils::{ call_expression::is_test_call_expression, diff --git a/crates/oxc_formatter/src/write/union_type.rs b/crates/oxc_formatter/src/write/union_type.rs index f93847cb3c64c..c193a3a4ff23d 100644 --- a/crates/oxc_formatter/src/write/union_type.rs +++ b/crates/oxc_formatter/src/write/union_type.rs @@ -3,13 +3,13 @@ use oxc_ast::ast::*; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ FormatResult, Formatter, prelude::*, trivia::{FormatLeadingComments, FormatTrailingComments}, }, - generated::ast_nodes::{AstNode, AstNodes}, parentheses::NeedsParentheses, utils::typescript::should_hug_type, write, diff --git a/crates/oxc_formatter/src/write/utils/array.rs b/crates/oxc_formatter/src/write/utils/array.rs index a275666a635a0..c77df638e93e9 100644 --- a/crates/oxc_formatter/src/write/utils/array.rs +++ b/crates/oxc_formatter/src/write/utils/array.rs @@ -3,8 +3,8 @@ use oxc_ast::ast::*; use oxc_span::{GetSpan, SPAN, Span}; use crate::{ + ast_nodes::AstNode, formatter::{FormatResult, Formatter, prelude::*}, - generated::ast_nodes::AstNode, options::FormatTrailingCommas, write, }; diff --git a/crates/oxc_formatter/src/write/utils/statement_body.rs b/crates/oxc_formatter/src/write/utils/statement_body.rs index 4306060bb5dc6..f9967ac10a828 100644 --- a/crates/oxc_formatter/src/write/utils/statement_body.rs +++ b/crates/oxc_formatter/src/write/utils/statement_body.rs @@ -2,6 +2,7 @@ use oxc_ast::ast::Statement; use oxc_span::GetSpan; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Buffer, Format, FormatResult, Formatter, @@ -10,7 +11,6 @@ use crate::{ }, trivia::FormatTrailingComments, }, - generated::ast_nodes::{AstNode, AstNodes}, utils::format_node_without_trailing_comments::FormatNodeWithoutTrailingComments, write, write::FormatWrite, diff --git a/crates/oxc_formatter/src/write/variable_declaration.rs b/crates/oxc_formatter/src/write/variable_declaration.rs index eda32f6ba9036..4dd14d65a2372 100644 --- a/crates/oxc_formatter/src/write/variable_declaration.rs +++ b/crates/oxc_formatter/src/write/variable_declaration.rs @@ -6,12 +6,12 @@ use crate::utils::assignment_like::AssignmentLike; use crate::write::semicolon::MaybeOptionalSemicolon; use crate::write::{OptionalSemicolon, semicolon}; use crate::{ + ast_nodes::{AstNode, AstNodes}, format_args, formatter::{ Buffer, Format, FormatError, FormatResult, Formatter, prelude::*, separated::FormatSeparatedIter, }, - generated::ast_nodes::{AstNode, AstNodes}, options::TrailingSeparator, write, }; diff --git a/tasks/ast_tools/src/generators/formatter/ast_nodes.rs b/tasks/ast_tools/src/generators/formatter/ast_nodes.rs index 62b312eab5ab9..7336f7cad0f94 100644 --- a/tasks/ast_tools/src/generators/formatter/ast_nodes.rs +++ b/tasks/ast_tools/src/generators/formatter/ast_nodes.rs @@ -1,23 +1,26 @@ //! Generator for `oxc_formatter`. //! Generates the `AstNodes` and `AstNode` types. -use itertools::Itertools; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use crate::{ Codegen, Generator, generators::define_generator, - output::{Output, output_path}, + output::Output, schema::{Def, EnumDef, FieldDef, Schema, StructDef, TypeDef, TypeId}, }; +const FORMATTER_CRATE_PATH: &str = "crates/oxc_formatter"; + +pub fn formatter_output_path(file_name: &str) -> String { + format!("{FORMATTER_CRATE_PATH}/src/ast_nodes/generated/{file_name}.rs") +} + pub fn get_node_type(ty: &TokenStream) -> TokenStream { quote! { AstNode<'a, #ty> } } -const FORMATTER_CRATE_PATH: &str = "crates/oxc_formatter"; - /// Based on the printing comments algorithm, the last child of these AST nodes don't need to print comments. /// Without following nodes could lead to only print comments that before the end of the node, which is what we want. const AST_NODE_WITHOUT_FOLLOWING_NODE_LIST: &[&str] = &[ @@ -105,12 +108,7 @@ impl Generator for FormatterAstNodesGenerator { } }; - let ast_node_ast_nodes_impls = ast_node_and_ast_nodes_impls(); - let ast_node_iterator_impls = ast_node_iterator_impls(schema); - let output = quote! { - #![expect(clippy::elidable_lifetime_names)] - use std::{mem::transmute, ops::Deref, fmt}; ///@@line_break use oxc_ast::ast::*; @@ -127,6 +125,8 @@ impl Generator for FormatterAstNodesGenerator { write::FormatWrite, }; + use crate::ast_nodes::AstNode; + ///@@line_break #transmute_self @@ -162,29 +162,10 @@ impl Generator for FormatterAstNodesGenerator { } } - ///@@line_break - pub struct AstNode<'a, T> { - pub(super) inner: &'a T, - pub parent: &'a AstNodes<'a>, - pub(super) allocator: &'a Allocator, - pub(super) following_span: Option, - } - - - impl GetSpan for &AstNode<'_, T> { - fn span(&self) -> Span { - self.inner.span() - } - } - - #ast_node_ast_nodes_impls - #impls - - #ast_node_iterator_impls }; - Output::Rust { path: output_path(FORMATTER_CRATE_PATH, "ast_nodes.rs"), tokens: output } + Output::Rust { path: formatter_output_path("ast_nodes"), tokens: output } } } @@ -229,7 +210,6 @@ fn generate_struct_impls( let fields = &struct_def.fields; let methods = fields.iter().enumerate().filter_map(|(index, field)| { if field.name == "span" { - // Instead of generating a method for `span`, we implement the `GetSpan` trait for it. return None; } @@ -397,14 +377,6 @@ fn generate_struct_impls( .fmt(f) } } - - ///@@line_break - impl<'a> GetSpan for AstNode<'a, #type_ty> { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } - } } } @@ -547,7 +519,7 @@ fn generate_enum_impls(enum_def: &EnumDef, schema: &Schema) -> TokenStream { let node_type = get_node_type(&type_ty); - let as_ast_nodes_fn = quote! { + quote! { ///@@line_break impl<'a> #node_type { #[inline] @@ -560,21 +532,6 @@ fn generate_enum_impls(enum_def: &EnumDef, schema: &Schema) -> TokenStream { self.allocator.alloc(node) } } - }; - - let impl_get_span = quote! { - ///@@line_break - impl<'a> GetSpan for #node_type { - #[inline] - fn span(&self) -> oxc_span::Span { - self.inner.span() - } - } - }; - - quote! { - #as_ast_nodes_fn - #impl_get_span } } @@ -590,196 +547,3 @@ fn has_kind(type_def: &TypeDef, schema: &Schema) -> bool { fn is_copyable(devices: &[String]) -> bool { devices.contains(&"Copy".to_string()) } - -fn ast_node_and_ast_nodes_impls() -> TokenStream { - quote! { - ///@@line_break - impl<'a, T: fmt::Debug> fmt::Debug for AstNode<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("AstNode") - .field("inner", &self.inner) - .field("parent", &self.parent.debug_name()) - .finish_non_exhaustive() - } - } - - ///@@line_break - impl<'a, T> Deref for AstNode<'a, T> { - type Target = T; - - fn deref(&self) -> &'a Self::Target { - self.inner - } - } - - ///@@line_break - impl<'a, T> AsRef for AstNode<'a, T> { - fn as_ref(&self) -> &'a T { - self.inner - } - } - - ///@@line_break - impl<'a> AstNode<'a, Program<'a>> { - pub fn new(inner: &'a Program<'a>, parent: &'a AstNodes<'a>, allocator: &'a Allocator) -> Self { - AstNode { inner, parent, allocator, following_span: None } - } - } - - ///@@line_break - impl<'a, T> AstNode<'a, Option> { - pub fn as_ref(&self) -> Option<&'a AstNode<'a, T>> { - self.allocator - .alloc(self.inner.as_ref().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: self.following_span, - })) - .as_ref() - } - } - } -} - -fn ast_node_iterator_impls(schema: &Schema) -> TokenStream { - let types_used_in_vec = schema - .types - .iter() - .filter_map(|type_def| { - if let TypeDef::Struct(struct_def) = type_def { - if !struct_def.visit.has_visitor() { - return None; - } - Some(struct_def.fields.iter().filter_map(|field| { - let mut field_type = field.type_def(schema); - if field_type.is_option() { - field_type = field_type.as_option().unwrap().inner_type(schema); - } - if let TypeDef::Vec(vec_def) = field_type { - let inner_type_def = vec_def - .maybe_inner_type(schema) - .unwrap_or_else(|| vec_def.inner_type(schema)); - - match inner_type_def { - TypeDef::Struct(inner_struct_def) - if !inner_struct_def.visit.has_visitor() => - { - None - } - TypeDef::Enum(inner_enum_def) - if !inner_enum_def.visit.has_visitor() => - { - None - } - _ => Some(inner_type_def.id()), - } - } else { - None - } - })) - } else { - None - } - }) - .flatten() - .sorted_unstable() - .dedup(); - - let impls = types_used_in_vec.map(|type_id| { - let type_def = &schema.types[type_id]; - - let next_to_following_node = if type_def.is_option() { - quote! { .map(|next| next.as_ref().map(GetSpan::span)).unwrap_or_default() } - } else { - quote! { .map(GetSpan::span) } - }; - - let type_ty = type_def.ty(schema); - quote! { - ///@@line_break - impl<'a> AstNode<'a, Vec<'a, #type_ty>> { - pub fn iter(&self) -> AstNodeIterator<'a, #type_ty> { - AstNodeIterator { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator - } - } - - ///@@line_break - pub fn first(&self) -> Option<&'a AstNode<'a, #type_ty>> { - let mut inner_iter = self.inner.iter(); - self.allocator - .alloc(inner_iter.next().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: inner_iter - .next() - #next_to_following_node, - })) - .as_ref() - } - - ///@@line_break - pub fn last(&self) -> Option<&'a AstNode<'a, #type_ty>> { - self.allocator - .alloc(self.inner.last().map(|inner| AstNode { - inner, - parent: self.parent, - allocator: self.allocator, - following_span: None, - })) - .as_ref() - } - } - - ///@@line_break - impl<'a> Iterator for AstNodeIterator<'a, #type_ty> { - type Item = &'a AstNode<'a, #type_ty>; - fn next(&mut self) -> Option { - let allocator = self.allocator; - allocator - .alloc(self.inner.next().map(|inner| { - let following_span = self.inner.peek() - .copied() - #next_to_following_node; - AstNode { - parent: self.parent, - inner, - allocator, - following_span, - } - })) - .as_ref() - } - } - - ///@@line_break - impl<'a> IntoIterator for &AstNode<'a, Vec<'a, #type_ty>> - { - type Item = &'a AstNode<'a, #type_ty>; - type IntoIter = AstNodeIterator<'a, #type_ty>; - fn into_iter(self) -> Self::IntoIter { - AstNodeIterator::<#type_ty> { - inner: self.inner.iter().peekable(), - parent: self.parent, - allocator: self.allocator, - } - } - } - } - }); - - quote! { - ///@@line_break - pub struct AstNodeIterator<'a, T> { - inner: std::iter::Peekable>, - parent: &'a AstNodes<'a>, - allocator: &'a Allocator, - } - - #(#impls)* - } -} diff --git a/tasks/ast_tools/src/generators/formatter/format.rs b/tasks/ast_tools/src/generators/formatter/format.rs index 88374b2e91c72..8dacf7fccbf18 100644 --- a/tasks/ast_tools/src/generators/formatter/format.rs +++ b/tasks/ast_tools/src/generators/formatter/format.rs @@ -7,11 +7,11 @@ use quote::{format_ident, quote}; use crate::{ Codegen, Generator, generators::{define_generator, formatter::ast_nodes::get_node_type}, - output::{Output, output_path}, + output::Output, schema::{Def, EnumDef, Schema, StructDef, TypeDef, TypeId}, }; -const FORMATTER_CRATE_PATH: &str = "crates/oxc_formatter"; +use super::ast_nodes::formatter_output_path; /// Based on the prettier printing comments algorithm, these nodes don't need to print comments. const AST_NODE_WITHOUT_PRINTING_COMMENTS_LIST: &[&str] = &[ @@ -90,15 +90,17 @@ impl Generator for FormatterFormatGenerator { trivia::FormatTrailingComments, }, parentheses::NeedsParentheses, - generated::ast_nodes::{AstNode, AstNodes, transmute_self}, + ast_nodes::{AstNode, AstNodes}, utils::{suppressed::FormatSuppressedNode, typecast::format_type_cast_comment_node}, write::{FormatWrite #(#options)*}, }; + use super::ast_nodes::transmute_self; + #impls }; - Output::Rust { path: output_path(FORMATTER_CRATE_PATH, "format.rs"), tokens: output } + Output::Rust { path: formatter_output_path("format"), tokens: output } } }