From edc5eae1197dfd80b3fd09743bbb67262ddcbba1 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:01:56 +0100 Subject: [PATCH 1/7] Add `#[visited_node]` attr to AST types which are visited --- Cargo.lock | 5 ++ Cargo.toml | 1 + crates/oxc_ast/Cargo.toml | 7 +- crates/oxc_ast/src/ast/js.rs | 121 ++++++++++++++++++++++++++++++ crates/oxc_ast/src/ast/jsx.rs | 24 ++++++ crates/oxc_ast/src/ast/literal.rs | 10 +++ crates/oxc_ast/src/ast/ts.rs | 85 +++++++++++++++++++++ crates/oxc_ast_macros/Cargo.toml | 20 +++++ crates/oxc_ast_macros/src/lib.rs | 8 ++ 9 files changed, 278 insertions(+), 3 deletions(-) create mode 100644 crates/oxc_ast_macros/Cargo.toml create mode 100644 crates/oxc_ast_macros/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 47ac48babdcfd..1e9e3b1682303 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1249,6 +1249,7 @@ dependencies = [ "bitflags 2.5.0", "num-bigint", "oxc_allocator", + "oxc_ast_macros", "oxc_span", "oxc_syntax", "serde", @@ -1258,6 +1259,10 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "oxc_ast_macros" +version = "0.0.0" + [[package]] name = "oxc_benchmark" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index b1d4288d73272..42aaf198c8ae0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,7 @@ oxc_transformer = { version = "0.12.5", path = "crates/oxc_transformer" } oxc_sourcemap = { version = "0.12.5", path = "crates/oxc_sourcemap" } # publish = false +oxc_ast_macros = { path = "crates/oxc_ast_macros" } oxc_macros = { path = "crates/oxc_macros" } oxc_linter = { path = "crates/oxc_linter" } oxc_prettier = { path = "crates/oxc_prettier" } diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 5390d97296377..088784024405a 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -18,9 +18,10 @@ workspace = true doctest = false [dependencies] -oxc_allocator = { workspace = true } -oxc_span = { workspace = true } -oxc_syntax = { workspace = true } +oxc_allocator = { workspace = true } +oxc_ast_macros = { workspace = true } +oxc_span = { workspace = true } +oxc_syntax = { workspace = true } bitflags = { workspace = true } num-bigint = { workspace = true } diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 2a6c0167a0739..3172ef702d85c 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1,9 +1,13 @@ +// NB: `#[visited_node]` attribute on AST nodes does not do anything to the code in this file. +// It is purely a marker for codegen used in `oxc_traverse`. See docs in that crate. + // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] use std::{cell::Cell, fmt, hash::Hash}; use oxc_allocator::{Box, Vec}; +use oxc_ast_macros::visited_node; use oxc_span::{Atom, CompactStr, SourceType, Span}; use oxc_syntax::{ operator::{ @@ -37,6 +41,7 @@ export interface FormalParameterRest extends Span { } "#; +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -65,6 +70,7 @@ inherit_variants! { /// Expression /// /// Inherits variants from [`MemberExpression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -389,6 +395,7 @@ impl<'a> Expression<'a> { } /// Identifier Name +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "Identifier"))] @@ -405,6 +412,7 @@ impl<'a> IdentifierName<'a> { } /// Identifier Reference +#[visited_node] #[derive(Debug, Clone)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "Identifier"))] @@ -432,6 +440,7 @@ impl<'a> IdentifierReference<'a> { } /// Binding Identifier +#[visited_node] #[derive(Debug, Clone)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "Identifier"))] @@ -457,6 +466,7 @@ impl<'a> BindingIdentifier<'a> { } /// Label Identifier +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "Identifier"))] @@ -467,6 +477,7 @@ pub struct LabelIdentifier<'a> { } /// This Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -476,6 +487,7 @@ pub struct ThisExpression { } /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -494,6 +506,7 @@ inherit_variants! { /// Array Expression Element /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] @@ -516,12 +529,14 @@ impl<'a> ArrayExpressionElement<'a> { /// Array Expression Elision Element /// Serialized as `null` in JSON AST. See `serialize.rs`. +#[visited_node] #[derive(Debug, Clone, Hash)] pub struct Elision { pub span: Span, } /// Object Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -540,6 +555,7 @@ impl<'a> ObjectExpression<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -548,6 +564,7 @@ pub enum ObjectPropertyKind<'a> { SpreadProperty(Box<'a, SpreadElement<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -567,6 +584,7 @@ inherit_variants! { /// Property Key /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -646,6 +664,7 @@ pub enum PropertyKind { /// Template Literal /// /// This is interpreted by interleaving the expression elements in between the quasi elements. +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -667,6 +686,7 @@ impl<'a> TemplateLiteral<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -678,6 +698,7 @@ pub struct TaggedTemplateExpression<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -704,6 +725,7 @@ pub struct TemplateElementValue<'a> { } /// +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -812,6 +834,7 @@ impl<'a> MemberExpression<'a> { } /// `MemberExpression[?Yield, ?Await] [ Expression[+In, ?Yield, ?Await] ]` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -824,6 +847,7 @@ pub struct ComputedMemberExpression<'a> { } /// `MemberExpression[?Yield, ?Await] . IdentifierName` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -836,6 +860,7 @@ pub struct StaticMemberExpression<'a> { } /// `MemberExpression[?Yield, ?Await] . PrivateIdentifier` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -848,6 +873,7 @@ pub struct PrivateFieldExpression<'a> { } /// Call Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -909,6 +935,7 @@ impl<'a> CallExpression<'a> { } /// New Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -921,6 +948,7 @@ pub struct NewExpression<'a> { } /// Meta Property `new.target` | `import.meta` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -932,6 +960,7 @@ pub struct MetaProperty<'a> { } /// Spread Element +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -945,6 +974,7 @@ inherit_variants! { /// Argument /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -963,6 +993,7 @@ impl Argument<'_> { } /// Update Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -975,6 +1006,7 @@ pub struct UpdateExpression<'a> { } /// Unary Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -986,6 +1018,7 @@ pub struct UnaryExpression<'a> { } /// Binary Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -998,6 +1031,7 @@ pub struct BinaryExpression<'a> { } /// Private Identifier in Shift Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1010,6 +1044,7 @@ pub struct PrivateInExpression<'a> { } /// Binary Logical Operators +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1022,6 +1057,7 @@ pub struct LogicalExpression<'a> { } /// Conditional Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1034,6 +1070,7 @@ pub struct ConditionalExpression<'a> { } /// Assignment Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1049,6 +1086,7 @@ inherit_variants! { /// Destructuring Assignment /// /// Inherits variants from [`SimpleAssignmentTarget`] and [`AssignmentTargetPattern`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1084,6 +1122,7 @@ inherit_variants! { /// Simple Assignment Target /// /// Inherits variants from [`MemberExpression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1128,6 +1167,7 @@ impl<'a> SimpleAssignmentTarget<'a> { } } +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1147,6 +1187,7 @@ macro_rules! match_assignment_target_pattern { pub use match_assignment_target_pattern; // See serializer in serialize.rs +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1174,6 +1215,7 @@ impl<'a> ArrayAssignmentTarget<'a> { } // See serializer in serialize.rs +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1206,6 +1248,7 @@ impl<'a> ObjectAssignmentTarget<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "RestElement"))] @@ -1220,6 +1263,7 @@ inherit_variants! { /// Assignment Target Maybe Default /// /// Inherits variants from [`AssignmentTarget`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1247,6 +1291,7 @@ impl<'a> AssignmentTargetMaybeDefault<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1257,6 +1302,7 @@ pub struct AssignmentTargetWithDefault<'a> { pub init: Expression<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -1266,6 +1312,7 @@ pub enum AssignmentTargetProperty<'a> { } /// Assignment Property - Identifier Reference +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1277,6 +1324,7 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { } /// Assignment Property - Property Name +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1288,6 +1336,7 @@ pub struct AssignmentTargetPropertyProperty<'a> { } /// Sequence Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1297,6 +1346,7 @@ pub struct SequenceExpression<'a> { pub expressions: Vec<'a, Expression<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1306,6 +1356,7 @@ pub struct Super { } /// Await Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1315,6 +1366,7 @@ pub struct AwaitExpression<'a> { pub argument: Expression<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1328,6 +1380,7 @@ inherit_variants! { /// Chain Element /// /// Inherits variants from [`MemberExpression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1340,6 +1393,7 @@ pub enum ChainElement<'a> { } /// Parenthesized Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1353,6 +1407,7 @@ inherit_variants! { /// Statement /// /// Inherits variants from [`Declaration`] and [`ModuleDeclaration`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1398,6 +1453,7 @@ impl<'a> Statement<'a> { } /// Directive Prologue +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1412,6 +1468,7 @@ pub struct Directive<'a> { } /// Hashbang +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1422,6 +1479,7 @@ pub struct Hashbang<'a> { } /// Block Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1432,6 +1490,7 @@ pub struct BlockStatement<'a> { } /// Declarations and the Variable Statement +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1503,6 +1562,7 @@ impl<'a> Declaration<'a> { } /// Variable Declaration +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1559,6 +1619,7 @@ impl fmt::Display for VariableDeclarationKind { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1574,6 +1635,7 @@ pub struct VariableDeclarator<'a> { /// Using Declaration /// * +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1586,6 +1648,7 @@ pub struct UsingDeclaration<'a> { } /// Empty Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1595,6 +1658,7 @@ pub struct EmptyStatement { } /// Expression Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1605,6 +1669,7 @@ pub struct ExpressionStatement<'a> { } /// If Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1617,6 +1682,7 @@ pub struct IfStatement<'a> { } /// Do-While Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1628,6 +1694,7 @@ pub struct DoWhileStatement<'a> { } /// While Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1639,6 +1706,7 @@ pub struct WhileStatement<'a> { } /// For Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1655,6 +1723,7 @@ inherit_variants! { /// For Statement Init /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1676,6 +1745,7 @@ impl<'a> ForStatementInit<'a> { } /// For-In Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1688,6 +1758,7 @@ pub struct ForInStatement<'a> { } /// For-Of Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1704,6 +1775,7 @@ inherit_variants! { /// For Statement Left /// /// Inherits variants from [`AssignmentTarget`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1725,6 +1797,7 @@ impl<'a> ForStatementLeft<'a> { } /// Continue Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1735,6 +1808,7 @@ pub struct ContinueStatement<'a> { } /// Break Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1745,6 +1819,7 @@ pub struct BreakStatement<'a> { } /// Return Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1755,6 +1830,7 @@ pub struct ReturnStatement<'a> { } /// With Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1766,6 +1842,7 @@ pub struct WithStatement<'a> { } /// Switch Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1776,6 +1853,7 @@ pub struct SwitchStatement<'a> { pub cases: Vec<'a, SwitchCase<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1793,6 +1871,7 @@ impl<'a> SwitchCase<'a> { } /// Labelled Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1804,6 +1883,7 @@ pub struct LabeledStatement<'a> { } /// Throw Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1814,6 +1894,7 @@ pub struct ThrowStatement<'a> { } /// Try Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1825,6 +1906,7 @@ pub struct TryStatement<'a> { pub finalizer: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1835,6 +1917,7 @@ pub struct CatchClause<'a> { pub body: Box<'a, BlockStatement<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1845,6 +1928,7 @@ pub struct CatchParameter<'a> { } /// Debugger Statement +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1855,6 +1939,7 @@ pub struct DebuggerStatement { /// Destructuring Binding Patterns /// * +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] @@ -1880,6 +1965,7 @@ impl<'a> BindingPattern<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -1919,6 +2005,7 @@ impl<'a> BindingPatternKind<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1930,6 +2017,7 @@ pub struct AssignmentPattern<'a> { } // See serializer in serialize.rs +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1952,6 +2040,7 @@ impl<'a> ObjectPattern<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1965,6 +2054,7 @@ pub struct BindingProperty<'a> { } // See serializer in serialize.rs +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -1990,6 +2080,7 @@ impl<'a> ArrayPattern<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename = "RestElement"))] @@ -2000,6 +2091,7 @@ pub struct BindingRestElement<'a> { } /// Function Definitions +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] @@ -2078,6 +2170,7 @@ pub enum FunctionType { /// // See serializer in serialize.rs +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2100,6 +2193,7 @@ impl<'a> FormalParameters<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2145,6 +2239,7 @@ impl<'a> FormalParameters<'a> { } /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2162,6 +2257,7 @@ impl<'a> FunctionBody<'a> { } /// Arrow Function Definitions +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2192,6 +2288,7 @@ impl<'a> ArrowFunctionExpression<'a> { } /// Generator Function Definitions +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2203,6 +2300,7 @@ pub struct YieldExpression<'a> { } /// Class Definitions +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] @@ -2246,6 +2344,7 @@ pub enum ClassType { ClassExpression, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2255,6 +2354,7 @@ pub struct ClassBody<'a> { pub body: Vec<'a, ClassElement<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -2356,6 +2456,7 @@ impl<'a> ClassElement<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] @@ -2381,6 +2482,7 @@ pub enum MethodDefinitionType { TSAbstractMethodDefinition, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))] @@ -2431,6 +2533,7 @@ impl MethodDefinitionKind { } } +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2446,6 +2549,7 @@ impl<'a> PrivateIdentifier<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2455,6 +2559,7 @@ pub struct StaticBlock<'a> { pub body: Vec<'a, Statement<'a>>, } +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -2534,6 +2639,7 @@ impl<'a> ModuleDeclaration<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2547,6 +2653,7 @@ pub struct AccessorProperty<'a> { pub decorators: Vec<'a, Decorator<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2557,6 +2664,7 @@ pub struct ImportExpression<'a> { pub arguments: Vec<'a, Expression<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2572,6 +2680,7 @@ pub struct ImportDeclaration<'a> { pub import_kind: ImportOrExportKind, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -2587,6 +2696,7 @@ pub enum ImportDeclarationSpecifier<'a> { // import {imported} from "source" // import {imported as local} from "source" +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2599,6 +2709,7 @@ pub struct ImportSpecifier<'a> { } // import local from "source" +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2609,6 +2720,7 @@ pub struct ImportDefaultSpecifier<'a> { } // import * as local from "source" +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2618,6 +2730,7 @@ pub struct ImportNamespaceSpecifier<'a> { pub local: BindingIdentifier<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2628,6 +2741,7 @@ pub struct WithClause<'a> { pub with_entries: Vec<'a, ImportAttribute<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2638,6 +2752,7 @@ pub struct ImportAttribute<'a> { pub value: StringLiteral<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -2655,6 +2770,7 @@ impl<'a> ImportAttributeKey<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2681,6 +2797,7 @@ impl<'a> ExportNamedDeclaration<'a> { /// export default HoistableDeclaration /// export default ClassDeclaration /// export default AssignmentExpression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -2697,6 +2814,7 @@ impl<'a> ExportDefaultDeclaration<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2715,6 +2833,7 @@ impl<'a> ExportAllDeclaration<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -2736,6 +2855,7 @@ inherit_variants! { /// Export Default Declaration Kind /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -2769,6 +2889,7 @@ impl<'a> ExportDefaultDeclarationKind<'a> { /// * `export {foo as "\0 any unicode"}` /// * es2022: /// * +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index 951e09c383d3b..8722901b7c680 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -1,9 +1,13 @@ //! [JSX](https://facebook.github.io/jsx) +// NB: `#[visited_node]` attribute on AST nodes does not do anything to the code in this file. +// It is purely a marker for codegen used in `oxc_traverse`. See docs in that crate. + // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] use oxc_allocator::{Box, Vec}; +use oxc_ast_macros::visited_node; use oxc_span::{Atom, Span}; #[cfg(feature = "serialize")] use serde::Serialize; @@ -17,6 +21,7 @@ use super::inherit_variants; // 1.2 JSX Elements /// JSX Element +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -29,6 +34,7 @@ pub struct JSXElement<'a> { } /// JSX Opening Element +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -42,6 +48,7 @@ pub struct JSXOpeningElement<'a> { } /// JSX Closing Element +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -52,6 +59,7 @@ pub struct JSXClosingElement<'a> { } /// JSX Fragment +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -80,6 +88,7 @@ pub struct JSXClosingFragment { } /// JSX Element Name +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -93,6 +102,7 @@ pub enum JSXElementName<'a> { } /// JSX Namespaced Name +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -110,6 +120,7 @@ impl<'a> std::fmt::Display for JSXNamespacedName<'a> { } /// JSX Member Expression +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -129,6 +140,7 @@ impl<'a> JSXMemberExpression<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -137,6 +149,7 @@ pub enum JSXMemberExpressionObject<'a> { MemberExpression(Box<'a, JSXMemberExpression<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -150,6 +163,7 @@ inherit_variants! { /// JSX Expression /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -168,6 +182,7 @@ impl<'a> JSXExpression<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -179,6 +194,7 @@ pub struct JSXEmptyExpression { // 1.3 JSX Attributes /// JSX Attributes +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -188,6 +204,7 @@ pub enum JSXAttributeItem<'a> { } /// JSX Attribute +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -209,6 +226,7 @@ impl<'a> JSXAttribute<'a> { } /// JSX Spread Attribute +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -219,6 +237,7 @@ pub struct JSXSpreadAttribute<'a> { } /// JSX Attribute Name +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -228,6 +247,7 @@ pub enum JSXAttributeName<'a> { } /// JSX Attribute Value +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -238,6 +258,7 @@ pub enum JSXAttributeValue<'a> { Fragment(Box<'a, JSXFragment<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -256,6 +277,7 @@ impl<'a> JSXIdentifier<'a> { // 1.4 JSX Children /// JSX Child +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -267,6 +289,7 @@ pub enum JSXChild<'a> { Spread(Box<'a, JSXSpreadChild<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -276,6 +299,7 @@ pub struct JSXSpreadChild<'a> { pub expression: Expression<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index fd3d9c5a2a9db..9d756ebdfcc5f 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -1,5 +1,8 @@ //! Literals +// NB: `#[visited_node]` attribute on AST nodes does not do anything to the code in this file. +// It is purely a marker for codegen used in `oxc_traverse`. See docs in that crate. + // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] @@ -9,6 +12,7 @@ use std::{ }; use bitflags::bitflags; +use oxc_ast_macros::visited_node; use oxc_span::{Atom, Span}; use oxc_syntax::number::{BigintBase, NumberBase}; #[cfg(feature = "serialize")] @@ -16,6 +20,7 @@ use serde::Serialize; #[cfg(feature = "serialize")] use tsify::Tsify; +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -39,6 +44,7 @@ impl BooleanLiteral { } } +#[visited_node] #[derive(Debug, Clone)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -59,6 +65,7 @@ impl NullLiteral { } } +#[visited_node] #[derive(Debug, Clone)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -110,6 +117,7 @@ impl<'a> Hash for NumericLiteral<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -127,6 +135,7 @@ impl<'a> BigIntLiteral<'a> { } } +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -234,6 +243,7 @@ impl fmt::Display for RegExpFlags { #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct EmptyObject; +#[visited_node] #[derive(Debug, Clone, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index ea0b8ccff4c71..3096882fda658 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -3,10 +3,14 @@ //! [AST Spec](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/ast-spec) //! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md) +// NB: `#[visited_node]` attribute on AST nodes does not do anything to the code in this file. +// It is purely a marker for codegen used in `oxc_traverse`. See docs in that crate. + // Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` #![allow(non_snake_case)] use oxc_allocator::{Box, Vec}; +use oxc_ast_macros::visited_node; use oxc_span::{Atom, GetSpan, Span}; #[cfg(feature = "serialize")] use serde::Serialize; @@ -25,6 +29,7 @@ export interface TSIndexSignatureName extends Span { } "#; +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -38,6 +43,7 @@ pub struct TSThisParameter<'a> { /// Enum Declaration /// /// `const_opt` enum `BindingIdentifier` { `EnumBody_opt` } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -50,6 +56,7 @@ pub struct TSEnumDeclaration<'a> { pub modifiers: Modifiers<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -64,6 +71,7 @@ inherit_variants! { /// TS Enum Member Name /// /// Inherits variants from [`Expression`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -79,6 +87,7 @@ pub enum TSEnumMemberName<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -88,6 +97,7 @@ pub struct TSTypeAnnotation<'a> { pub type_annotation: TSType<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -97,6 +107,7 @@ pub struct TSLiteralType<'a> { pub literal: TSLiteral<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))] @@ -111,6 +122,7 @@ pub enum TSLiteral<'a> { UnaryExpression(Box<'a, UnaryExpression<'a>>), } +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -219,6 +231,7 @@ impl<'a> TSType<'a> { /// `SomeType extends OtherType ? TrueType : FalseType;` /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -234,6 +247,7 @@ pub struct TSConditionalType<'a> { /// string | string[] | (() => string) | { s: string } /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -246,6 +260,7 @@ pub struct TSUnionType<'a> { /// type `ColorfulCircle` = Colorful & Circle; /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -258,6 +273,7 @@ pub struct TSIntersectionType<'a> { /// keyof unique readonly /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -280,6 +296,7 @@ pub enum TSTypeOperatorOperator { /// `let myArray: string[] = ["hello", "world"];` /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -292,6 +309,7 @@ pub struct TSArrayType<'a> { /// `type I1 = Person["age" | "name"];` /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -305,6 +323,7 @@ pub struct TSIndexedAccessType<'a> { /// type `StringNumberPair` = [string, number]; /// /// +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -314,6 +333,7 @@ pub struct TSTupleType<'a> { pub element_types: Vec<'a, TSTupleElement<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -325,6 +345,7 @@ pub struct TSNamedTupleMember<'a> { pub optional: bool, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -334,6 +355,7 @@ pub struct TSOptionalType<'a> { pub type_annotation: TSType<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -347,6 +369,7 @@ inherit_variants! { /// TS Tuple Element /// /// Inherits variants from [`TSType`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -361,6 +384,7 @@ pub enum TSTupleElement<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -369,6 +393,7 @@ pub struct TSAnyKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -377,6 +402,7 @@ pub struct TSStringKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -385,6 +411,7 @@ pub struct TSBooleanKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -393,6 +420,7 @@ pub struct TSNumberKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -401,6 +429,7 @@ pub struct TSNeverKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -409,6 +438,7 @@ pub struct TSUnknownKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -417,6 +447,7 @@ pub struct TSNullKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -425,6 +456,7 @@ pub struct TSUndefinedKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -433,6 +465,7 @@ pub struct TSVoidKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -441,6 +474,7 @@ pub struct TSSymbolKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -449,6 +483,7 @@ pub struct TSThisType { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -457,6 +492,7 @@ pub struct TSObjectKeyword { pub span: Span, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type"))] @@ -468,6 +504,7 @@ pub struct TSBigIntKeyword { /// type C = A; /// type D = B.a; /// type E = D.c.b.a; +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -481,6 +518,7 @@ pub struct TSTypeReference<'a> { /// TypeName: /// IdentifierReference /// NamespaceName . IdentifierReference +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -534,6 +572,7 @@ impl GetSpan for TSTypeName<'_> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -544,6 +583,7 @@ pub struct TSQualifiedName<'a> { pub right: IdentifierName<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -553,6 +593,7 @@ pub struct TSTypeParameterInstantiation<'a> { pub params: Vec<'a, TSType<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -567,6 +608,7 @@ pub struct TSTypeParameter<'a> { pub r#const: bool, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -576,6 +618,7 @@ pub struct TSTypeParameterDeclaration<'a> { pub params: Vec<'a, TSTypeParameter<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -598,6 +641,7 @@ pub enum TSAccessibility { Public, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -611,6 +655,7 @@ pub struct TSClassImplements<'a> { /// Interface Declaration /// /// interface `BindingIdentifier` `TypeParameters_opt` `InterfaceExtendsClause_opt` `ObjectType` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -625,6 +670,7 @@ pub struct TSInterfaceDeclaration<'a> { pub modifiers: Modifiers<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -634,6 +680,7 @@ pub struct TSInterfaceBody<'a> { pub body: Vec<'a, TSSignature<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -647,6 +694,7 @@ pub struct TSPropertySignature<'a> { pub type_annotation: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))] @@ -658,6 +706,7 @@ pub enum TSSignature<'a> { TSMethodSignature(Box<'a, TSMethodSignature<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -669,6 +718,7 @@ pub struct TSIndexSignature<'a> { pub readonly: bool, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -690,6 +740,7 @@ pub enum TSMethodSignatureKind { Set, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -706,6 +757,7 @@ pub struct TSMethodSignature<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -717,6 +769,7 @@ pub struct TSConstructSignatureDeclaration<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr( @@ -730,6 +783,7 @@ pub struct TSIndexSignatureName<'a> { pub type_annotation: Box<'a, TSTypeAnnotation<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -740,6 +794,7 @@ pub struct TSInterfaceHeritage<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -751,6 +806,7 @@ pub struct TSTypePredicate<'a> { pub type_annotation: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))] @@ -759,6 +815,7 @@ pub enum TSTypePredicateName<'a> { This(TSThisType), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -790,6 +847,7 @@ pub enum TSModuleDeclarationKind { Namespace, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -807,6 +865,7 @@ impl<'a> TSModuleDeclarationName<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -815,6 +874,7 @@ pub enum TSModuleDeclarationBody<'a> { TSModuleBlock(Box<'a, TSModuleBlock<'a>>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -824,6 +884,7 @@ pub struct TSModuleBlock<'a> { pub body: Vec<'a, Statement<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -833,6 +894,7 @@ pub struct TSTypeLiteral<'a> { pub members: Vec<'a, TSSignature<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -842,6 +904,7 @@ pub struct TSInferType<'a> { pub type_parameter: Box<'a, TSTypeParameter<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -856,6 +919,7 @@ inherit_variants! { /// TS Type Query Expr Name /// /// Inherits variants from [`TSTypeName`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -867,6 +931,7 @@ pub enum TSTypeQueryExprName<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -879,6 +944,7 @@ pub struct TSImportType<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -888,6 +954,7 @@ pub struct TSImportAttributes<'a> { pub elements: Vec<'a, TSImportAttribute<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -898,6 +965,7 @@ pub struct TSImportAttribute<'a> { pub value: Expression<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(untagged))] @@ -906,6 +974,7 @@ pub enum TSImportAttributeName<'a> { StringLiteral(StringLiteral<'a>), } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -918,6 +987,7 @@ pub struct TSFunctionType<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -930,6 +1000,7 @@ pub struct TSConstructorType<'a> { pub type_parameters: Option>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -955,6 +1026,7 @@ pub enum TSMappedTypeModifierOperator { None, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -965,6 +1037,7 @@ pub struct TSTemplateLiteralType<'a> { pub types: Vec<'a, TSType<'a>>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -975,6 +1048,7 @@ pub struct TSAsExpression<'a> { pub type_annotation: TSType<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -985,6 +1059,7 @@ pub struct TSSatisfiesExpression<'a> { pub type_annotation: TSType<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -995,6 +1070,7 @@ pub struct TSTypeAssertion<'a> { pub type_annotation: TSType<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1010,6 +1086,7 @@ inherit_variants! { /// TS Module Reference /// /// Inherits variants from [`TSTypeName`]. +#[visited_node] #[repr(C, u8)] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] @@ -1021,6 +1098,7 @@ pub enum TSModuleReference<'a> { } } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1030,6 +1108,7 @@ pub struct TSExternalModuleReference<'a> { pub expression: StringLiteral<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1039,6 +1118,7 @@ pub struct TSNonNullExpression<'a> { pub expression: Expression<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1145,6 +1225,7 @@ impl<'a> Modifiers<'a> { /// Export Assignment in non-module files /// /// `export = foo` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1157,6 +1238,7 @@ pub struct TSExportAssignment<'a> { /// Namespace Export Declaration in declaration files /// /// `export as namespace foo` +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1166,6 +1248,7 @@ pub struct TSNamespaceExportDeclaration<'a> { pub id: IdentifierName<'a>, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1196,6 +1279,7 @@ impl ImportOrExportKind { // [`JSDoc`](https://github.com/microsoft/TypeScript/blob/54a554d8af2657630307cbfa8a3e4f3946e36507/src/compiler/types.ts#L393) +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] @@ -1206,6 +1290,7 @@ pub struct JSDocNullableType<'a> { pub postfix: bool, } +#[visited_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))] diff --git a/crates/oxc_ast_macros/Cargo.toml b/crates/oxc_ast_macros/Cargo.toml new file mode 100644 index 0000000000000..fdd566dcc2d0f --- /dev/null +++ b/crates/oxc_ast_macros/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "oxc_ast_macros" +version = "0.0.0" +publish = false +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +categories.workspace = true + +[lints] +workspace = true + +[lib] +proc-macro = true +doctest = false diff --git a/crates/oxc_ast_macros/src/lib.rs b/crates/oxc_ast_macros/src/lib.rs new file mode 100644 index 0000000000000..92efceb9e3ca0 --- /dev/null +++ b/crates/oxc_ast_macros/src/lib.rs @@ -0,0 +1,8 @@ +use proc_macro::TokenStream; + +/// Attach to AST node type (struct or enum), to signal to codegen to create visitor for this type. +/// Macro itself does nothing - just passes through the token stream unchanged. +#[proc_macro_attribute] +pub fn visited_node(_args: TokenStream, input: TokenStream) -> TokenStream { + input +} From df09437a978a42af419dc64e272db507803ac858 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:06:24 +0100 Subject: [PATCH 2/7] `oxc_traverse` crate --- Cargo.lock | 96 + Cargo.toml | 3 + crates/oxc_traverse/Cargo.toml | 29 + crates/oxc_traverse/build.rs | 22 + crates/oxc_traverse/scripts/build.mjs | 40 + crates/oxc_traverse/scripts/lib/ancestor.mjs | 142 + crates/oxc_traverse/scripts/lib/parse.mjs | 98 + crates/oxc_traverse/scripts/lib/traverse.mjs | 33 + crates/oxc_traverse/scripts/lib/utils.mjs | 40 + crates/oxc_traverse/scripts/lib/walk.mjs | 212 + crates/oxc_traverse/scripts/package.json | 5 + crates/oxc_traverse/src/ancestor.rs | 10943 ++++++++++++++++ crates/oxc_traverse/src/context.rs | 143 + crates/oxc_traverse/src/lib.rs | 149 + crates/oxc_traverse/src/traverse.rs | 1993 +++ crates/oxc_traverse/src/walk.rs | 5302 ++++++++ crates/oxc_traverse/tests/compile_fail.rs | 5 + .../tests/compile_fail/ancestor_lifetime1.rs | 18 + .../compile_fail/ancestor_lifetime1.stderr | 11 + .../tests/compile_fail/ancestor_lifetime2.rs | 20 + .../compile_fail/ancestor_lifetime2.stderr | 11 + .../tests/compile_fail/ancestor_lifetime3.rs | 21 + .../compile_fail/ancestor_lifetime3.stderr | 11 + 23 files changed, 19347 insertions(+) create mode 100644 crates/oxc_traverse/Cargo.toml create mode 100644 crates/oxc_traverse/build.rs create mode 100644 crates/oxc_traverse/scripts/build.mjs create mode 100644 crates/oxc_traverse/scripts/lib/ancestor.mjs create mode 100644 crates/oxc_traverse/scripts/lib/parse.mjs create mode 100644 crates/oxc_traverse/scripts/lib/traverse.mjs create mode 100644 crates/oxc_traverse/scripts/lib/utils.mjs create mode 100644 crates/oxc_traverse/scripts/lib/walk.mjs create mode 100644 crates/oxc_traverse/scripts/package.json create mode 100644 crates/oxc_traverse/src/ancestor.rs create mode 100644 crates/oxc_traverse/src/context.rs create mode 100644 crates/oxc_traverse/src/lib.rs create mode 100644 crates/oxc_traverse/src/traverse.rs create mode 100644 crates/oxc_traverse/src/walk.rs create mode 100644 crates/oxc_traverse/tests/compile_fail.rs create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.rs create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.stderr create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.rs create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.stderr create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.rs create mode 100644 crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.stderr diff --git a/Cargo.lock b/Cargo.lock index 1e9e3b1682303..c9a5727e0751b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -973,6 +973,15 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "miette" version = "7.2.0" @@ -1693,6 +1702,18 @@ dependencies = [ "serde", ] +[[package]] +name = "oxc_traverse" +version = "0.12.5" +dependencies = [ + "memoffset", + "oxc_allocator", + "oxc_ast", + "oxc_span", + "oxc_syntax", + "trybuild", +] + [[package]] name = "oxc_wasm" version = "0.0.0" @@ -2234,6 +2255,15 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "sha2" version = "0.10.8" @@ -2362,6 +2392,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -2472,6 +2511,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -2593,6 +2666,20 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "trybuild" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0e5d82932dfbf36df38de5df0cfe846d13430b3ae3fdc48b2e91ed692c8df7" +dependencies = [ + "glob", + "serde", + "serde_derive", + "serde_json", + "termcolor", + "toml", +] + [[package]] name = "tsify" version = "0.4.5" @@ -3010,6 +3097,15 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +[[package]] +name = "winnow" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +dependencies = [ + "memchr", +] + [[package]] name = "yansi" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 42aaf198c8ae0..cf18998f231ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,6 +92,7 @@ oxc_macros = { path = "crates/oxc_macros" } oxc_linter = { path = "crates/oxc_linter" } oxc_prettier = { path = "crates/oxc_prettier" } oxc_tasks_common = { path = "tasks/common" } +oxc_traverse = { path = "crates/oxc_traverse" } napi = "2" napi-derive = "2" @@ -111,6 +112,7 @@ ignore = "0.4.22" itertools = "0.12.1" jemallocator = "0.5.4" lazy_static = "1.4.0" +memoffset = "0.9.1" miette = { version = "7.2.0", features = ["fancy-no-syscall"] } mimalloc = "0.1.41" num-bigint = "0.4.4" @@ -133,6 +135,7 @@ tempfile = "3.10.1" thiserror = "1.0.59" tokio = "1" tower-lsp = "0.20.0" +trybuild = "1.0.93" unicode-id-start = "1.1.2" ureq = { version = "2.9.6", default-features = false } url = "2.5.0" diff --git a/crates/oxc_traverse/Cargo.toml b/crates/oxc_traverse/Cargo.toml new file mode 100644 index 0000000000000..fbaade960fffd --- /dev/null +++ b/crates/oxc_traverse/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "oxc_traverse" +version = "0.12.5" +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +categories.workspace = true + +[lints] +workspace = true + +[lib] +doctest = true + +[dependencies] +oxc_allocator = { workspace = true } +oxc_ast = { workspace = true } +oxc_span = { workspace = true } +oxc_syntax = { workspace = true } + +memoffset = { workspace = true } + +[dev-dependencies] +trybuild = { workspace = true } diff --git a/crates/oxc_traverse/build.rs b/crates/oxc_traverse/build.rs new file mode 100644 index 0000000000000..dd2a6bffe1cb6 --- /dev/null +++ b/crates/oxc_traverse/build.rs @@ -0,0 +1,22 @@ +use std::{env, process::Command}; + +fn main() { + // Re-run if NodeJS build script or AST types change + println!("cargo:rerun-if-changed=scripts"); + println!("cargo:rerun-if-changed=../oxc_ast/src/ast"); + + // Exit if on CI. + // The built files should be checked into git, so want to run tests etc on what's actually in repo, + // rather than regenerating them. + match env::var("CI") { + Ok(value) if value == "true" => return, + _ => {} + } + + // Run NodeJS build script + let status = Command::new("node") + .arg("./scripts/build.mjs") + .status() + .expect("Failed to run NodeJS build script"); + assert!(status.success(), "Failed to run NodeJS build script"); +} diff --git a/crates/oxc_traverse/scripts/build.mjs b/crates/oxc_traverse/scripts/build.mjs new file mode 100644 index 0000000000000..79da6d90eb0d3 --- /dev/null +++ b/crates/oxc_traverse/scripts/build.mjs @@ -0,0 +1,40 @@ +/* + * Codegen for `traverse`. + * + * Parses Rust AST type definitions from files in `crates/oxc_ast/src/ast`, and generates: + * - `src/traverse.rs` + * - `src/ancestor.rs` + * - `src/walk.rs` + * + * This is a quick-and-dirty version written in JS for speed of implementation. + * We should do this properly with a Rust build script using `syn` etc. + */ + +import {writeFile} from 'fs/promises'; +import {exec} from 'child_process'; +import {join as pathJoin} from 'path'; +import {fileURLToPath} from 'url'; +import {promisify} from 'util'; +import getTypesFromCode from './lib/parse.mjs'; +import generateTraverseTraitCode from './lib/traverse.mjs'; +import generateAncestorsCode from './lib/ancestor.mjs'; +import generateWalkFunctionsCode from './lib/walk.mjs'; + +const execAsync = promisify(exec); + +const PREAMBLE = '// Generated by `scripts/build.mjs`.\n\n'; + +const types = await getTypesFromCode(); + +const outputDirPath = pathJoin(fileURLToPath(import.meta.url), '../../src'); +await writeToFile('traverse.rs', generateTraverseTraitCode(types)); +await writeToFile('ancestor.rs', generateAncestorsCode(types)); +await writeToFile('walk.rs', generateWalkFunctionsCode(types)); + +async function writeToFile(filename, code) { + code = `${PREAMBLE}${code}`; + const path = pathJoin(outputDirPath, filename); + console.log('Writing:', path); + await writeFile(path, code); + await execAsync(`rustfmt ${JSON.stringify(path)}`); +} diff --git a/crates/oxc_traverse/scripts/lib/ancestor.mjs b/crates/oxc_traverse/scripts/lib/ancestor.mjs new file mode 100644 index 0000000000000..98d7bcb405c1c --- /dev/null +++ b/crates/oxc_traverse/scripts/lib/ancestor.mjs @@ -0,0 +1,142 @@ +import {camelToSnake, snakeToCamel} from './utils.mjs'; + +export default function generateAncestorsCode(types) { + const variantNamesForEnums = Object.create(null); + let enumVariants = '', + isFunctions = '', + ancestorTypes = '', + discriminant = 1; + for (const type of Object.values(types)) { + if (type.kind === 'enum') continue; + + const typeSnakeName = camelToSnake(type.name), + typeScreamingName = typeSnakeName.toUpperCase(); + let offsetCode = ''; + for (const field of type.fields) { + const offsetVarName = `OFFSET_${typeScreamingName}_${field.name.toUpperCase()}`; + field.offsetVarName = offsetVarName; + offsetCode += `pub(crate) const ${offsetVarName}: usize = ` + + `offset_of!(${type.name}, ${field.rawName});\n`; + } + + const variantNames = []; + let thisAncestorTypes = ''; + for (const field of type.fields) { + const fieldTypeName = field.innerTypeName, + fieldType = types[fieldTypeName]; + if (!fieldType) continue; + + let methodsCode = ''; + for (const otherField of type.fields) { + if (otherField === field) continue; + + methodsCode += ` + #[inline] + pub fn ${otherField.rawName}(&self) -> &${otherField.rawTypeName} { + unsafe { + &*( + (self.0 as *const u8).add(${otherField.offsetVarName}) + as *const ${otherField.rawTypeName} + ) + } + } + `; + } + + const fieldNameCamel = snakeToCamel(field.name), + lifetime = type.hasLifetime ? "<'a>" : '', + structName = `${type.name}Without${fieldNameCamel}${lifetime}`; + + thisAncestorTypes += ` + #[repr(transparent)] + #[derive(Debug)] + pub struct ${structName}( + pub(crate) *const ${type.name}${lifetime} + ); + + impl${lifetime} ${structName} { + ${methodsCode} + } + `; + + const variantName = `${type.name}${fieldNameCamel}`; + variantNames.push(variantName); + + enumVariants += `${variantName}(${structName}) = ${discriminant},\n`; + field.ancestorDiscriminant = discriminant; + discriminant++; + + if (fieldType.kind === 'enum') { + (variantNamesForEnums[fieldTypeName] || (variantNamesForEnums[fieldTypeName] = [])) + .push(variantName); + } + } + + if (variantNames.length > 0) { + ancestorTypes += ` + ${offsetCode} + ${thisAncestorTypes} + `; + + isFunctions += ` + #[inline] + pub fn is_${typeSnakeName}(&self) -> bool { + matches!(self, ${variantNames.map(name => `Self::${name}(_)`).join(' | ')}) + } + `; + } + } + + for (const [typeName, variantNames] of Object.entries(variantNamesForEnums)) { + isFunctions += ` + #[inline] + pub fn is_via_${camelToSnake(typeName)}(&self) -> bool { + matches!(self, ${variantNames.map(name => `Self::${name}(_)`).join(' | ')}) + } + `; + } + + const discriminantType = discriminant <= 256 ? 'u8' : 'u16'; + + return ` + #![allow( + unsafe_code, + clippy::missing_safety_doc, + clippy::ptr_as_ptr, + clippy::undocumented_unsafe_blocks, + clippy::cast_ptr_alignment + )] + + use memoffset::offset_of; + + use oxc_allocator::{Box, Vec}; + #[allow(clippy::wildcard_imports)] + use oxc_ast::ast::*; + use oxc_span::{Atom, SourceType, Span}; + use oxc_syntax::operator::{ + AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, + }; + + pub(crate) type AncestorDiscriminant = ${discriminantType}; + + /// Ancestor type used in AST traversal. + /// + /// Encodes both the type of the parent, and child's location in the parent. + /// i.e. variants for \`BinaryExpressionLeft\` and \`BinaryExpressionRight\`, not just \`BinaryExpression\`. + // + // SAFETY: This type MUST be \`#[repr(u8)]\` or \`#[repr(u16)]\` (depending on number of variants) + // to maintain the safety of \`TraverseCtx::retag_stack\`. + #[repr(C, ${discriminantType})] + #[derive(Debug)] + pub enum Ancestor<'a> { + None = 0, + ${enumVariants} + } + + impl<'a> Ancestor<'a> { + ${isFunctions} + } + + ${ancestorTypes} + `; +} diff --git a/crates/oxc_traverse/scripts/lib/parse.mjs b/crates/oxc_traverse/scripts/lib/parse.mjs new file mode 100644 index 0000000000000..72a4f565ce6fb --- /dev/null +++ b/crates/oxc_traverse/scripts/lib/parse.mjs @@ -0,0 +1,98 @@ +import {readFile} from 'fs/promises'; +import {join as pathJoin} from 'path'; +import {fileURLToPath} from 'url'; +import assert from 'assert'; +import {typeAndWrappers} from './utils.mjs'; + +const FILENAMES = ['js.rs', 'jsx.rs', 'literal.rs', 'ts.rs']; + +/** + * Parse type defs from Rust files. + */ +export default async function getTypesFromCode() { + const codeDirPath = pathJoin(fileURLToPath(import.meta.url), '../../../../oxc_ast/src/ast/'); + + const types = Object.create(null); + for (const filename of FILENAMES) { + const code = await readFile(`${codeDirPath}${filename}`, 'utf8'); + parseFile(code, filename, types); + } + return types; +} + +function parseFile(code, filename, types) { + const lines = code.split(/\r?\n/); + for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) { + if (lines[lineIndex] !== '#[visited_node]') continue; + + let match; + while (true) { + match = lines[++lineIndex].match(/^pub (enum|struct) (.+?)(<'a>)? \{/); + if (match) break; + } + const [, kind, name, lifetimeStr] = match, + hasLifetime = !!lifetimeStr, + startLineIndex = lineIndex; + + const itemLines = []; + while (true) { + const line = lines[++lineIndex].replace(/\/\/.*$/, '').replace(/\s+/g, ' ').trim(); + if (line === '}') break; + if (line !== '') itemLines.push(line); + } + + if (kind === 'struct') { + types[name] = parseStruct(name, hasLifetime, itemLines, filename, startLineIndex); + } else { + types[name] = parseEnum(name, hasLifetime, itemLines, filename, startLineIndex); + } + } +} + +function parseStruct(name, hasLifetime, lines, filename, startLineIndex) { + const fields = []; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + if (line.startsWith('#[')) { + while (!lines[i].endsWith(']')) { + i++; + } + continue; + } + + const match = line.match(/^pub ((?:r#)?([a-z_]+)): (.+),$/); + assert( + match, + `Cannot parse line ${startLineIndex + i} in '${filename}' as struct field: '${line}'` + ); + const [, rawName, name, rawTypeName] = match, + typeName = rawTypeName.replace(/<'a>/g, '').replace(/<'a, ?/g, '<'), + {name: innerTypeName, wrappers} = typeAndWrappers(typeName); + + fields.push({name, typeName, rawName, rawTypeName, innerTypeName, wrappers}); + } + return {kind: 'struct', name, hasLifetime, fields}; +} + +function parseEnum(name, hasLifetime, lines, filename, startLineIndex) { + const variants = [], + inherits = []; + for (const [lineIndex, line] of lines.entries()) { + const match = line.match(/^(.+?)\((.+?)\)(?: ?= ?(\d+))?,$/); + if (match) { + const [, name, rawTypeName, discriminantStr] = match, + typeName = rawTypeName.replace(/<'a>/g, '').replace(/<'a,\s*/g, '<'), + {name: innerTypeName, wrappers} = typeAndWrappers(typeName), + discriminant = discriminantStr ? +discriminantStr : null; + variants.push({name, typeName, rawTypeName, innerTypeName, wrappers, discriminant}); + } else { + const match2 = line.match(/^@inherit ([A-Za-z]+)$/); + assert( + match2, + `Cannot parse line ${startLineIndex + lineIndex} in '${filename}' as enum variant: '${line}'` + ); + inherits.push(match2[1]); + } + } + return {kind: 'enum', name, hasLifetime, variants, inherits}; +} diff --git a/crates/oxc_traverse/scripts/lib/traverse.mjs b/crates/oxc_traverse/scripts/lib/traverse.mjs new file mode 100644 index 0000000000000..9d6e8f96e6902 --- /dev/null +++ b/crates/oxc_traverse/scripts/lib/traverse.mjs @@ -0,0 +1,33 @@ +import {camelToSnake, toTypeName} from './utils.mjs'; + +export default function generateTraverseTraitCode(types) { + let traverseMethods = ''; + for (const type of Object.values(types)) { + const snakeName = camelToSnake(type.name), + typeName = toTypeName(type); + traverseMethods += ` + #[inline] + fn enter_${snakeName}(&mut self, node: &mut ${typeName}, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_${snakeName}(&mut self, node: &mut ${typeName}, ctx: &TraverseCtx<'a>) {} + `; + } + + return ` + use oxc_allocator::Vec; + #[allow(clippy::wildcard_imports)] + use oxc_ast::ast::*; + + use crate::TraverseCtx; + + #[allow(unused_variables)] + pub trait Traverse<'a> { + ${traverseMethods} + + #[inline] + fn enter_statements(&mut self, node: &mut Vec<'a, Statement<'a>>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_statements(&mut self, node: &mut Vec<'a, Statement<'a>>, ctx: &TraverseCtx<'a>) {} + } + `; +} diff --git a/crates/oxc_traverse/scripts/lib/utils.mjs b/crates/oxc_traverse/scripts/lib/utils.mjs new file mode 100644 index 0000000000000..e03fddf235e83 --- /dev/null +++ b/crates/oxc_traverse/scripts/lib/utils.mjs @@ -0,0 +1,40 @@ +export function typeAndWrappers(name) { + const wrappers = []; + while (true) { + const match = name.match(/^(.+?)<(.+)>$/); + if (!match) break; + wrappers.push(match[1]); + name = match[2]; + } + return {name, wrappers}; +} + +export function toTypeName(type) { + let ty = type.name; + if (type.hasLifetime) ty += "<'a>"; + return ty; +} + +export function camelToSnake(name) { + let prefixLen = 1; + for (const prefix of ['TS', 'JSX', 'JS']) { + if (name.startsWith(prefix)) { + prefixLen = prefix.length; + break; + } + } + return name.slice(0, prefixLen).toLowerCase() + + name.slice(prefixLen).replace(/[A-Z]/g, c => `_${c.toLowerCase()}`); +} + +export function snakeToCamel(name) { + let prefixLen = 0; + for (const prefix of ['TS', 'JSX', 'JS']) { + if (name.startsWith(`${prefix.toLowerCase()}_`)) { + prefixLen = prefix.length + 1; + break; + } + } + return name.slice(0, prefixLen + 1).toUpperCase() + + name.slice(prefixLen + 1).replace(/_([a-z])/g, (_, c) => c.toUpperCase()); +} diff --git a/crates/oxc_traverse/scripts/lib/walk.mjs b/crates/oxc_traverse/scripts/lib/walk.mjs new file mode 100644 index 0000000000000..953189a81703c --- /dev/null +++ b/crates/oxc_traverse/scripts/lib/walk.mjs @@ -0,0 +1,212 @@ +import assert from 'assert'; +import {toTypeName, camelToSnake, snakeToCamel} from './utils.mjs'; + +export default function generateWalkFunctionsCode(types) { + let walkMethods = ''; + for (const type of Object.values(types)) { + if (type.kind === 'struct') { + walkMethods += generateWalkForStruct(type, types); + } else { + walkMethods += generateWalkForEnum(type, types); + } + } + + return ` + #![allow( + unsafe_code, + clippy::missing_safety_doc, + clippy::missing_panics_doc, + clippy::undocumented_unsafe_blocks, + clippy::semicolon_if_nothing_returned, + clippy::ptr_as_ptr, + clippy::borrow_as_ptr, + clippy::cast_ptr_alignment + )] + + use oxc_allocator::Vec; + #[allow(clippy::wildcard_imports)] + use oxc_ast::ast::*; + + use crate::{ancestor, Ancestor, Traverse, TraverseCtx}; + + ${walkMethods} + + pub(crate) unsafe fn walk_statements<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + stmts: *mut Vec<'a, Statement<'a>>, + ctx: &mut TraverseCtx<'a> + ) { + traverser.enter_statements(&mut *stmts, ctx); + for stmt in (*stmts).iter_mut() { + walk_statement(traverser, stmt, ctx); + } + traverser.exit_statements(&mut *stmts, ctx); + } + `; +} + +function generateWalkForStruct(type, types) { + const visitedFields = type.fields.filter(field => field.innerTypeName in types); + + const fieldsCodes = visitedFields.map((field, index) => { + const fieldWalkName = `walk_${camelToSnake(field.innerTypeName)}`; + + const retagCode = index === 0 ? '' : `ctx.retag_stack(${field.ancestorDiscriminant});`, + fieldCode = `(node as *mut u8).add(ancestor::${field.offsetVarName}) as *mut ${field.typeName}`; + + if (field.wrappers[0] === 'Option') { + let walkCode; + if (field.wrappers.length === 2 && field.wrappers[1] === 'Vec') { + if (field.typeNameInner === 'Statement') { + // Special case for `Option>` + walkCode = `walk_statements(traverser, field as *mut _, ctx);`; + } else { + walkCode = ` + for item in field.iter_mut() { + ${fieldWalkName}(traverser, item as *mut _, ctx); + } + `.trim(); + } + } else if (field.wrappers.length === 2 && field.wrappers[1] === 'Box') { + walkCode = `${fieldWalkName}(traverser, (&mut **field) as *mut _, ctx);`; + } else { + assert(field.wrappers.length === 1, `Cannot handle struct field with type ${field.typeName}`); + walkCode = `${fieldWalkName}(traverser, field as *mut _, ctx);`; + } + + return ` + if let Some(field) = &mut *(${fieldCode}) { + ${retagCode} + ${walkCode} + } + `; + } + + if (field.wrappers[0] === 'Vec') { + let walkVecCode; + if (field.wrappers.length === 1 && field.innerTypeName === 'Statement') { + // Special case for `Vec` + walkVecCode = `walk_statements(traverser, ${fieldCode}, ctx);` + } else { + let walkCode = `${fieldWalkName}(traverser, item as *mut _, ctx);`, + iterModifier = ''; + if (field.wrappers.length === 2 && field.wrappers[1] === 'Option') { + iterModifier = '.flatten()'; + } else { + assert( + field.wrappers.length === 1, + `Cannot handle struct field with type ${field.type}` + ); + } + walkVecCode = ` + for item in (*(${fieldCode})).iter_mut()${iterModifier} { + ${walkCode} + } + `.trim(); + } + + return ` + ${retagCode} + ${walkVecCode} + `; + } + + if (field.wrappers.length === 1 && field.wrappers[0] === 'Box') { + return ` + ${retagCode} + ${fieldWalkName}(traverser, (&mut **(${fieldCode})) as *mut _, ctx); + `; + } + + assert(field.wrappers.length === 0, `Cannot handle struct field with type: ${field.type}`); + + return ` + ${retagCode} + ${fieldWalkName}(traverser, ${fieldCode}, ctx); + `; + }); + + if (visitedFields.length > 0) { + const field = visitedFields[0], + fieldCamelName = snakeToCamel(field.name); + fieldsCodes.unshift(` + ctx.push_stack( + Ancestor::${type.name}${fieldCamelName}( + ancestor::${type.name}Without${fieldCamelName}(node) + ) + ); + `); + fieldsCodes.push('ctx.pop_stack();'); + } + + const typeSnakeName = camelToSnake(type.name); + return ` + pub(crate) unsafe fn walk_${typeSnakeName}<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ${toTypeName(type)}, + ctx: &mut TraverseCtx<'a> + ) { + traverser.enter_${typeSnakeName}(&mut *node, ctx); + ${fieldsCodes.join('\n')} + traverser.exit_${typeSnakeName}(&mut *node, ctx); + } + `.replace(/\n\s*\n+/g, '\n'); +} + +function generateWalkForEnum(type, types) { + const variantCodes = type.variants.map((variant) => { + const variantType = types[variant.innerTypeName]; + assert(variantType, `Cannot handle enum variant with type: ${variant.type}`); + + let nodeCode = 'node'; + if (variant.wrappers.length === 1 && variant.wrappers[0] === 'Box') { + nodeCode = '(&mut **node)'; + } else { + assert(variant.wrappers.length === 0, `Cannot handle enum variant with type: ${variant.type}`); + } + + return `${type.name}::${variant.name}(node) => ` + + `walk_${camelToSnake(variant.innerTypeName)}(traverser, ${nodeCode} as *mut _, ctx),`; + }); + + const missingVariants = []; + for (const inheritedTypeName of type.inherits) { + // Recurse into nested inherited types + const variantMatches = [], + inheritedFrom = [inheritedTypeName]; + for (let i = 0; i < inheritedFrom.length; i++) { + const inheritedTypeName = inheritedFrom[i], + inheritedType = types[inheritedTypeName]; + if (!inheritedType || inheritedType.kind !== 'enum') { + missingVariants.push(inheritedTypeName); + } else { + variantMatches.push(...inheritedType.variants.map( + variant => `${type.name}::${variant.name}(_)` + )); + inheritedFrom.push(...inheritedType.inherits); + } + } + + variantCodes.push( + `${variantMatches.join(' | ')} => ` + + `walk_${camelToSnake(inheritedTypeName)}(traverser, node as *mut _, ctx),` + ); + } + + assert(missingVariants.length === 0, `Missing enum variants: ${missingVariants.join(', ')}`); + + const typeSnakeName = camelToSnake(type.name); + return ` + pub(crate) unsafe fn walk_${typeSnakeName}<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ${toTypeName(type)}, + ctx: &mut TraverseCtx<'a> + ) { + traverser.enter_${typeSnakeName}(&mut *node, ctx); + match &mut *node { + ${variantCodes.join('\n')} + } + traverser.exit_${typeSnakeName}(&mut *node, ctx); + } + `; +} diff --git a/crates/oxc_traverse/scripts/package.json b/crates/oxc_traverse/scripts/package.json new file mode 100644 index 0000000000000..50394bcefad29 --- /dev/null +++ b/crates/oxc_traverse/scripts/package.json @@ -0,0 +1,5 @@ +{ + "name": "oxc_ast_scripts", + "version": "0.0.0", + "type": "module" +} diff --git a/crates/oxc_traverse/src/ancestor.rs b/crates/oxc_traverse/src/ancestor.rs new file mode 100644 index 0000000000000..a34ec5d826e3c --- /dev/null +++ b/crates/oxc_traverse/src/ancestor.rs @@ -0,0 +1,10943 @@ +// Generated by `scripts/build.mjs`. + +#![allow( + unsafe_code, + clippy::missing_safety_doc, + clippy::ptr_as_ptr, + clippy::undocumented_unsafe_blocks, + clippy::cast_ptr_alignment +)] + +use memoffset::offset_of; + +use oxc_allocator::{Box, Vec}; +#[allow(clippy::wildcard_imports)] +use oxc_ast::ast::*; +use oxc_span::{Atom, SourceType, Span}; +use oxc_syntax::operator::{ + AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator, +}; + +pub(crate) type AncestorDiscriminant = u16; + +/// Ancestor type used in AST traversal. +/// +/// Encodes both the type of the parent, and child's location in the parent. +/// i.e. variants for `BinaryExpressionLeft` and `BinaryExpressionRight`, not just `BinaryExpression`. +// +// SAFETY: This type MUST be `#[repr(u8)]` or `#[repr(u16)]` (depending on number of variants) +// to maintain the safety of `TraverseCtx::retag_stack`. +#[repr(C, u16)] +#[derive(Debug)] +pub enum Ancestor<'a> { + None = 0, + ProgramDirectives(ProgramWithoutDirectives<'a>) = 1, + ProgramHashbang(ProgramWithoutHashbang<'a>) = 2, + ProgramBody(ProgramWithoutBody<'a>) = 3, + ArrayExpressionElements(ArrayExpressionWithoutElements<'a>) = 4, + ObjectExpressionProperties(ObjectExpressionWithoutProperties<'a>) = 5, + ObjectPropertyKey(ObjectPropertyWithoutKey<'a>) = 6, + ObjectPropertyValue(ObjectPropertyWithoutValue<'a>) = 7, + ObjectPropertyInit(ObjectPropertyWithoutInit<'a>) = 8, + TemplateLiteralQuasis(TemplateLiteralWithoutQuasis<'a>) = 9, + TemplateLiteralExpressions(TemplateLiteralWithoutExpressions<'a>) = 10, + TaggedTemplateExpressionTag(TaggedTemplateExpressionWithoutTag<'a>) = 11, + TaggedTemplateExpressionQuasi(TaggedTemplateExpressionWithoutQuasi<'a>) = 12, + TaggedTemplateExpressionTypeParameters(TaggedTemplateExpressionWithoutTypeParameters<'a>) = 13, + ComputedMemberExpressionObject(ComputedMemberExpressionWithoutObject<'a>) = 14, + ComputedMemberExpressionExpression(ComputedMemberExpressionWithoutExpression<'a>) = 15, + StaticMemberExpressionObject(StaticMemberExpressionWithoutObject<'a>) = 16, + StaticMemberExpressionProperty(StaticMemberExpressionWithoutProperty<'a>) = 17, + PrivateFieldExpressionObject(PrivateFieldExpressionWithoutObject<'a>) = 18, + PrivateFieldExpressionField(PrivateFieldExpressionWithoutField<'a>) = 19, + CallExpressionCallee(CallExpressionWithoutCallee<'a>) = 20, + CallExpressionArguments(CallExpressionWithoutArguments<'a>) = 21, + CallExpressionTypeParameters(CallExpressionWithoutTypeParameters<'a>) = 22, + NewExpressionCallee(NewExpressionWithoutCallee<'a>) = 23, + NewExpressionArguments(NewExpressionWithoutArguments<'a>) = 24, + NewExpressionTypeParameters(NewExpressionWithoutTypeParameters<'a>) = 25, + MetaPropertyMeta(MetaPropertyWithoutMeta<'a>) = 26, + MetaPropertyProperty(MetaPropertyWithoutProperty<'a>) = 27, + SpreadElementArgument(SpreadElementWithoutArgument<'a>) = 28, + UpdateExpressionArgument(UpdateExpressionWithoutArgument<'a>) = 29, + UnaryExpressionArgument(UnaryExpressionWithoutArgument<'a>) = 30, + BinaryExpressionLeft(BinaryExpressionWithoutLeft<'a>) = 31, + BinaryExpressionRight(BinaryExpressionWithoutRight<'a>) = 32, + PrivateInExpressionLeft(PrivateInExpressionWithoutLeft<'a>) = 33, + PrivateInExpressionRight(PrivateInExpressionWithoutRight<'a>) = 34, + LogicalExpressionLeft(LogicalExpressionWithoutLeft<'a>) = 35, + LogicalExpressionRight(LogicalExpressionWithoutRight<'a>) = 36, + ConditionalExpressionTest(ConditionalExpressionWithoutTest<'a>) = 37, + ConditionalExpressionConsequent(ConditionalExpressionWithoutConsequent<'a>) = 38, + ConditionalExpressionAlternate(ConditionalExpressionWithoutAlternate<'a>) = 39, + AssignmentExpressionLeft(AssignmentExpressionWithoutLeft<'a>) = 40, + AssignmentExpressionRight(AssignmentExpressionWithoutRight<'a>) = 41, + ArrayAssignmentTargetElements(ArrayAssignmentTargetWithoutElements<'a>) = 42, + ArrayAssignmentTargetRest(ArrayAssignmentTargetWithoutRest<'a>) = 43, + ObjectAssignmentTargetProperties(ObjectAssignmentTargetWithoutProperties<'a>) = 44, + ObjectAssignmentTargetRest(ObjectAssignmentTargetWithoutRest<'a>) = 45, + AssignmentTargetRestTarget(AssignmentTargetRestWithoutTarget<'a>) = 46, + AssignmentTargetWithDefaultBinding(AssignmentTargetWithDefaultWithoutBinding<'a>) = 47, + AssignmentTargetWithDefaultInit(AssignmentTargetWithDefaultWithoutInit<'a>) = 48, + AssignmentTargetPropertyIdentifierBinding(AssignmentTargetPropertyIdentifierWithoutBinding<'a>) = + 49, + AssignmentTargetPropertyIdentifierInit(AssignmentTargetPropertyIdentifierWithoutInit<'a>) = 50, + AssignmentTargetPropertyPropertyName(AssignmentTargetPropertyPropertyWithoutName<'a>) = 51, + AssignmentTargetPropertyPropertyBinding(AssignmentTargetPropertyPropertyWithoutBinding<'a>) = + 52, + SequenceExpressionExpressions(SequenceExpressionWithoutExpressions<'a>) = 53, + AwaitExpressionArgument(AwaitExpressionWithoutArgument<'a>) = 54, + ChainExpressionExpression(ChainExpressionWithoutExpression<'a>) = 55, + ParenthesizedExpressionExpression(ParenthesizedExpressionWithoutExpression<'a>) = 56, + DirectiveExpression(DirectiveWithoutExpression<'a>) = 57, + BlockStatementBody(BlockStatementWithoutBody<'a>) = 58, + VariableDeclarationDeclarations(VariableDeclarationWithoutDeclarations<'a>) = 59, + VariableDeclaratorId(VariableDeclaratorWithoutId<'a>) = 60, + VariableDeclaratorInit(VariableDeclaratorWithoutInit<'a>) = 61, + UsingDeclarationDeclarations(UsingDeclarationWithoutDeclarations<'a>) = 62, + ExpressionStatementExpression(ExpressionStatementWithoutExpression<'a>) = 63, + IfStatementTest(IfStatementWithoutTest<'a>) = 64, + IfStatementConsequent(IfStatementWithoutConsequent<'a>) = 65, + IfStatementAlternate(IfStatementWithoutAlternate<'a>) = 66, + DoWhileStatementBody(DoWhileStatementWithoutBody<'a>) = 67, + DoWhileStatementTest(DoWhileStatementWithoutTest<'a>) = 68, + WhileStatementTest(WhileStatementWithoutTest<'a>) = 69, + WhileStatementBody(WhileStatementWithoutBody<'a>) = 70, + ForStatementInit(ForStatementWithoutInit<'a>) = 71, + ForStatementTest(ForStatementWithoutTest<'a>) = 72, + ForStatementUpdate(ForStatementWithoutUpdate<'a>) = 73, + ForStatementBody(ForStatementWithoutBody<'a>) = 74, + ForInStatementLeft(ForInStatementWithoutLeft<'a>) = 75, + ForInStatementRight(ForInStatementWithoutRight<'a>) = 76, + ForInStatementBody(ForInStatementWithoutBody<'a>) = 77, + ForOfStatementLeft(ForOfStatementWithoutLeft<'a>) = 78, + ForOfStatementRight(ForOfStatementWithoutRight<'a>) = 79, + ForOfStatementBody(ForOfStatementWithoutBody<'a>) = 80, + ContinueStatementLabel(ContinueStatementWithoutLabel<'a>) = 81, + BreakStatementLabel(BreakStatementWithoutLabel<'a>) = 82, + ReturnStatementArgument(ReturnStatementWithoutArgument<'a>) = 83, + WithStatementObject(WithStatementWithoutObject<'a>) = 84, + WithStatementBody(WithStatementWithoutBody<'a>) = 85, + SwitchStatementDiscriminant(SwitchStatementWithoutDiscriminant<'a>) = 86, + SwitchStatementCases(SwitchStatementWithoutCases<'a>) = 87, + SwitchCaseTest(SwitchCaseWithoutTest<'a>) = 88, + SwitchCaseConsequent(SwitchCaseWithoutConsequent<'a>) = 89, + LabeledStatementLabel(LabeledStatementWithoutLabel<'a>) = 90, + LabeledStatementBody(LabeledStatementWithoutBody<'a>) = 91, + ThrowStatementArgument(ThrowStatementWithoutArgument<'a>) = 92, + TryStatementBlock(TryStatementWithoutBlock<'a>) = 93, + TryStatementHandler(TryStatementWithoutHandler<'a>) = 94, + TryStatementFinalizer(TryStatementWithoutFinalizer<'a>) = 95, + CatchClauseParam(CatchClauseWithoutParam<'a>) = 96, + CatchClauseBody(CatchClauseWithoutBody<'a>) = 97, + CatchParameterPattern(CatchParameterWithoutPattern<'a>) = 98, + BindingPatternKind(BindingPatternWithoutKind<'a>) = 99, + BindingPatternTypeAnnotation(BindingPatternWithoutTypeAnnotation<'a>) = 100, + AssignmentPatternLeft(AssignmentPatternWithoutLeft<'a>) = 101, + AssignmentPatternRight(AssignmentPatternWithoutRight<'a>) = 102, + ObjectPatternProperties(ObjectPatternWithoutProperties<'a>) = 103, + ObjectPatternRest(ObjectPatternWithoutRest<'a>) = 104, + BindingPropertyKey(BindingPropertyWithoutKey<'a>) = 105, + BindingPropertyValue(BindingPropertyWithoutValue<'a>) = 106, + ArrayPatternElements(ArrayPatternWithoutElements<'a>) = 107, + ArrayPatternRest(ArrayPatternWithoutRest<'a>) = 108, + BindingRestElementArgument(BindingRestElementWithoutArgument<'a>) = 109, + FunctionId(FunctionWithoutId<'a>) = 110, + FunctionThisParam(FunctionWithoutThisParam<'a>) = 111, + FunctionParams(FunctionWithoutParams<'a>) = 112, + FunctionBody(FunctionWithoutBody<'a>) = 113, + FunctionTypeParameters(FunctionWithoutTypeParameters<'a>) = 114, + FunctionReturnType(FunctionWithoutReturnType<'a>) = 115, + FormalParametersItems(FormalParametersWithoutItems<'a>) = 116, + FormalParametersRest(FormalParametersWithoutRest<'a>) = 117, + FormalParameterPattern(FormalParameterWithoutPattern<'a>) = 118, + FormalParameterDecorators(FormalParameterWithoutDecorators<'a>) = 119, + FunctionBodyDirectives(FunctionBodyWithoutDirectives<'a>) = 120, + FunctionBodyStatements(FunctionBodyWithoutStatements<'a>) = 121, + ArrowFunctionExpressionParams(ArrowFunctionExpressionWithoutParams<'a>) = 122, + ArrowFunctionExpressionBody(ArrowFunctionExpressionWithoutBody<'a>) = 123, + ArrowFunctionExpressionTypeParameters(ArrowFunctionExpressionWithoutTypeParameters<'a>) = 124, + ArrowFunctionExpressionReturnType(ArrowFunctionExpressionWithoutReturnType<'a>) = 125, + YieldExpressionArgument(YieldExpressionWithoutArgument<'a>) = 126, + ClassId(ClassWithoutId<'a>) = 127, + ClassSuperClass(ClassWithoutSuperClass<'a>) = 128, + ClassBody(ClassWithoutBody<'a>) = 129, + ClassTypeParameters(ClassWithoutTypeParameters<'a>) = 130, + ClassSuperTypeParameters(ClassWithoutSuperTypeParameters<'a>) = 131, + ClassImplements(ClassWithoutImplements<'a>) = 132, + ClassDecorators(ClassWithoutDecorators<'a>) = 133, + ClassBodyBody(ClassBodyWithoutBody<'a>) = 134, + MethodDefinitionKey(MethodDefinitionWithoutKey<'a>) = 135, + MethodDefinitionValue(MethodDefinitionWithoutValue<'a>) = 136, + MethodDefinitionDecorators(MethodDefinitionWithoutDecorators<'a>) = 137, + PropertyDefinitionKey(PropertyDefinitionWithoutKey<'a>) = 138, + PropertyDefinitionValue(PropertyDefinitionWithoutValue<'a>) = 139, + PropertyDefinitionTypeAnnotation(PropertyDefinitionWithoutTypeAnnotation<'a>) = 140, + PropertyDefinitionDecorators(PropertyDefinitionWithoutDecorators<'a>) = 141, + StaticBlockBody(StaticBlockWithoutBody<'a>) = 142, + AccessorPropertyKey(AccessorPropertyWithoutKey<'a>) = 143, + AccessorPropertyValue(AccessorPropertyWithoutValue<'a>) = 144, + AccessorPropertyDecorators(AccessorPropertyWithoutDecorators<'a>) = 145, + ImportExpressionSource(ImportExpressionWithoutSource<'a>) = 146, + ImportExpressionArguments(ImportExpressionWithoutArguments<'a>) = 147, + ImportDeclarationSpecifiers(ImportDeclarationWithoutSpecifiers<'a>) = 148, + ImportDeclarationSource(ImportDeclarationWithoutSource<'a>) = 149, + ImportDeclarationWithClause(ImportDeclarationWithoutWithClause<'a>) = 150, + ImportSpecifierImported(ImportSpecifierWithoutImported<'a>) = 151, + ImportSpecifierLocal(ImportSpecifierWithoutLocal<'a>) = 152, + ImportDefaultSpecifierLocal(ImportDefaultSpecifierWithoutLocal<'a>) = 153, + ImportNamespaceSpecifierLocal(ImportNamespaceSpecifierWithoutLocal<'a>) = 154, + WithClauseAttributesKeyword(WithClauseWithoutAttributesKeyword<'a>) = 155, + WithClauseWithEntries(WithClauseWithoutWithEntries<'a>) = 156, + ImportAttributeKey(ImportAttributeWithoutKey<'a>) = 157, + ImportAttributeValue(ImportAttributeWithoutValue<'a>) = 158, + ExportNamedDeclarationDeclaration(ExportNamedDeclarationWithoutDeclaration<'a>) = 159, + ExportNamedDeclarationSpecifiers(ExportNamedDeclarationWithoutSpecifiers<'a>) = 160, + ExportNamedDeclarationSource(ExportNamedDeclarationWithoutSource<'a>) = 161, + ExportNamedDeclarationWithClause(ExportNamedDeclarationWithoutWithClause<'a>) = 162, + ExportDefaultDeclarationDeclaration(ExportDefaultDeclarationWithoutDeclaration<'a>) = 163, + ExportDefaultDeclarationExported(ExportDefaultDeclarationWithoutExported<'a>) = 164, + ExportAllDeclarationExported(ExportAllDeclarationWithoutExported<'a>) = 165, + ExportAllDeclarationSource(ExportAllDeclarationWithoutSource<'a>) = 166, + ExportAllDeclarationWithClause(ExportAllDeclarationWithoutWithClause<'a>) = 167, + ExportSpecifierLocal(ExportSpecifierWithoutLocal<'a>) = 168, + ExportSpecifierExported(ExportSpecifierWithoutExported<'a>) = 169, + JSXElementOpeningElement(JSXElementWithoutOpeningElement<'a>) = 170, + JSXElementClosingElement(JSXElementWithoutClosingElement<'a>) = 171, + JSXElementChildren(JSXElementWithoutChildren<'a>) = 172, + JSXOpeningElementName(JSXOpeningElementWithoutName<'a>) = 173, + JSXOpeningElementAttributes(JSXOpeningElementWithoutAttributes<'a>) = 174, + JSXOpeningElementTypeParameters(JSXOpeningElementWithoutTypeParameters<'a>) = 175, + JSXClosingElementName(JSXClosingElementWithoutName<'a>) = 176, + JSXFragmentChildren(JSXFragmentWithoutChildren<'a>) = 177, + JSXNamespacedNameNamespace(JSXNamespacedNameWithoutNamespace<'a>) = 178, + JSXNamespacedNameProperty(JSXNamespacedNameWithoutProperty<'a>) = 179, + JSXMemberExpressionObject(JSXMemberExpressionWithoutObject<'a>) = 180, + JSXMemberExpressionProperty(JSXMemberExpressionWithoutProperty<'a>) = 181, + JSXExpressionContainerExpression(JSXExpressionContainerWithoutExpression<'a>) = 182, + JSXAttributeName(JSXAttributeWithoutName<'a>) = 183, + JSXAttributeValue(JSXAttributeWithoutValue<'a>) = 184, + JSXSpreadAttributeArgument(JSXSpreadAttributeWithoutArgument<'a>) = 185, + JSXSpreadChildExpression(JSXSpreadChildWithoutExpression<'a>) = 186, + TSThisParameterThis(TSThisParameterWithoutThis<'a>) = 187, + TSThisParameterTypeAnnotation(TSThisParameterWithoutTypeAnnotation<'a>) = 188, + TSEnumDeclarationId(TSEnumDeclarationWithoutId<'a>) = 189, + TSEnumDeclarationMembers(TSEnumDeclarationWithoutMembers<'a>) = 190, + TSEnumMemberId(TSEnumMemberWithoutId<'a>) = 191, + TSEnumMemberInitializer(TSEnumMemberWithoutInitializer<'a>) = 192, + TSTypeAnnotationTypeAnnotation(TSTypeAnnotationWithoutTypeAnnotation<'a>) = 193, + TSLiteralTypeLiteral(TSLiteralTypeWithoutLiteral<'a>) = 194, + TSConditionalTypeCheckType(TSConditionalTypeWithoutCheckType<'a>) = 195, + TSConditionalTypeExtendsType(TSConditionalTypeWithoutExtendsType<'a>) = 196, + TSConditionalTypeTrueType(TSConditionalTypeWithoutTrueType<'a>) = 197, + TSConditionalTypeFalseType(TSConditionalTypeWithoutFalseType<'a>) = 198, + TSUnionTypeTypes(TSUnionTypeWithoutTypes<'a>) = 199, + TSIntersectionTypeTypes(TSIntersectionTypeWithoutTypes<'a>) = 200, + TSTypeOperatorTypeAnnotation(TSTypeOperatorWithoutTypeAnnotation<'a>) = 201, + TSArrayTypeElementType(TSArrayTypeWithoutElementType<'a>) = 202, + TSIndexedAccessTypeObjectType(TSIndexedAccessTypeWithoutObjectType<'a>) = 203, + TSIndexedAccessTypeIndexType(TSIndexedAccessTypeWithoutIndexType<'a>) = 204, + TSTupleTypeElementTypes(TSTupleTypeWithoutElementTypes<'a>) = 205, + TSNamedTupleMemberElementType(TSNamedTupleMemberWithoutElementType<'a>) = 206, + TSNamedTupleMemberLabel(TSNamedTupleMemberWithoutLabel<'a>) = 207, + TSOptionalTypeTypeAnnotation(TSOptionalTypeWithoutTypeAnnotation<'a>) = 208, + TSRestTypeTypeAnnotation(TSRestTypeWithoutTypeAnnotation<'a>) = 209, + TSTypeReferenceTypeName(TSTypeReferenceWithoutTypeName<'a>) = 210, + TSTypeReferenceTypeParameters(TSTypeReferenceWithoutTypeParameters<'a>) = 211, + TSQualifiedNameLeft(TSQualifiedNameWithoutLeft<'a>) = 212, + TSQualifiedNameRight(TSQualifiedNameWithoutRight<'a>) = 213, + TSTypeParameterInstantiationParams(TSTypeParameterInstantiationWithoutParams<'a>) = 214, + TSTypeParameterName(TSTypeParameterWithoutName<'a>) = 215, + TSTypeParameterConstraint(TSTypeParameterWithoutConstraint<'a>) = 216, + TSTypeParameterDefault(TSTypeParameterWithoutDefault<'a>) = 217, + TSTypeParameterDeclarationParams(TSTypeParameterDeclarationWithoutParams<'a>) = 218, + TSTypeAliasDeclarationId(TSTypeAliasDeclarationWithoutId<'a>) = 219, + TSTypeAliasDeclarationTypeAnnotation(TSTypeAliasDeclarationWithoutTypeAnnotation<'a>) = 220, + TSTypeAliasDeclarationTypeParameters(TSTypeAliasDeclarationWithoutTypeParameters<'a>) = 221, + TSClassImplementsExpression(TSClassImplementsWithoutExpression<'a>) = 222, + TSClassImplementsTypeParameters(TSClassImplementsWithoutTypeParameters<'a>) = 223, + TSInterfaceDeclarationId(TSInterfaceDeclarationWithoutId<'a>) = 224, + TSInterfaceDeclarationBody(TSInterfaceDeclarationWithoutBody<'a>) = 225, + TSInterfaceDeclarationTypeParameters(TSInterfaceDeclarationWithoutTypeParameters<'a>) = 226, + TSInterfaceDeclarationExtends(TSInterfaceDeclarationWithoutExtends<'a>) = 227, + TSInterfaceBodyBody(TSInterfaceBodyWithoutBody<'a>) = 228, + TSPropertySignatureKey(TSPropertySignatureWithoutKey<'a>) = 229, + TSPropertySignatureTypeAnnotation(TSPropertySignatureWithoutTypeAnnotation<'a>) = 230, + TSIndexSignatureParameters(TSIndexSignatureWithoutParameters<'a>) = 231, + TSIndexSignatureTypeAnnotation(TSIndexSignatureWithoutTypeAnnotation<'a>) = 232, + TSCallSignatureDeclarationThisParam(TSCallSignatureDeclarationWithoutThisParam<'a>) = 233, + TSCallSignatureDeclarationParams(TSCallSignatureDeclarationWithoutParams<'a>) = 234, + TSCallSignatureDeclarationReturnType(TSCallSignatureDeclarationWithoutReturnType<'a>) = 235, + TSCallSignatureDeclarationTypeParameters(TSCallSignatureDeclarationWithoutTypeParameters<'a>) = + 236, + TSMethodSignatureKey(TSMethodSignatureWithoutKey<'a>) = 237, + TSMethodSignatureThisParam(TSMethodSignatureWithoutThisParam<'a>) = 238, + TSMethodSignatureParams(TSMethodSignatureWithoutParams<'a>) = 239, + TSMethodSignatureReturnType(TSMethodSignatureWithoutReturnType<'a>) = 240, + TSMethodSignatureTypeParameters(TSMethodSignatureWithoutTypeParameters<'a>) = 241, + TSConstructSignatureDeclarationParams(TSConstructSignatureDeclarationWithoutParams<'a>) = 242, + TSConstructSignatureDeclarationReturnType(TSConstructSignatureDeclarationWithoutReturnType<'a>) = + 243, + TSConstructSignatureDeclarationTypeParameters( + TSConstructSignatureDeclarationWithoutTypeParameters<'a>, + ) = 244, + TSIndexSignatureNameTypeAnnotation(TSIndexSignatureNameWithoutTypeAnnotation<'a>) = 245, + TSInterfaceHeritageExpression(TSInterfaceHeritageWithoutExpression<'a>) = 246, + TSInterfaceHeritageTypeParameters(TSInterfaceHeritageWithoutTypeParameters<'a>) = 247, + TSTypePredicateParameterName(TSTypePredicateWithoutParameterName<'a>) = 248, + TSTypePredicateTypeAnnotation(TSTypePredicateWithoutTypeAnnotation<'a>) = 249, + TSModuleDeclarationId(TSModuleDeclarationWithoutId<'a>) = 250, + TSModuleDeclarationBody(TSModuleDeclarationWithoutBody<'a>) = 251, + TSModuleBlockBody(TSModuleBlockWithoutBody<'a>) = 252, + TSTypeLiteralMembers(TSTypeLiteralWithoutMembers<'a>) = 253, + TSInferTypeTypeParameter(TSInferTypeWithoutTypeParameter<'a>) = 254, + TSTypeQueryExprName(TSTypeQueryWithoutExprName<'a>) = 255, + TSTypeQueryTypeParameters(TSTypeQueryWithoutTypeParameters<'a>) = 256, + TSImportTypeArgument(TSImportTypeWithoutArgument<'a>) = 257, + TSImportTypeQualifier(TSImportTypeWithoutQualifier<'a>) = 258, + TSImportTypeAttributes(TSImportTypeWithoutAttributes<'a>) = 259, + TSImportTypeTypeParameters(TSImportTypeWithoutTypeParameters<'a>) = 260, + TSImportAttributesElements(TSImportAttributesWithoutElements<'a>) = 261, + TSImportAttributeName(TSImportAttributeWithoutName<'a>) = 262, + TSImportAttributeValue(TSImportAttributeWithoutValue<'a>) = 263, + TSFunctionTypeThisParam(TSFunctionTypeWithoutThisParam<'a>) = 264, + TSFunctionTypeParams(TSFunctionTypeWithoutParams<'a>) = 265, + TSFunctionTypeReturnType(TSFunctionTypeWithoutReturnType<'a>) = 266, + TSFunctionTypeTypeParameters(TSFunctionTypeWithoutTypeParameters<'a>) = 267, + TSConstructorTypeParams(TSConstructorTypeWithoutParams<'a>) = 268, + TSConstructorTypeReturnType(TSConstructorTypeWithoutReturnType<'a>) = 269, + TSConstructorTypeTypeParameters(TSConstructorTypeWithoutTypeParameters<'a>) = 270, + TSMappedTypeTypeParameter(TSMappedTypeWithoutTypeParameter<'a>) = 271, + TSMappedTypeNameType(TSMappedTypeWithoutNameType<'a>) = 272, + TSMappedTypeTypeAnnotation(TSMappedTypeWithoutTypeAnnotation<'a>) = 273, + TSTemplateLiteralTypeQuasis(TSTemplateLiteralTypeWithoutQuasis<'a>) = 274, + TSTemplateLiteralTypeTypes(TSTemplateLiteralTypeWithoutTypes<'a>) = 275, + TSAsExpressionExpression(TSAsExpressionWithoutExpression<'a>) = 276, + TSAsExpressionTypeAnnotation(TSAsExpressionWithoutTypeAnnotation<'a>) = 277, + TSSatisfiesExpressionExpression(TSSatisfiesExpressionWithoutExpression<'a>) = 278, + TSSatisfiesExpressionTypeAnnotation(TSSatisfiesExpressionWithoutTypeAnnotation<'a>) = 279, + TSTypeAssertionExpression(TSTypeAssertionWithoutExpression<'a>) = 280, + TSTypeAssertionTypeAnnotation(TSTypeAssertionWithoutTypeAnnotation<'a>) = 281, + TSImportEqualsDeclarationId(TSImportEqualsDeclarationWithoutId<'a>) = 282, + TSImportEqualsDeclarationModuleReference(TSImportEqualsDeclarationWithoutModuleReference<'a>) = + 283, + TSExternalModuleReferenceExpression(TSExternalModuleReferenceWithoutExpression<'a>) = 284, + TSNonNullExpressionExpression(TSNonNullExpressionWithoutExpression<'a>) = 285, + DecoratorExpression(DecoratorWithoutExpression<'a>) = 286, + TSExportAssignmentExpression(TSExportAssignmentWithoutExpression<'a>) = 287, + TSNamespaceExportDeclarationId(TSNamespaceExportDeclarationWithoutId<'a>) = 288, + TSInstantiationExpressionExpression(TSInstantiationExpressionWithoutExpression<'a>) = 289, + TSInstantiationExpressionTypeParameters(TSInstantiationExpressionWithoutTypeParameters<'a>) = + 290, + JSDocNullableTypeTypeAnnotation(JSDocNullableTypeWithoutTypeAnnotation<'a>) = 291, +} + +impl<'a> Ancestor<'a> { + #[inline] + pub fn is_program(&self) -> bool { + matches!(self, Self::ProgramDirectives(_) | Self::ProgramHashbang(_) | Self::ProgramBody(_)) + } + + #[inline] + pub fn is_array_expression(&self) -> bool { + matches!(self, Self::ArrayExpressionElements(_)) + } + + #[inline] + pub fn is_object_expression(&self) -> bool { + matches!(self, Self::ObjectExpressionProperties(_)) + } + + #[inline] + pub fn is_object_property(&self) -> bool { + matches!( + self, + Self::ObjectPropertyKey(_) | Self::ObjectPropertyValue(_) | Self::ObjectPropertyInit(_) + ) + } + + #[inline] + pub fn is_template_literal(&self) -> bool { + matches!(self, Self::TemplateLiteralQuasis(_) | Self::TemplateLiteralExpressions(_)) + } + + #[inline] + pub fn is_tagged_template_expression(&self) -> bool { + matches!( + self, + Self::TaggedTemplateExpressionTag(_) + | Self::TaggedTemplateExpressionQuasi(_) + | Self::TaggedTemplateExpressionTypeParameters(_) + ) + } + + #[inline] + pub fn is_computed_member_expression(&self) -> bool { + matches!( + self, + Self::ComputedMemberExpressionObject(_) | Self::ComputedMemberExpressionExpression(_) + ) + } + + #[inline] + pub fn is_static_member_expression(&self) -> bool { + matches!( + self, + Self::StaticMemberExpressionObject(_) | Self::StaticMemberExpressionProperty(_) + ) + } + + #[inline] + pub fn is_private_field_expression(&self) -> bool { + matches!(self, Self::PrivateFieldExpressionObject(_) | Self::PrivateFieldExpressionField(_)) + } + + #[inline] + pub fn is_call_expression(&self) -> bool { + matches!( + self, + Self::CallExpressionCallee(_) + | Self::CallExpressionArguments(_) + | Self::CallExpressionTypeParameters(_) + ) + } + + #[inline] + pub fn is_new_expression(&self) -> bool { + matches!( + self, + Self::NewExpressionCallee(_) + | Self::NewExpressionArguments(_) + | Self::NewExpressionTypeParameters(_) + ) + } + + #[inline] + pub fn is_meta_property(&self) -> bool { + matches!(self, Self::MetaPropertyMeta(_) | Self::MetaPropertyProperty(_)) + } + + #[inline] + pub fn is_spread_element(&self) -> bool { + matches!(self, Self::SpreadElementArgument(_)) + } + + #[inline] + pub fn is_update_expression(&self) -> bool { + matches!(self, Self::UpdateExpressionArgument(_)) + } + + #[inline] + pub fn is_unary_expression(&self) -> bool { + matches!(self, Self::UnaryExpressionArgument(_)) + } + + #[inline] + pub fn is_binary_expression(&self) -> bool { + matches!(self, Self::BinaryExpressionLeft(_) | Self::BinaryExpressionRight(_)) + } + + #[inline] + pub fn is_private_in_expression(&self) -> bool { + matches!(self, Self::PrivateInExpressionLeft(_) | Self::PrivateInExpressionRight(_)) + } + + #[inline] + pub fn is_logical_expression(&self) -> bool { + matches!(self, Self::LogicalExpressionLeft(_) | Self::LogicalExpressionRight(_)) + } + + #[inline] + pub fn is_conditional_expression(&self) -> bool { + matches!( + self, + Self::ConditionalExpressionTest(_) + | Self::ConditionalExpressionConsequent(_) + | Self::ConditionalExpressionAlternate(_) + ) + } + + #[inline] + pub fn is_assignment_expression(&self) -> bool { + matches!(self, Self::AssignmentExpressionLeft(_) | Self::AssignmentExpressionRight(_)) + } + + #[inline] + pub fn is_array_assignment_target(&self) -> bool { + matches!(self, Self::ArrayAssignmentTargetElements(_) | Self::ArrayAssignmentTargetRest(_)) + } + + #[inline] + pub fn is_object_assignment_target(&self) -> bool { + matches!( + self, + Self::ObjectAssignmentTargetProperties(_) | Self::ObjectAssignmentTargetRest(_) + ) + } + + #[inline] + pub fn is_assignment_target_rest(&self) -> bool { + matches!(self, Self::AssignmentTargetRestTarget(_)) + } + + #[inline] + pub fn is_assignment_target_with_default(&self) -> bool { + matches!( + self, + Self::AssignmentTargetWithDefaultBinding(_) | Self::AssignmentTargetWithDefaultInit(_) + ) + } + + #[inline] + pub fn is_assignment_target_property_identifier(&self) -> bool { + matches!( + self, + Self::AssignmentTargetPropertyIdentifierBinding(_) + | Self::AssignmentTargetPropertyIdentifierInit(_) + ) + } + + #[inline] + pub fn is_assignment_target_property_property(&self) -> bool { + matches!( + self, + Self::AssignmentTargetPropertyPropertyName(_) + | Self::AssignmentTargetPropertyPropertyBinding(_) + ) + } + + #[inline] + pub fn is_sequence_expression(&self) -> bool { + matches!(self, Self::SequenceExpressionExpressions(_)) + } + + #[inline] + pub fn is_await_expression(&self) -> bool { + matches!(self, Self::AwaitExpressionArgument(_)) + } + + #[inline] + pub fn is_chain_expression(&self) -> bool { + matches!(self, Self::ChainExpressionExpression(_)) + } + + #[inline] + pub fn is_parenthesized_expression(&self) -> bool { + matches!(self, Self::ParenthesizedExpressionExpression(_)) + } + + #[inline] + pub fn is_directive(&self) -> bool { + matches!(self, Self::DirectiveExpression(_)) + } + + #[inline] + pub fn is_block_statement(&self) -> bool { + matches!(self, Self::BlockStatementBody(_)) + } + + #[inline] + pub fn is_variable_declaration(&self) -> bool { + matches!(self, Self::VariableDeclarationDeclarations(_)) + } + + #[inline] + pub fn is_variable_declarator(&self) -> bool { + matches!(self, Self::VariableDeclaratorId(_) | Self::VariableDeclaratorInit(_)) + } + + #[inline] + pub fn is_using_declaration(&self) -> bool { + matches!(self, Self::UsingDeclarationDeclarations(_)) + } + + #[inline] + pub fn is_expression_statement(&self) -> bool { + matches!(self, Self::ExpressionStatementExpression(_)) + } + + #[inline] + pub fn is_if_statement(&self) -> bool { + matches!( + self, + Self::IfStatementTest(_) + | Self::IfStatementConsequent(_) + | Self::IfStatementAlternate(_) + ) + } + + #[inline] + pub fn is_do_while_statement(&self) -> bool { + matches!(self, Self::DoWhileStatementBody(_) | Self::DoWhileStatementTest(_)) + } + + #[inline] + pub fn is_while_statement(&self) -> bool { + matches!(self, Self::WhileStatementTest(_) | Self::WhileStatementBody(_)) + } + + #[inline] + pub fn is_for_statement(&self) -> bool { + matches!( + self, + Self::ForStatementInit(_) + | Self::ForStatementTest(_) + | Self::ForStatementUpdate(_) + | Self::ForStatementBody(_) + ) + } + + #[inline] + pub fn is_for_in_statement(&self) -> bool { + matches!( + self, + Self::ForInStatementLeft(_) + | Self::ForInStatementRight(_) + | Self::ForInStatementBody(_) + ) + } + + #[inline] + pub fn is_for_of_statement(&self) -> bool { + matches!( + self, + Self::ForOfStatementLeft(_) + | Self::ForOfStatementRight(_) + | Self::ForOfStatementBody(_) + ) + } + + #[inline] + pub fn is_continue_statement(&self) -> bool { + matches!(self, Self::ContinueStatementLabel(_)) + } + + #[inline] + pub fn is_break_statement(&self) -> bool { + matches!(self, Self::BreakStatementLabel(_)) + } + + #[inline] + pub fn is_return_statement(&self) -> bool { + matches!(self, Self::ReturnStatementArgument(_)) + } + + #[inline] + pub fn is_with_statement(&self) -> bool { + matches!(self, Self::WithStatementObject(_) | Self::WithStatementBody(_)) + } + + #[inline] + pub fn is_switch_statement(&self) -> bool { + matches!(self, Self::SwitchStatementDiscriminant(_) | Self::SwitchStatementCases(_)) + } + + #[inline] + pub fn is_switch_case(&self) -> bool { + matches!(self, Self::SwitchCaseTest(_) | Self::SwitchCaseConsequent(_)) + } + + #[inline] + pub fn is_labeled_statement(&self) -> bool { + matches!(self, Self::LabeledStatementLabel(_) | Self::LabeledStatementBody(_)) + } + + #[inline] + pub fn is_throw_statement(&self) -> bool { + matches!(self, Self::ThrowStatementArgument(_)) + } + + #[inline] + pub fn is_try_statement(&self) -> bool { + matches!( + self, + Self::TryStatementBlock(_) + | Self::TryStatementHandler(_) + | Self::TryStatementFinalizer(_) + ) + } + + #[inline] + pub fn is_catch_clause(&self) -> bool { + matches!(self, Self::CatchClauseParam(_) | Self::CatchClauseBody(_)) + } + + #[inline] + pub fn is_catch_parameter(&self) -> bool { + matches!(self, Self::CatchParameterPattern(_)) + } + + #[inline] + pub fn is_binding_pattern(&self) -> bool { + matches!(self, Self::BindingPatternKind(_) | Self::BindingPatternTypeAnnotation(_)) + } + + #[inline] + pub fn is_assignment_pattern(&self) -> bool { + matches!(self, Self::AssignmentPatternLeft(_) | Self::AssignmentPatternRight(_)) + } + + #[inline] + pub fn is_object_pattern(&self) -> bool { + matches!(self, Self::ObjectPatternProperties(_) | Self::ObjectPatternRest(_)) + } + + #[inline] + pub fn is_binding_property(&self) -> bool { + matches!(self, Self::BindingPropertyKey(_) | Self::BindingPropertyValue(_)) + } + + #[inline] + pub fn is_array_pattern(&self) -> bool { + matches!(self, Self::ArrayPatternElements(_) | Self::ArrayPatternRest(_)) + } + + #[inline] + pub fn is_binding_rest_element(&self) -> bool { + matches!(self, Self::BindingRestElementArgument(_)) + } + + #[inline] + pub fn is_function(&self) -> bool { + matches!( + self, + Self::FunctionId(_) + | Self::FunctionThisParam(_) + | Self::FunctionParams(_) + | Self::FunctionBody(_) + | Self::FunctionTypeParameters(_) + | Self::FunctionReturnType(_) + ) + } + + #[inline] + pub fn is_formal_parameters(&self) -> bool { + matches!(self, Self::FormalParametersItems(_) | Self::FormalParametersRest(_)) + } + + #[inline] + pub fn is_formal_parameter(&self) -> bool { + matches!(self, Self::FormalParameterPattern(_) | Self::FormalParameterDecorators(_)) + } + + #[inline] + pub fn is_function_body(&self) -> bool { + matches!(self, Self::FunctionBodyDirectives(_) | Self::FunctionBodyStatements(_)) + } + + #[inline] + pub fn is_arrow_function_expression(&self) -> bool { + matches!( + self, + Self::ArrowFunctionExpressionParams(_) + | Self::ArrowFunctionExpressionBody(_) + | Self::ArrowFunctionExpressionTypeParameters(_) + | Self::ArrowFunctionExpressionReturnType(_) + ) + } + + #[inline] + pub fn is_yield_expression(&self) -> bool { + matches!(self, Self::YieldExpressionArgument(_)) + } + + #[inline] + pub fn is_class(&self) -> bool { + matches!( + self, + Self::ClassId(_) + | Self::ClassSuperClass(_) + | Self::ClassBody(_) + | Self::ClassTypeParameters(_) + | Self::ClassSuperTypeParameters(_) + | Self::ClassImplements(_) + | Self::ClassDecorators(_) + ) + } + + #[inline] + pub fn is_class_body(&self) -> bool { + matches!(self, Self::ClassBodyBody(_)) + } + + #[inline] + pub fn is_method_definition(&self) -> bool { + matches!( + self, + Self::MethodDefinitionKey(_) + | Self::MethodDefinitionValue(_) + | Self::MethodDefinitionDecorators(_) + ) + } + + #[inline] + pub fn is_property_definition(&self) -> bool { + matches!( + self, + Self::PropertyDefinitionKey(_) + | Self::PropertyDefinitionValue(_) + | Self::PropertyDefinitionTypeAnnotation(_) + | Self::PropertyDefinitionDecorators(_) + ) + } + + #[inline] + pub fn is_static_block(&self) -> bool { + matches!(self, Self::StaticBlockBody(_)) + } + + #[inline] + pub fn is_accessor_property(&self) -> bool { + matches!( + self, + Self::AccessorPropertyKey(_) + | Self::AccessorPropertyValue(_) + | Self::AccessorPropertyDecorators(_) + ) + } + + #[inline] + pub fn is_import_expression(&self) -> bool { + matches!(self, Self::ImportExpressionSource(_) | Self::ImportExpressionArguments(_)) + } + + #[inline] + pub fn is_import_declaration(&self) -> bool { + matches!( + self, + Self::ImportDeclarationSpecifiers(_) + | Self::ImportDeclarationSource(_) + | Self::ImportDeclarationWithClause(_) + ) + } + + #[inline] + pub fn is_import_specifier(&self) -> bool { + matches!(self, Self::ImportSpecifierImported(_) | Self::ImportSpecifierLocal(_)) + } + + #[inline] + pub fn is_import_default_specifier(&self) -> bool { + matches!(self, Self::ImportDefaultSpecifierLocal(_)) + } + + #[inline] + pub fn is_import_namespace_specifier(&self) -> bool { + matches!(self, Self::ImportNamespaceSpecifierLocal(_)) + } + + #[inline] + pub fn is_with_clause(&self) -> bool { + matches!(self, Self::WithClauseAttributesKeyword(_) | Self::WithClauseWithEntries(_)) + } + + #[inline] + pub fn is_import_attribute(&self) -> bool { + matches!(self, Self::ImportAttributeKey(_) | Self::ImportAttributeValue(_)) + } + + #[inline] + pub fn is_export_named_declaration(&self) -> bool { + matches!( + self, + Self::ExportNamedDeclarationDeclaration(_) + | Self::ExportNamedDeclarationSpecifiers(_) + | Self::ExportNamedDeclarationSource(_) + | Self::ExportNamedDeclarationWithClause(_) + ) + } + + #[inline] + pub fn is_export_default_declaration(&self) -> bool { + matches!( + self, + Self::ExportDefaultDeclarationDeclaration(_) + | Self::ExportDefaultDeclarationExported(_) + ) + } + + #[inline] + pub fn is_export_all_declaration(&self) -> bool { + matches!( + self, + Self::ExportAllDeclarationExported(_) + | Self::ExportAllDeclarationSource(_) + | Self::ExportAllDeclarationWithClause(_) + ) + } + + #[inline] + pub fn is_export_specifier(&self) -> bool { + matches!(self, Self::ExportSpecifierLocal(_) | Self::ExportSpecifierExported(_)) + } + + #[inline] + pub fn is_jsx_element(&self) -> bool { + matches!( + self, + Self::JSXElementOpeningElement(_) + | Self::JSXElementClosingElement(_) + | Self::JSXElementChildren(_) + ) + } + + #[inline] + pub fn is_jsx_opening_element(&self) -> bool { + matches!( + self, + Self::JSXOpeningElementName(_) + | Self::JSXOpeningElementAttributes(_) + | Self::JSXOpeningElementTypeParameters(_) + ) + } + + #[inline] + pub fn is_jsx_closing_element(&self) -> bool { + matches!(self, Self::JSXClosingElementName(_)) + } + + #[inline] + pub fn is_jsx_fragment(&self) -> bool { + matches!(self, Self::JSXFragmentChildren(_)) + } + + #[inline] + pub fn is_jsx_namespaced_name(&self) -> bool { + matches!(self, Self::JSXNamespacedNameNamespace(_) | Self::JSXNamespacedNameProperty(_)) + } + + #[inline] + pub fn is_jsx_member_expression(&self) -> bool { + matches!(self, Self::JSXMemberExpressionObject(_) | Self::JSXMemberExpressionProperty(_)) + } + + #[inline] + pub fn is_jsx_expression_container(&self) -> bool { + matches!(self, Self::JSXExpressionContainerExpression(_)) + } + + #[inline] + pub fn is_jsx_attribute(&self) -> bool { + matches!(self, Self::JSXAttributeName(_) | Self::JSXAttributeValue(_)) + } + + #[inline] + pub fn is_jsx_spread_attribute(&self) -> bool { + matches!(self, Self::JSXSpreadAttributeArgument(_)) + } + + #[inline] + pub fn is_jsx_spread_child(&self) -> bool { + matches!(self, Self::JSXSpreadChildExpression(_)) + } + + #[inline] + pub fn is_ts_this_parameter(&self) -> bool { + matches!(self, Self::TSThisParameterThis(_) | Self::TSThisParameterTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_enum_declaration(&self) -> bool { + matches!(self, Self::TSEnumDeclarationId(_) | Self::TSEnumDeclarationMembers(_)) + } + + #[inline] + pub fn is_ts_enum_member(&self) -> bool { + matches!(self, Self::TSEnumMemberId(_) | Self::TSEnumMemberInitializer(_)) + } + + #[inline] + pub fn is_ts_type_annotation(&self) -> bool { + matches!(self, Self::TSTypeAnnotationTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_literal_type(&self) -> bool { + matches!(self, Self::TSLiteralTypeLiteral(_)) + } + + #[inline] + pub fn is_ts_conditional_type(&self) -> bool { + matches!( + self, + Self::TSConditionalTypeCheckType(_) + | Self::TSConditionalTypeExtendsType(_) + | Self::TSConditionalTypeTrueType(_) + | Self::TSConditionalTypeFalseType(_) + ) + } + + #[inline] + pub fn is_ts_union_type(&self) -> bool { + matches!(self, Self::TSUnionTypeTypes(_)) + } + + #[inline] + pub fn is_ts_intersection_type(&self) -> bool { + matches!(self, Self::TSIntersectionTypeTypes(_)) + } + + #[inline] + pub fn is_ts_type_operator(&self) -> bool { + matches!(self, Self::TSTypeOperatorTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_array_type(&self) -> bool { + matches!(self, Self::TSArrayTypeElementType(_)) + } + + #[inline] + pub fn is_ts_indexed_access_type(&self) -> bool { + matches!( + self, + Self::TSIndexedAccessTypeObjectType(_) | Self::TSIndexedAccessTypeIndexType(_) + ) + } + + #[inline] + pub fn is_ts_tuple_type(&self) -> bool { + matches!(self, Self::TSTupleTypeElementTypes(_)) + } + + #[inline] + pub fn is_ts_named_tuple_member(&self) -> bool { + matches!(self, Self::TSNamedTupleMemberElementType(_) | Self::TSNamedTupleMemberLabel(_)) + } + + #[inline] + pub fn is_ts_optional_type(&self) -> bool { + matches!(self, Self::TSOptionalTypeTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_rest_type(&self) -> bool { + matches!(self, Self::TSRestTypeTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_type_reference(&self) -> bool { + matches!(self, Self::TSTypeReferenceTypeName(_) | Self::TSTypeReferenceTypeParameters(_)) + } + + #[inline] + pub fn is_ts_qualified_name(&self) -> bool { + matches!(self, Self::TSQualifiedNameLeft(_) | Self::TSQualifiedNameRight(_)) + } + + #[inline] + pub fn is_ts_type_parameter_instantiation(&self) -> bool { + matches!(self, Self::TSTypeParameterInstantiationParams(_)) + } + + #[inline] + pub fn is_ts_type_parameter(&self) -> bool { + matches!( + self, + Self::TSTypeParameterName(_) + | Self::TSTypeParameterConstraint(_) + | Self::TSTypeParameterDefault(_) + ) + } + + #[inline] + pub fn is_ts_type_parameter_declaration(&self) -> bool { + matches!(self, Self::TSTypeParameterDeclarationParams(_)) + } + + #[inline] + pub fn is_ts_type_alias_declaration(&self) -> bool { + matches!( + self, + Self::TSTypeAliasDeclarationId(_) + | Self::TSTypeAliasDeclarationTypeAnnotation(_) + | Self::TSTypeAliasDeclarationTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_class_implements(&self) -> bool { + matches!( + self, + Self::TSClassImplementsExpression(_) | Self::TSClassImplementsTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_interface_declaration(&self) -> bool { + matches!( + self, + Self::TSInterfaceDeclarationId(_) + | Self::TSInterfaceDeclarationBody(_) + | Self::TSInterfaceDeclarationTypeParameters(_) + | Self::TSInterfaceDeclarationExtends(_) + ) + } + + #[inline] + pub fn is_ts_interface_body(&self) -> bool { + matches!(self, Self::TSInterfaceBodyBody(_)) + } + + #[inline] + pub fn is_ts_property_signature(&self) -> bool { + matches!(self, Self::TSPropertySignatureKey(_) | Self::TSPropertySignatureTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_index_signature(&self) -> bool { + matches!( + self, + Self::TSIndexSignatureParameters(_) | Self::TSIndexSignatureTypeAnnotation(_) + ) + } + + #[inline] + pub fn is_ts_call_signature_declaration(&self) -> bool { + matches!( + self, + Self::TSCallSignatureDeclarationThisParam(_) + | Self::TSCallSignatureDeclarationParams(_) + | Self::TSCallSignatureDeclarationReturnType(_) + | Self::TSCallSignatureDeclarationTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_method_signature(&self) -> bool { + matches!( + self, + Self::TSMethodSignatureKey(_) + | Self::TSMethodSignatureThisParam(_) + | Self::TSMethodSignatureParams(_) + | Self::TSMethodSignatureReturnType(_) + | Self::TSMethodSignatureTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_construct_signature_declaration(&self) -> bool { + matches!( + self, + Self::TSConstructSignatureDeclarationParams(_) + | Self::TSConstructSignatureDeclarationReturnType(_) + | Self::TSConstructSignatureDeclarationTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_index_signature_name(&self) -> bool { + matches!(self, Self::TSIndexSignatureNameTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_interface_heritage(&self) -> bool { + matches!( + self, + Self::TSInterfaceHeritageExpression(_) | Self::TSInterfaceHeritageTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_type_predicate(&self) -> bool { + matches!( + self, + Self::TSTypePredicateParameterName(_) | Self::TSTypePredicateTypeAnnotation(_) + ) + } + + #[inline] + pub fn is_ts_module_declaration(&self) -> bool { + matches!(self, Self::TSModuleDeclarationId(_) | Self::TSModuleDeclarationBody(_)) + } + + #[inline] + pub fn is_ts_module_block(&self) -> bool { + matches!(self, Self::TSModuleBlockBody(_)) + } + + #[inline] + pub fn is_ts_type_literal(&self) -> bool { + matches!(self, Self::TSTypeLiteralMembers(_)) + } + + #[inline] + pub fn is_ts_infer_type(&self) -> bool { + matches!(self, Self::TSInferTypeTypeParameter(_)) + } + + #[inline] + pub fn is_ts_type_query(&self) -> bool { + matches!(self, Self::TSTypeQueryExprName(_) | Self::TSTypeQueryTypeParameters(_)) + } + + #[inline] + pub fn is_ts_import_type(&self) -> bool { + matches!( + self, + Self::TSImportTypeArgument(_) + | Self::TSImportTypeQualifier(_) + | Self::TSImportTypeAttributes(_) + | Self::TSImportTypeTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_import_attributes(&self) -> bool { + matches!(self, Self::TSImportAttributesElements(_)) + } + + #[inline] + pub fn is_ts_import_attribute(&self) -> bool { + matches!(self, Self::TSImportAttributeName(_) | Self::TSImportAttributeValue(_)) + } + + #[inline] + pub fn is_ts_function_type(&self) -> bool { + matches!( + self, + Self::TSFunctionTypeThisParam(_) + | Self::TSFunctionTypeParams(_) + | Self::TSFunctionTypeReturnType(_) + | Self::TSFunctionTypeTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_constructor_type(&self) -> bool { + matches!( + self, + Self::TSConstructorTypeParams(_) + | Self::TSConstructorTypeReturnType(_) + | Self::TSConstructorTypeTypeParameters(_) + ) + } + + #[inline] + pub fn is_ts_mapped_type(&self) -> bool { + matches!( + self, + Self::TSMappedTypeTypeParameter(_) + | Self::TSMappedTypeNameType(_) + | Self::TSMappedTypeTypeAnnotation(_) + ) + } + + #[inline] + pub fn is_ts_template_literal_type(&self) -> bool { + matches!(self, Self::TSTemplateLiteralTypeQuasis(_) | Self::TSTemplateLiteralTypeTypes(_)) + } + + #[inline] + pub fn is_ts_as_expression(&self) -> bool { + matches!(self, Self::TSAsExpressionExpression(_) | Self::TSAsExpressionTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_satisfies_expression(&self) -> bool { + matches!( + self, + Self::TSSatisfiesExpressionExpression(_) | Self::TSSatisfiesExpressionTypeAnnotation(_) + ) + } + + #[inline] + pub fn is_ts_type_assertion(&self) -> bool { + matches!(self, Self::TSTypeAssertionExpression(_) | Self::TSTypeAssertionTypeAnnotation(_)) + } + + #[inline] + pub fn is_ts_import_equals_declaration(&self) -> bool { + matches!( + self, + Self::TSImportEqualsDeclarationId(_) + | Self::TSImportEqualsDeclarationModuleReference(_) + ) + } + + #[inline] + pub fn is_ts_external_module_reference(&self) -> bool { + matches!(self, Self::TSExternalModuleReferenceExpression(_)) + } + + #[inline] + pub fn is_ts_non_null_expression(&self) -> bool { + matches!(self, Self::TSNonNullExpressionExpression(_)) + } + + #[inline] + pub fn is_decorator(&self) -> bool { + matches!(self, Self::DecoratorExpression(_)) + } + + #[inline] + pub fn is_ts_export_assignment(&self) -> bool { + matches!(self, Self::TSExportAssignmentExpression(_)) + } + + #[inline] + pub fn is_ts_namespace_export_declaration(&self) -> bool { + matches!(self, Self::TSNamespaceExportDeclarationId(_)) + } + + #[inline] + pub fn is_ts_instantiation_expression(&self) -> bool { + matches!( + self, + Self::TSInstantiationExpressionExpression(_) + | Self::TSInstantiationExpressionTypeParameters(_) + ) + } + + #[inline] + pub fn is_js_doc_nullable_type(&self) -> bool { + matches!(self, Self::JSDocNullableTypeTypeAnnotation(_)) + } + + #[inline] + pub fn is_via_statement(&self) -> bool { + matches!( + self, + Self::ProgramBody(_) + | Self::BlockStatementBody(_) + | Self::IfStatementConsequent(_) + | Self::IfStatementAlternate(_) + | Self::DoWhileStatementBody(_) + | Self::WhileStatementBody(_) + | Self::ForStatementBody(_) + | Self::ForInStatementBody(_) + | Self::ForOfStatementBody(_) + | Self::WithStatementBody(_) + | Self::SwitchCaseConsequent(_) + | Self::LabeledStatementBody(_) + | Self::FunctionBodyStatements(_) + | Self::StaticBlockBody(_) + | Self::TSModuleBlockBody(_) + ) + } + + #[inline] + pub fn is_via_array_expression_element(&self) -> bool { + matches!(self, Self::ArrayExpressionElements(_)) + } + + #[inline] + pub fn is_via_object_property_kind(&self) -> bool { + matches!(self, Self::ObjectExpressionProperties(_)) + } + + #[inline] + pub fn is_via_property_key(&self) -> bool { + matches!( + self, + Self::ObjectPropertyKey(_) + | Self::AssignmentTargetPropertyPropertyName(_) + | Self::BindingPropertyKey(_) + | Self::MethodDefinitionKey(_) + | Self::PropertyDefinitionKey(_) + | Self::AccessorPropertyKey(_) + | Self::TSPropertySignatureKey(_) + | Self::TSMethodSignatureKey(_) + ) + } + + #[inline] + pub fn is_via_expression(&self) -> bool { + matches!( + self, + Self::ObjectPropertyValue(_) + | Self::ObjectPropertyInit(_) + | Self::TemplateLiteralExpressions(_) + | Self::TaggedTemplateExpressionTag(_) + | Self::ComputedMemberExpressionObject(_) + | Self::ComputedMemberExpressionExpression(_) + | Self::StaticMemberExpressionObject(_) + | Self::PrivateFieldExpressionObject(_) + | Self::CallExpressionCallee(_) + | Self::NewExpressionCallee(_) + | Self::SpreadElementArgument(_) + | Self::UnaryExpressionArgument(_) + | Self::BinaryExpressionLeft(_) + | Self::BinaryExpressionRight(_) + | Self::PrivateInExpressionRight(_) + | Self::LogicalExpressionLeft(_) + | Self::LogicalExpressionRight(_) + | Self::ConditionalExpressionTest(_) + | Self::ConditionalExpressionConsequent(_) + | Self::ConditionalExpressionAlternate(_) + | Self::AssignmentExpressionRight(_) + | Self::AssignmentTargetWithDefaultInit(_) + | Self::AssignmentTargetPropertyIdentifierInit(_) + | Self::SequenceExpressionExpressions(_) + | Self::AwaitExpressionArgument(_) + | Self::ParenthesizedExpressionExpression(_) + | Self::VariableDeclaratorInit(_) + | Self::ExpressionStatementExpression(_) + | Self::IfStatementTest(_) + | Self::DoWhileStatementTest(_) + | Self::WhileStatementTest(_) + | Self::ForStatementTest(_) + | Self::ForStatementUpdate(_) + | Self::ForInStatementRight(_) + | Self::ForOfStatementRight(_) + | Self::ReturnStatementArgument(_) + | Self::WithStatementObject(_) + | Self::SwitchStatementDiscriminant(_) + | Self::SwitchCaseTest(_) + | Self::ThrowStatementArgument(_) + | Self::AssignmentPatternRight(_) + | Self::YieldExpressionArgument(_) + | Self::ClassSuperClass(_) + | Self::PropertyDefinitionValue(_) + | Self::AccessorPropertyValue(_) + | Self::ImportExpressionSource(_) + | Self::ImportExpressionArguments(_) + | Self::JSXSpreadAttributeArgument(_) + | Self::JSXSpreadChildExpression(_) + | Self::TSEnumMemberInitializer(_) + | Self::TSInterfaceHeritageExpression(_) + | Self::TSImportAttributeValue(_) + | Self::TSAsExpressionExpression(_) + | Self::TSSatisfiesExpressionExpression(_) + | Self::TSTypeAssertionExpression(_) + | Self::TSNonNullExpressionExpression(_) + | Self::DecoratorExpression(_) + | Self::TSExportAssignmentExpression(_) + | Self::TSInstantiationExpressionExpression(_) + ) + } + + #[inline] + pub fn is_via_argument(&self) -> bool { + matches!(self, Self::CallExpressionArguments(_) | Self::NewExpressionArguments(_)) + } + + #[inline] + pub fn is_via_simple_assignment_target(&self) -> bool { + matches!(self, Self::UpdateExpressionArgument(_)) + } + + #[inline] + pub fn is_via_assignment_target(&self) -> bool { + matches!( + self, + Self::AssignmentExpressionLeft(_) + | Self::AssignmentTargetRestTarget(_) + | Self::AssignmentTargetWithDefaultBinding(_) + ) + } + + #[inline] + pub fn is_via_assignment_target_maybe_default(&self) -> bool { + matches!( + self, + Self::ArrayAssignmentTargetElements(_) + | Self::AssignmentTargetPropertyPropertyBinding(_) + ) + } + + #[inline] + pub fn is_via_assignment_target_property(&self) -> bool { + matches!(self, Self::ObjectAssignmentTargetProperties(_)) + } + + #[inline] + pub fn is_via_chain_element(&self) -> bool { + matches!(self, Self::ChainExpressionExpression(_)) + } + + #[inline] + pub fn is_via_for_statement_init(&self) -> bool { + matches!(self, Self::ForStatementInit(_)) + } + + #[inline] + pub fn is_via_for_statement_left(&self) -> bool { + matches!(self, Self::ForInStatementLeft(_) | Self::ForOfStatementLeft(_)) + } + + #[inline] + pub fn is_via_binding_pattern_kind(&self) -> bool { + matches!(self, Self::BindingPatternKind(_)) + } + + #[inline] + pub fn is_via_class_element(&self) -> bool { + matches!(self, Self::ClassBodyBody(_)) + } + + #[inline] + pub fn is_via_import_declaration_specifier(&self) -> bool { + matches!(self, Self::ImportDeclarationSpecifiers(_)) + } + + #[inline] + pub fn is_via_module_export_name(&self) -> bool { + matches!( + self, + Self::ImportSpecifierImported(_) + | Self::ExportDefaultDeclarationExported(_) + | Self::ExportAllDeclarationExported(_) + | Self::ExportSpecifierLocal(_) + | Self::ExportSpecifierExported(_) + ) + } + + #[inline] + pub fn is_via_import_attribute_key(&self) -> bool { + matches!(self, Self::ImportAttributeKey(_)) + } + + #[inline] + pub fn is_via_declaration(&self) -> bool { + matches!(self, Self::ExportNamedDeclarationDeclaration(_)) + } + + #[inline] + pub fn is_via_export_default_declaration_kind(&self) -> bool { + matches!(self, Self::ExportDefaultDeclarationDeclaration(_)) + } + + #[inline] + pub fn is_via_jsx_child(&self) -> bool { + matches!(self, Self::JSXElementChildren(_) | Self::JSXFragmentChildren(_)) + } + + #[inline] + pub fn is_via_jsx_element_name(&self) -> bool { + matches!(self, Self::JSXOpeningElementName(_) | Self::JSXClosingElementName(_)) + } + + #[inline] + pub fn is_via_jsx_attribute_item(&self) -> bool { + matches!(self, Self::JSXOpeningElementAttributes(_)) + } + + #[inline] + pub fn is_via_jsx_member_expression_object(&self) -> bool { + matches!(self, Self::JSXMemberExpressionObject(_)) + } + + #[inline] + pub fn is_via_jsx_expression(&self) -> bool { + matches!(self, Self::JSXExpressionContainerExpression(_)) + } + + #[inline] + pub fn is_via_jsx_attribute_name(&self) -> bool { + matches!(self, Self::JSXAttributeName(_)) + } + + #[inline] + pub fn is_via_jsx_attribute_value(&self) -> bool { + matches!(self, Self::JSXAttributeValue(_)) + } + + #[inline] + pub fn is_via_ts_enum_member_name(&self) -> bool { + matches!(self, Self::TSEnumMemberId(_)) + } + + #[inline] + pub fn is_via_ts_type(&self) -> bool { + matches!( + self, + Self::TSTypeAnnotationTypeAnnotation(_) + | Self::TSConditionalTypeCheckType(_) + | Self::TSConditionalTypeExtendsType(_) + | Self::TSConditionalTypeTrueType(_) + | Self::TSConditionalTypeFalseType(_) + | Self::TSUnionTypeTypes(_) + | Self::TSIntersectionTypeTypes(_) + | Self::TSTypeOperatorTypeAnnotation(_) + | Self::TSArrayTypeElementType(_) + | Self::TSIndexedAccessTypeObjectType(_) + | Self::TSIndexedAccessTypeIndexType(_) + | Self::TSNamedTupleMemberElementType(_) + | Self::TSOptionalTypeTypeAnnotation(_) + | Self::TSRestTypeTypeAnnotation(_) + | Self::TSTypeParameterInstantiationParams(_) + | Self::TSTypeParameterConstraint(_) + | Self::TSTypeParameterDefault(_) + | Self::TSTypeAliasDeclarationTypeAnnotation(_) + | Self::TSImportTypeArgument(_) + | Self::TSMappedTypeNameType(_) + | Self::TSMappedTypeTypeAnnotation(_) + | Self::TSTemplateLiteralTypeTypes(_) + | Self::TSAsExpressionTypeAnnotation(_) + | Self::TSSatisfiesExpressionTypeAnnotation(_) + | Self::TSTypeAssertionTypeAnnotation(_) + | Self::JSDocNullableTypeTypeAnnotation(_) + ) + } + + #[inline] + pub fn is_via_ts_literal(&self) -> bool { + matches!(self, Self::TSLiteralTypeLiteral(_)) + } + + #[inline] + pub fn is_via_ts_tuple_element(&self) -> bool { + matches!(self, Self::TSTupleTypeElementTypes(_)) + } + + #[inline] + pub fn is_via_ts_type_name(&self) -> bool { + matches!( + self, + Self::TSTypeReferenceTypeName(_) + | Self::TSQualifiedNameLeft(_) + | Self::TSClassImplementsExpression(_) + | Self::TSImportTypeQualifier(_) + ) + } + + #[inline] + pub fn is_via_ts_signature(&self) -> bool { + matches!(self, Self::TSInterfaceBodyBody(_) | Self::TSTypeLiteralMembers(_)) + } + + #[inline] + pub fn is_via_ts_type_predicate_name(&self) -> bool { + matches!(self, Self::TSTypePredicateParameterName(_)) + } + + #[inline] + pub fn is_via_ts_module_declaration_name(&self) -> bool { + matches!(self, Self::TSModuleDeclarationId(_)) + } + + #[inline] + pub fn is_via_ts_module_declaration_body(&self) -> bool { + matches!(self, Self::TSModuleDeclarationBody(_)) + } + + #[inline] + pub fn is_via_ts_type_query_expr_name(&self) -> bool { + matches!(self, Self::TSTypeQueryExprName(_)) + } + + #[inline] + pub fn is_via_ts_import_attribute_name(&self) -> bool { + matches!(self, Self::TSImportAttributeName(_)) + } + + #[inline] + pub fn is_via_ts_module_reference(&self) -> bool { + matches!(self, Self::TSImportEqualsDeclarationModuleReference(_)) + } +} + +pub(crate) const OFFSET_PROGRAM_SPAN: usize = offset_of!(Program, span); +pub(crate) const OFFSET_PROGRAM_SOURCE_TYPE: usize = offset_of!(Program, source_type); +pub(crate) const OFFSET_PROGRAM_DIRECTIVES: usize = offset_of!(Program, directives); +pub(crate) const OFFSET_PROGRAM_HASHBANG: usize = offset_of!(Program, hashbang); +pub(crate) const OFFSET_PROGRAM_BODY: usize = offset_of!(Program, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ProgramWithoutDirectives<'a>(pub(crate) *const Program<'a>); + +impl<'a> ProgramWithoutDirectives<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SPAN) as *const Span) } + } + + #[inline] + pub fn source_type(&self) -> &SourceType { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SOURCE_TYPE) as *const SourceType) } + } + + #[inline] + pub fn hashbang(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_HASHBANG) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Vec<'a, Statement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_BODY) as *const Vec<'a, Statement<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ProgramWithoutHashbang<'a>(pub(crate) *const Program<'a>); + +impl<'a> ProgramWithoutHashbang<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SPAN) as *const Span) } + } + + #[inline] + pub fn source_type(&self) -> &SourceType { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SOURCE_TYPE) as *const SourceType) } + } + + #[inline] + pub fn directives(&self) -> &Vec<'a, Directive<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_DIRECTIVES) + as *const Vec<'a, Directive<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Vec<'a, Statement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_BODY) as *const Vec<'a, Statement<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ProgramWithoutBody<'a>(pub(crate) *const Program<'a>); + +impl<'a> ProgramWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SPAN) as *const Span) } + } + + #[inline] + pub fn source_type(&self) -> &SourceType { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROGRAM_SOURCE_TYPE) as *const SourceType) } + } + + #[inline] + pub fn directives(&self) -> &Vec<'a, Directive<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_DIRECTIVES) + as *const Vec<'a, Directive<'a>>) + } + } + + #[inline] + pub fn hashbang(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROGRAM_HASHBANG) as *const Option>) + } + } +} + +pub(crate) const OFFSET_ARRAY_EXPRESSION_SPAN: usize = offset_of!(ArrayExpression, span); +pub(crate) const OFFSET_ARRAY_EXPRESSION_ELEMENTS: usize = offset_of!(ArrayExpression, elements); +pub(crate) const OFFSET_ARRAY_EXPRESSION_TRAILING_COMMA: usize = + offset_of!(ArrayExpression, trailing_comma); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrayExpressionWithoutElements<'a>(pub(crate) *const ArrayExpression<'a>); + +impl<'a> ArrayExpressionWithoutElements<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ARRAY_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn trailing_comma(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_EXPRESSION_TRAILING_COMMA) + as *const Option) + } + } +} + +pub(crate) const OFFSET_OBJECT_EXPRESSION_SPAN: usize = offset_of!(ObjectExpression, span); +pub(crate) const OFFSET_OBJECT_EXPRESSION_PROPERTIES: usize = + offset_of!(ObjectExpression, properties); +pub(crate) const OFFSET_OBJECT_EXPRESSION_TRAILING_COMMA: usize = + offset_of!(ObjectExpression, trailing_comma); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectExpressionWithoutProperties<'a>(pub(crate) *const ObjectExpression<'a>); + +impl<'a> ObjectExpressionWithoutProperties<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn trailing_comma(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_EXPRESSION_TRAILING_COMMA) + as *const Option) + } + } +} + +pub(crate) const OFFSET_OBJECT_PROPERTY_SPAN: usize = offset_of!(ObjectProperty, span); +pub(crate) const OFFSET_OBJECT_PROPERTY_KIND: usize = offset_of!(ObjectProperty, kind); +pub(crate) const OFFSET_OBJECT_PROPERTY_KEY: usize = offset_of!(ObjectProperty, key); +pub(crate) const OFFSET_OBJECT_PROPERTY_VALUE: usize = offset_of!(ObjectProperty, value); +pub(crate) const OFFSET_OBJECT_PROPERTY_INIT: usize = offset_of!(ObjectProperty, init); +pub(crate) const OFFSET_OBJECT_PROPERTY_METHOD: usize = offset_of!(ObjectProperty, method); +pub(crate) const OFFSET_OBJECT_PROPERTY_SHORTHAND: usize = offset_of!(ObjectProperty, shorthand); +pub(crate) const OFFSET_OBJECT_PROPERTY_COMPUTED: usize = offset_of!(ObjectProperty, computed); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectPropertyWithoutKey<'a>(pub(crate) *const ObjectProperty<'a>); + +impl<'a> ObjectPropertyWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &PropertyKind { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KIND) as *const PropertyKind) } + } + + #[inline] + pub fn value(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_VALUE) as *const Expression<'a>) + } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_INIT) + as *const Option>) + } + } + + #[inline] + pub fn method(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } + } + + #[inline] + pub fn shorthand(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SHORTHAND) as *const bool) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_COMPUTED) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectPropertyWithoutValue<'a>(pub(crate) *const ObjectProperty<'a>); + +impl<'a> ObjectPropertyWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &PropertyKind { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KIND) as *const PropertyKind) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_INIT) + as *const Option>) + } + } + + #[inline] + pub fn method(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } + } + + #[inline] + pub fn shorthand(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SHORTHAND) as *const bool) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_COMPUTED) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectPropertyWithoutInit<'a>(pub(crate) *const ObjectProperty<'a>); + +impl<'a> ObjectPropertyWithoutInit<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &PropertyKind { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KIND) as *const PropertyKind) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn value(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_VALUE) as *const Expression<'a>) + } + } + + #[inline] + pub fn method(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_METHOD) as *const bool) } + } + + #[inline] + pub fn shorthand(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_SHORTHAND) as *const bool) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PROPERTY_COMPUTED) as *const bool) } + } +} + +pub(crate) const OFFSET_TEMPLATE_LITERAL_SPAN: usize = offset_of!(TemplateLiteral, span); +pub(crate) const OFFSET_TEMPLATE_LITERAL_QUASIS: usize = offset_of!(TemplateLiteral, quasis); +pub(crate) const OFFSET_TEMPLATE_LITERAL_EXPRESSIONS: usize = + offset_of!(TemplateLiteral, expressions); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TemplateLiteralWithoutQuasis<'a>(pub(crate) *const TemplateLiteral<'a>); + +impl<'a> TemplateLiteralWithoutQuasis<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TEMPLATE_LITERAL_SPAN) as *const Span) } + } + + #[inline] + pub fn expressions(&self) -> &Vec<'a, Expression<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TEMPLATE_LITERAL_EXPRESSIONS) + as *const Vec<'a, Expression<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TemplateLiteralWithoutExpressions<'a>(pub(crate) *const TemplateLiteral<'a>); + +impl<'a> TemplateLiteralWithoutExpressions<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TEMPLATE_LITERAL_SPAN) as *const Span) } + } + + #[inline] + pub fn quasis(&self) -> &Vec<'a, TemplateElement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TEMPLATE_LITERAL_QUASIS) + as *const Vec<'a, TemplateElement<'a>>) + } + } +} + +pub(crate) const OFFSET_TAGGED_TEMPLATE_EXPRESSION_SPAN: usize = + offset_of!(TaggedTemplateExpression, span); +pub(crate) const OFFSET_TAGGED_TEMPLATE_EXPRESSION_TAG: usize = + offset_of!(TaggedTemplateExpression, tag); +pub(crate) const OFFSET_TAGGED_TEMPLATE_EXPRESSION_QUASI: usize = + offset_of!(TaggedTemplateExpression, quasi); +pub(crate) const OFFSET_TAGGED_TEMPLATE_EXPRESSION_TYPE_PARAMETERS: usize = + offset_of!(TaggedTemplateExpression, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TaggedTemplateExpressionWithoutTag<'a>(pub(crate) *const TaggedTemplateExpression<'a>); + +impl<'a> TaggedTemplateExpressionWithoutTag<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn quasi(&self) -> &TemplateLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_QUASI) + as *const TemplateLiteral<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TaggedTemplateExpressionWithoutQuasi<'a>(pub(crate) *const TaggedTemplateExpression<'a>); + +impl<'a> TaggedTemplateExpressionWithoutQuasi<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn tag(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_TAG) + as *const Expression<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TaggedTemplateExpressionWithoutTypeParameters<'a>( + pub(crate) *const TaggedTemplateExpression<'a>, +); + +impl<'a> TaggedTemplateExpressionWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn tag(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_TAG) + as *const Expression<'a>) + } + } + + #[inline] + pub fn quasi(&self) -> &TemplateLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TAGGED_TEMPLATE_EXPRESSION_QUASI) + as *const TemplateLiteral<'a>) + } + } +} + +pub(crate) const OFFSET_COMPUTED_MEMBER_EXPRESSION_SPAN: usize = + offset_of!(ComputedMemberExpression, span); +pub(crate) const OFFSET_COMPUTED_MEMBER_EXPRESSION_OBJECT: usize = + offset_of!(ComputedMemberExpression, object); +pub(crate) const OFFSET_COMPUTED_MEMBER_EXPRESSION_EXPRESSION: usize = + offset_of!(ComputedMemberExpression, expression); +pub(crate) const OFFSET_COMPUTED_MEMBER_EXPRESSION_OPTIONAL: usize = + offset_of!(ComputedMemberExpression, optional); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ComputedMemberExpressionWithoutObject<'a>( + pub(crate) *const ComputedMemberExpression<'a>, +); + +impl<'a> ComputedMemberExpressionWithoutObject<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_EXPRESSION) + as *const Expression<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ComputedMemberExpressionWithoutExpression<'a>( + pub(crate) *const ComputedMemberExpression<'a>, +); + +impl<'a> ComputedMemberExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn object(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_OBJECT) + as *const Expression<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_COMPUTED_MEMBER_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +pub(crate) const OFFSET_STATIC_MEMBER_EXPRESSION_SPAN: usize = + offset_of!(StaticMemberExpression, span); +pub(crate) const OFFSET_STATIC_MEMBER_EXPRESSION_OBJECT: usize = + offset_of!(StaticMemberExpression, object); +pub(crate) const OFFSET_STATIC_MEMBER_EXPRESSION_PROPERTY: usize = + offset_of!(StaticMemberExpression, property); +pub(crate) const OFFSET_STATIC_MEMBER_EXPRESSION_OPTIONAL: usize = + offset_of!(StaticMemberExpression, optional); + +#[repr(transparent)] +#[derive(Debug)] +pub struct StaticMemberExpressionWithoutObject<'a>(pub(crate) *const StaticMemberExpression<'a>); + +impl<'a> StaticMemberExpressionWithoutObject<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn property(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_PROPERTY) + as *const IdentifierName<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct StaticMemberExpressionWithoutProperty<'a>(pub(crate) *const StaticMemberExpression<'a>); + +impl<'a> StaticMemberExpressionWithoutProperty<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn object(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_OBJECT) + as *const Expression<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_STATIC_MEMBER_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +pub(crate) const OFFSET_PRIVATE_FIELD_EXPRESSION_SPAN: usize = + offset_of!(PrivateFieldExpression, span); +pub(crate) const OFFSET_PRIVATE_FIELD_EXPRESSION_OBJECT: usize = + offset_of!(PrivateFieldExpression, object); +pub(crate) const OFFSET_PRIVATE_FIELD_EXPRESSION_FIELD: usize = + offset_of!(PrivateFieldExpression, field); +pub(crate) const OFFSET_PRIVATE_FIELD_EXPRESSION_OPTIONAL: usize = + offset_of!(PrivateFieldExpression, optional); + +#[repr(transparent)] +#[derive(Debug)] +pub struct PrivateFieldExpressionWithoutObject<'a>(pub(crate) *const PrivateFieldExpression<'a>); + +impl<'a> PrivateFieldExpressionWithoutObject<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn field(&self) -> &PrivateIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_FIELD) + as *const PrivateIdentifier<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct PrivateFieldExpressionWithoutField<'a>(pub(crate) *const PrivateFieldExpression<'a>); + +impl<'a> PrivateFieldExpressionWithoutField<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn object(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_OBJECT) + as *const Expression<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_FIELD_EXPRESSION_OPTIONAL) as *const bool) + } + } +} + +pub(crate) const OFFSET_CALL_EXPRESSION_SPAN: usize = offset_of!(CallExpression, span); +pub(crate) const OFFSET_CALL_EXPRESSION_CALLEE: usize = offset_of!(CallExpression, callee); +pub(crate) const OFFSET_CALL_EXPRESSION_ARGUMENTS: usize = offset_of!(CallExpression, arguments); +pub(crate) const OFFSET_CALL_EXPRESSION_OPTIONAL: usize = offset_of!(CallExpression, optional); +pub(crate) const OFFSET_CALL_EXPRESSION_TYPE_PARAMETERS: usize = + offset_of!(CallExpression, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct CallExpressionWithoutCallee<'a>(pub(crate) *const CallExpression<'a>); + +impl<'a> CallExpressionWithoutCallee<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn arguments(&self) -> &Vec<'a, Argument<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_ARGUMENTS) + as *const Vec<'a, Argument<'a>>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct CallExpressionWithoutArguments<'a>(pub(crate) *const CallExpression<'a>); + +impl<'a> CallExpressionWithoutArguments<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn callee(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_CALLEE) as *const Expression<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct CallExpressionWithoutTypeParameters<'a>(pub(crate) *const CallExpression<'a>); + +impl<'a> CallExpressionWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn callee(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_CALLEE) as *const Expression<'a>) + } + } + + #[inline] + pub fn arguments(&self) -> &Vec<'a, Argument<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_ARGUMENTS) + as *const Vec<'a, Argument<'a>>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_CALL_EXPRESSION_OPTIONAL) as *const bool) } + } +} + +pub(crate) const OFFSET_NEW_EXPRESSION_SPAN: usize = offset_of!(NewExpression, span); +pub(crate) const OFFSET_NEW_EXPRESSION_CALLEE: usize = offset_of!(NewExpression, callee); +pub(crate) const OFFSET_NEW_EXPRESSION_ARGUMENTS: usize = offset_of!(NewExpression, arguments); +pub(crate) const OFFSET_NEW_EXPRESSION_TYPE_PARAMETERS: usize = + offset_of!(NewExpression, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct NewExpressionWithoutCallee<'a>(pub(crate) *const NewExpression<'a>); + +impl<'a> NewExpressionWithoutCallee<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn arguments(&self) -> &Vec<'a, Argument<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_ARGUMENTS) + as *const Vec<'a, Argument<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct NewExpressionWithoutArguments<'a>(pub(crate) *const NewExpression<'a>); + +impl<'a> NewExpressionWithoutArguments<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn callee(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_CALLEE) as *const Expression<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct NewExpressionWithoutTypeParameters<'a>(pub(crate) *const NewExpression<'a>); + +impl<'a> NewExpressionWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn callee(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_CALLEE) as *const Expression<'a>) + } + } + + #[inline] + pub fn arguments(&self) -> &Vec<'a, Argument<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_NEW_EXPRESSION_ARGUMENTS) + as *const Vec<'a, Argument<'a>>) + } + } +} + +pub(crate) const OFFSET_META_PROPERTY_SPAN: usize = offset_of!(MetaProperty, span); +pub(crate) const OFFSET_META_PROPERTY_META: usize = offset_of!(MetaProperty, meta); +pub(crate) const OFFSET_META_PROPERTY_PROPERTY: usize = offset_of!(MetaProperty, property); + +#[repr(transparent)] +#[derive(Debug)] +pub struct MetaPropertyWithoutMeta<'a>(pub(crate) *const MetaProperty<'a>); + +impl<'a> MetaPropertyWithoutMeta<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_META_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn property(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_META_PROPERTY_PROPERTY) + as *const IdentifierName<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct MetaPropertyWithoutProperty<'a>(pub(crate) *const MetaProperty<'a>); + +impl<'a> MetaPropertyWithoutProperty<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_META_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn meta(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_META_PROPERTY_META) as *const IdentifierName<'a>) + } + } +} + +pub(crate) const OFFSET_SPREAD_ELEMENT_SPAN: usize = offset_of!(SpreadElement, span); +pub(crate) const OFFSET_SPREAD_ELEMENT_ARGUMENT: usize = offset_of!(SpreadElement, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct SpreadElementWithoutArgument<'a>(pub(crate) *const SpreadElement<'a>); + +impl<'a> SpreadElementWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SPREAD_ELEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_UPDATE_EXPRESSION_SPAN: usize = offset_of!(UpdateExpression, span); +pub(crate) const OFFSET_UPDATE_EXPRESSION_OPERATOR: usize = offset_of!(UpdateExpression, operator); +pub(crate) const OFFSET_UPDATE_EXPRESSION_PREFIX: usize = offset_of!(UpdateExpression, prefix); +pub(crate) const OFFSET_UPDATE_EXPRESSION_ARGUMENT: usize = offset_of!(UpdateExpression, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct UpdateExpressionWithoutArgument<'a>(pub(crate) *const UpdateExpression<'a>); + +impl<'a> UpdateExpressionWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_UPDATE_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &UpdateOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_UPDATE_EXPRESSION_OPERATOR) + as *const UpdateOperator) + } + } + + #[inline] + pub fn prefix(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_UPDATE_EXPRESSION_PREFIX) as *const bool) } + } +} + +pub(crate) const OFFSET_UNARY_EXPRESSION_SPAN: usize = offset_of!(UnaryExpression, span); +pub(crate) const OFFSET_UNARY_EXPRESSION_OPERATOR: usize = offset_of!(UnaryExpression, operator); +pub(crate) const OFFSET_UNARY_EXPRESSION_ARGUMENT: usize = offset_of!(UnaryExpression, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct UnaryExpressionWithoutArgument<'a>(pub(crate) *const UnaryExpression<'a>); + +impl<'a> UnaryExpressionWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_UNARY_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &UnaryOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_UNARY_EXPRESSION_OPERATOR) as *const UnaryOperator) + } + } +} + +pub(crate) const OFFSET_BINARY_EXPRESSION_SPAN: usize = offset_of!(BinaryExpression, span); +pub(crate) const OFFSET_BINARY_EXPRESSION_LEFT: usize = offset_of!(BinaryExpression, left); +pub(crate) const OFFSET_BINARY_EXPRESSION_OPERATOR: usize = offset_of!(BinaryExpression, operator); +pub(crate) const OFFSET_BINARY_EXPRESSION_RIGHT: usize = offset_of!(BinaryExpression, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BinaryExpressionWithoutLeft<'a>(pub(crate) *const BinaryExpression<'a>); + +impl<'a> BinaryExpressionWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &BinaryOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_OPERATOR) + as *const BinaryOperator) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_RIGHT) as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct BinaryExpressionWithoutRight<'a>(pub(crate) *const BinaryExpression<'a>); + +impl<'a> BinaryExpressionWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_LEFT) as *const Expression<'a>) + } + } + + #[inline] + pub fn operator(&self) -> &BinaryOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINARY_EXPRESSION_OPERATOR) + as *const BinaryOperator) + } + } +} + +pub(crate) const OFFSET_PRIVATE_IN_EXPRESSION_SPAN: usize = offset_of!(PrivateInExpression, span); +pub(crate) const OFFSET_PRIVATE_IN_EXPRESSION_LEFT: usize = offset_of!(PrivateInExpression, left); +pub(crate) const OFFSET_PRIVATE_IN_EXPRESSION_OPERATOR: usize = + offset_of!(PrivateInExpression, operator); +pub(crate) const OFFSET_PRIVATE_IN_EXPRESSION_RIGHT: usize = offset_of!(PrivateInExpression, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct PrivateInExpressionWithoutLeft<'a>(pub(crate) *const PrivateInExpression<'a>); + +impl<'a> PrivateInExpressionWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &BinaryOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_OPERATOR) + as *const BinaryOperator) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_RIGHT) + as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct PrivateInExpressionWithoutRight<'a>(pub(crate) *const PrivateInExpression<'a>); + +impl<'a> PrivateInExpressionWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &PrivateIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_LEFT) + as *const PrivateIdentifier<'a>) + } + } + + #[inline] + pub fn operator(&self) -> &BinaryOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PRIVATE_IN_EXPRESSION_OPERATOR) + as *const BinaryOperator) + } + } +} + +pub(crate) const OFFSET_LOGICAL_EXPRESSION_SPAN: usize = offset_of!(LogicalExpression, span); +pub(crate) const OFFSET_LOGICAL_EXPRESSION_LEFT: usize = offset_of!(LogicalExpression, left); +pub(crate) const OFFSET_LOGICAL_EXPRESSION_OPERATOR: usize = + offset_of!(LogicalExpression, operator); +pub(crate) const OFFSET_LOGICAL_EXPRESSION_RIGHT: usize = offset_of!(LogicalExpression, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct LogicalExpressionWithoutLeft<'a>(pub(crate) *const LogicalExpression<'a>); + +impl<'a> LogicalExpressionWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &LogicalOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_OPERATOR) + as *const LogicalOperator) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_RIGHT) as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct LogicalExpressionWithoutRight<'a>(pub(crate) *const LogicalExpression<'a>); + +impl<'a> LogicalExpressionWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_LEFT) as *const Expression<'a>) + } + } + + #[inline] + pub fn operator(&self) -> &LogicalOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LOGICAL_EXPRESSION_OPERATOR) + as *const LogicalOperator) + } + } +} + +pub(crate) const OFFSET_CONDITIONAL_EXPRESSION_SPAN: usize = + offset_of!(ConditionalExpression, span); +pub(crate) const OFFSET_CONDITIONAL_EXPRESSION_TEST: usize = + offset_of!(ConditionalExpression, test); +pub(crate) const OFFSET_CONDITIONAL_EXPRESSION_CONSEQUENT: usize = + offset_of!(ConditionalExpression, consequent); +pub(crate) const OFFSET_CONDITIONAL_EXPRESSION_ALTERNATE: usize = + offset_of!(ConditionalExpression, alternate); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ConditionalExpressionWithoutTest<'a>(pub(crate) *const ConditionalExpression<'a>); + +impl<'a> ConditionalExpressionWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn consequent(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_CONSEQUENT) + as *const Expression<'a>) + } + } + + #[inline] + pub fn alternate(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_ALTERNATE) + as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ConditionalExpressionWithoutConsequent<'a>(pub(crate) *const ConditionalExpression<'a>); + +impl<'a> ConditionalExpressionWithoutConsequent<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_TEST) + as *const Expression<'a>) + } + } + + #[inline] + pub fn alternate(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_ALTERNATE) + as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ConditionalExpressionWithoutAlternate<'a>(pub(crate) *const ConditionalExpression<'a>); + +impl<'a> ConditionalExpressionWithoutAlternate<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_TEST) + as *const Expression<'a>) + } + } + + #[inline] + pub fn consequent(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CONDITIONAL_EXPRESSION_CONSEQUENT) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_EXPRESSION_SPAN: usize = offset_of!(AssignmentExpression, span); +pub(crate) const OFFSET_ASSIGNMENT_EXPRESSION_OPERATOR: usize = + offset_of!(AssignmentExpression, operator); +pub(crate) const OFFSET_ASSIGNMENT_EXPRESSION_LEFT: usize = offset_of!(AssignmentExpression, left); +pub(crate) const OFFSET_ASSIGNMENT_EXPRESSION_RIGHT: usize = + offset_of!(AssignmentExpression, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentExpressionWithoutLeft<'a>(pub(crate) *const AssignmentExpression<'a>); + +impl<'a> AssignmentExpressionWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &AssignmentOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_OPERATOR) + as *const AssignmentOperator) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_RIGHT) + as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentExpressionWithoutRight<'a>(pub(crate) *const AssignmentExpression<'a>); + +impl<'a> AssignmentExpressionWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &AssignmentOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_OPERATOR) + as *const AssignmentOperator) + } + } + + #[inline] + pub fn left(&self) -> &AssignmentTarget<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_EXPRESSION_LEFT) + as *const AssignmentTarget<'a>) + } + } +} + +pub(crate) const OFFSET_ARRAY_ASSIGNMENT_TARGET_SPAN: usize = + offset_of!(ArrayAssignmentTarget, span); +pub(crate) const OFFSET_ARRAY_ASSIGNMENT_TARGET_ELEMENTS: usize = + offset_of!(ArrayAssignmentTarget, elements); +pub(crate) const OFFSET_ARRAY_ASSIGNMENT_TARGET_REST: usize = + offset_of!(ArrayAssignmentTarget, rest); +pub(crate) const OFFSET_ARRAY_ASSIGNMENT_TARGET_TRAILING_COMMA: usize = + offset_of!(ArrayAssignmentTarget, trailing_comma); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrayAssignmentTargetWithoutElements<'a>(pub(crate) *const ArrayAssignmentTarget<'a>); + +impl<'a> ArrayAssignmentTargetWithoutElements<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_SPAN) as *const Span) } + } + + #[inline] + pub fn rest(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_REST) + as *const Option>) + } + } + + #[inline] + pub fn trailing_comma(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_TRAILING_COMMA) + as *const Option) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrayAssignmentTargetWithoutRest<'a>(pub(crate) *const ArrayAssignmentTarget<'a>); + +impl<'a> ArrayAssignmentTargetWithoutRest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_SPAN) as *const Span) } + } + + #[inline] + pub fn elements(&self) -> &Vec<'a, Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_ELEMENTS) + as *const Vec<'a, Option>>) + } + } + + #[inline] + pub fn trailing_comma(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_ASSIGNMENT_TARGET_TRAILING_COMMA) + as *const Option) + } + } +} + +pub(crate) const OFFSET_OBJECT_ASSIGNMENT_TARGET_SPAN: usize = + offset_of!(ObjectAssignmentTarget, span); +pub(crate) const OFFSET_OBJECT_ASSIGNMENT_TARGET_PROPERTIES: usize = + offset_of!(ObjectAssignmentTarget, properties); +pub(crate) const OFFSET_OBJECT_ASSIGNMENT_TARGET_REST: usize = + offset_of!(ObjectAssignmentTarget, rest); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectAssignmentTargetWithoutProperties<'a>( + pub(crate) *const ObjectAssignmentTarget<'a>, +); + +impl<'a> ObjectAssignmentTargetWithoutProperties<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_ASSIGNMENT_TARGET_SPAN) as *const Span) + } + } + + #[inline] + pub fn rest(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_ASSIGNMENT_TARGET_REST) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectAssignmentTargetWithoutRest<'a>(pub(crate) *const ObjectAssignmentTarget<'a>); + +impl<'a> ObjectAssignmentTargetWithoutRest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_ASSIGNMENT_TARGET_SPAN) as *const Span) + } + } + + #[inline] + pub fn properties(&self) -> &Vec<'a, AssignmentTargetProperty<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_ASSIGNMENT_TARGET_PROPERTIES) + as *const Vec<'a, AssignmentTargetProperty<'a>>) + } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_TARGET_REST_SPAN: usize = offset_of!(AssignmentTargetRest, span); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_REST_TARGET: usize = + offset_of!(AssignmentTargetRest, target); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetRestWithoutTarget<'a>(pub(crate) *const AssignmentTargetRest<'a>); + +impl<'a> AssignmentTargetRestWithoutTarget<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_REST_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_SPAN: usize = + offset_of!(AssignmentTargetWithDefault, span); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_BINDING: usize = + offset_of!(AssignmentTargetWithDefault, binding); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_INIT: usize = + offset_of!(AssignmentTargetWithDefault, init); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetWithDefaultWithoutBinding<'a>( + pub(crate) *const AssignmentTargetWithDefault<'a>, +); + +impl<'a> AssignmentTargetWithDefaultWithoutBinding<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_SPAN) as *const Span) + } + } + + #[inline] + pub fn init(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_INIT) + as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetWithDefaultWithoutInit<'a>( + pub(crate) *const AssignmentTargetWithDefault<'a>, +); + +impl<'a> AssignmentTargetWithDefaultWithoutInit<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_SPAN) as *const Span) + } + } + + #[inline] + pub fn binding(&self) -> &AssignmentTarget<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_BINDING) + as *const AssignmentTarget<'a>) + } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_SPAN: usize = + offset_of!(AssignmentTargetPropertyIdentifier, span); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_BINDING: usize = + offset_of!(AssignmentTargetPropertyIdentifier, binding); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_INIT: usize = + offset_of!(AssignmentTargetPropertyIdentifier, init); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetPropertyIdentifierWithoutBinding<'a>( + pub(crate) *const AssignmentTargetPropertyIdentifier<'a>, +); + +impl<'a> AssignmentTargetPropertyIdentifierWithoutBinding<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_SPAN) + as *const Span) + } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_INIT) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetPropertyIdentifierWithoutInit<'a>( + pub(crate) *const AssignmentTargetPropertyIdentifier<'a>, +); + +impl<'a> AssignmentTargetPropertyIdentifierWithoutInit<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_SPAN) + as *const Span) + } + } + + #[inline] + pub fn binding(&self) -> &IdentifierReference<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_BINDING) + as *const IdentifierReference<'a>) + } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_SPAN: usize = + offset_of!(AssignmentTargetPropertyProperty, span); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_NAME: usize = + offset_of!(AssignmentTargetPropertyProperty, name); +pub(crate) const OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_BINDING: usize = + offset_of!(AssignmentTargetPropertyProperty, binding); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetPropertyPropertyWithoutName<'a>( + pub(crate) *const AssignmentTargetPropertyProperty<'a>, +); + +impl<'a> AssignmentTargetPropertyPropertyWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_SPAN) + as *const Span) + } + } + + #[inline] + pub fn binding(&self) -> &AssignmentTargetMaybeDefault<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_BINDING) + as *const AssignmentTargetMaybeDefault<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentTargetPropertyPropertyWithoutBinding<'a>( + pub(crate) *const AssignmentTargetPropertyProperty<'a>, +); + +impl<'a> AssignmentTargetPropertyPropertyWithoutBinding<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_SPAN) + as *const Span) + } + } + + #[inline] + pub fn name(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_NAME) + as *const PropertyKey<'a>) + } + } +} + +pub(crate) const OFFSET_SEQUENCE_EXPRESSION_SPAN: usize = offset_of!(SequenceExpression, span); +pub(crate) const OFFSET_SEQUENCE_EXPRESSION_EXPRESSIONS: usize = + offset_of!(SequenceExpression, expressions); + +#[repr(transparent)] +#[derive(Debug)] +pub struct SequenceExpressionWithoutExpressions<'a>(pub(crate) *const SequenceExpression<'a>); + +impl<'a> SequenceExpressionWithoutExpressions<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SEQUENCE_EXPRESSION_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_AWAIT_EXPRESSION_SPAN: usize = offset_of!(AwaitExpression, span); +pub(crate) const OFFSET_AWAIT_EXPRESSION_ARGUMENT: usize = offset_of!(AwaitExpression, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AwaitExpressionWithoutArgument<'a>(pub(crate) *const AwaitExpression<'a>); + +impl<'a> AwaitExpressionWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_AWAIT_EXPRESSION_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_CHAIN_EXPRESSION_SPAN: usize = offset_of!(ChainExpression, span); +pub(crate) const OFFSET_CHAIN_EXPRESSION_EXPRESSION: usize = + offset_of!(ChainExpression, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ChainExpressionWithoutExpression<'a>(pub(crate) *const ChainExpression<'a>); + +impl<'a> ChainExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CHAIN_EXPRESSION_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_PARENTHESIZED_EXPRESSION_SPAN: usize = + offset_of!(ParenthesizedExpression, span); +pub(crate) const OFFSET_PARENTHESIZED_EXPRESSION_EXPRESSION: usize = + offset_of!(ParenthesizedExpression, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ParenthesizedExpressionWithoutExpression<'a>( + pub(crate) *const ParenthesizedExpression<'a>, +); + +impl<'a> ParenthesizedExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PARENTHESIZED_EXPRESSION_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_DIRECTIVE_SPAN: usize = offset_of!(Directive, span); +pub(crate) const OFFSET_DIRECTIVE_EXPRESSION: usize = offset_of!(Directive, expression); +pub(crate) const OFFSET_DIRECTIVE_DIRECTIVE: usize = offset_of!(Directive, directive); + +#[repr(transparent)] +#[derive(Debug)] +pub struct DirectiveWithoutExpression<'a>(pub(crate) *const Directive<'a>); + +impl<'a> DirectiveWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_DIRECTIVE_SPAN) as *const Span) } + } + + #[inline] + pub fn directive(&self) -> &Atom<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_DIRECTIVE_DIRECTIVE) as *const Atom<'a>) } + } +} + +pub(crate) const OFFSET_BLOCK_STATEMENT_SPAN: usize = offset_of!(BlockStatement, span); +pub(crate) const OFFSET_BLOCK_STATEMENT_BODY: usize = offset_of!(BlockStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BlockStatementWithoutBody<'a>(pub(crate) *const BlockStatement<'a>); + +impl<'a> BlockStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BLOCK_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_VARIABLE_DECLARATION_SPAN: usize = offset_of!(VariableDeclaration, span); +pub(crate) const OFFSET_VARIABLE_DECLARATION_KIND: usize = offset_of!(VariableDeclaration, kind); +pub(crate) const OFFSET_VARIABLE_DECLARATION_DECLARATIONS: usize = + offset_of!(VariableDeclaration, declarations); +pub(crate) const OFFSET_VARIABLE_DECLARATION_MODIFIERS: usize = + offset_of!(VariableDeclaration, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct VariableDeclarationWithoutDeclarations<'a>(pub(crate) *const VariableDeclaration<'a>); + +impl<'a> VariableDeclarationWithoutDeclarations<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &VariableDeclarationKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATION_KIND) + as *const VariableDeclarationKind) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +pub(crate) const OFFSET_VARIABLE_DECLARATOR_SPAN: usize = offset_of!(VariableDeclarator, span); +pub(crate) const OFFSET_VARIABLE_DECLARATOR_KIND: usize = offset_of!(VariableDeclarator, kind); +pub(crate) const OFFSET_VARIABLE_DECLARATOR_ID: usize = offset_of!(VariableDeclarator, id); +pub(crate) const OFFSET_VARIABLE_DECLARATOR_INIT: usize = offset_of!(VariableDeclarator, init); +pub(crate) const OFFSET_VARIABLE_DECLARATOR_DEFINITE: usize = + offset_of!(VariableDeclarator, definite); + +#[repr(transparent)] +#[derive(Debug)] +pub struct VariableDeclaratorWithoutId<'a>(pub(crate) *const VariableDeclarator<'a>); + +impl<'a> VariableDeclaratorWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &VariableDeclarationKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_KIND) + as *const VariableDeclarationKind) + } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_INIT) + as *const Option>) + } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_DEFINITE) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct VariableDeclaratorWithoutInit<'a>(pub(crate) *const VariableDeclarator<'a>); + +impl<'a> VariableDeclaratorWithoutInit<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &VariableDeclarationKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_KIND) + as *const VariableDeclarationKind) + } + } + + #[inline] + pub fn id(&self) -> &BindingPattern<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_ID) + as *const BindingPattern<'a>) + } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_VARIABLE_DECLARATOR_DEFINITE) as *const bool) } + } +} + +pub(crate) const OFFSET_USING_DECLARATION_SPAN: usize = offset_of!(UsingDeclaration, span); +pub(crate) const OFFSET_USING_DECLARATION_IS_AWAIT: usize = offset_of!(UsingDeclaration, is_await); +pub(crate) const OFFSET_USING_DECLARATION_DECLARATIONS: usize = + offset_of!(UsingDeclaration, declarations); + +#[repr(transparent)] +#[derive(Debug)] +pub struct UsingDeclarationWithoutDeclarations<'a>(pub(crate) *const UsingDeclaration<'a>); + +impl<'a> UsingDeclarationWithoutDeclarations<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_USING_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn is_await(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_USING_DECLARATION_IS_AWAIT) as *const bool) } + } +} + +pub(crate) const OFFSET_EXPRESSION_STATEMENT_SPAN: usize = offset_of!(ExpressionStatement, span); +pub(crate) const OFFSET_EXPRESSION_STATEMENT_EXPRESSION: usize = + offset_of!(ExpressionStatement, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExpressionStatementWithoutExpression<'a>(pub(crate) *const ExpressionStatement<'a>); + +impl<'a> ExpressionStatementWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPRESSION_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_IF_STATEMENT_SPAN: usize = offset_of!(IfStatement, span); +pub(crate) const OFFSET_IF_STATEMENT_TEST: usize = offset_of!(IfStatement, test); +pub(crate) const OFFSET_IF_STATEMENT_CONSEQUENT: usize = offset_of!(IfStatement, consequent); +pub(crate) const OFFSET_IF_STATEMENT_ALTERNATE: usize = offset_of!(IfStatement, alternate); + +#[repr(transparent)] +#[derive(Debug)] +pub struct IfStatementWithoutTest<'a>(pub(crate) *const IfStatement<'a>); + +impl<'a> IfStatementWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn consequent(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_CONSEQUENT) as *const Statement<'a>) + } + } + + #[inline] + pub fn alternate(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_ALTERNATE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct IfStatementWithoutConsequent<'a>(pub(crate) *const IfStatement<'a>); + +impl<'a> IfStatementWithoutConsequent<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_TEST) as *const Expression<'a>) } + } + + #[inline] + pub fn alternate(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_ALTERNATE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct IfStatementWithoutAlternate<'a>(pub(crate) *const IfStatement<'a>); + +impl<'a> IfStatementWithoutAlternate<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_TEST) as *const Expression<'a>) } + } + + #[inline] + pub fn consequent(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IF_STATEMENT_CONSEQUENT) as *const Statement<'a>) + } + } +} + +pub(crate) const OFFSET_DO_WHILE_STATEMENT_SPAN: usize = offset_of!(DoWhileStatement, span); +pub(crate) const OFFSET_DO_WHILE_STATEMENT_BODY: usize = offset_of!(DoWhileStatement, body); +pub(crate) const OFFSET_DO_WHILE_STATEMENT_TEST: usize = offset_of!(DoWhileStatement, test); + +#[repr(transparent)] +#[derive(Debug)] +pub struct DoWhileStatementWithoutBody<'a>(pub(crate) *const DoWhileStatement<'a>); + +impl<'a> DoWhileStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_DO_WHILE_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_DO_WHILE_STATEMENT_TEST) as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct DoWhileStatementWithoutTest<'a>(pub(crate) *const DoWhileStatement<'a>); + +impl<'a> DoWhileStatementWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_DO_WHILE_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_DO_WHILE_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +pub(crate) const OFFSET_WHILE_STATEMENT_SPAN: usize = offset_of!(WhileStatement, span); +pub(crate) const OFFSET_WHILE_STATEMENT_TEST: usize = offset_of!(WhileStatement, test); +pub(crate) const OFFSET_WHILE_STATEMENT_BODY: usize = offset_of!(WhileStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct WhileStatementWithoutTest<'a>(pub(crate) *const WhileStatement<'a>); + +impl<'a> WhileStatementWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WHILE_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_WHILE_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct WhileStatementWithoutBody<'a>(pub(crate) *const WhileStatement<'a>); + +impl<'a> WhileStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WHILE_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_WHILE_STATEMENT_TEST) as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_FOR_STATEMENT_SPAN: usize = offset_of!(ForStatement, span); +pub(crate) const OFFSET_FOR_STATEMENT_INIT: usize = offset_of!(ForStatement, init); +pub(crate) const OFFSET_FOR_STATEMENT_TEST: usize = offset_of!(ForStatement, test); +pub(crate) const OFFSET_FOR_STATEMENT_UPDATE: usize = offset_of!(ForStatement, update); +pub(crate) const OFFSET_FOR_STATEMENT_BODY: usize = offset_of!(ForStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForStatementWithoutInit<'a>(pub(crate) *const ForStatement<'a>); + +impl<'a> ForStatementWithoutInit<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_TEST) + as *const Option>) + } + } + + #[inline] + pub fn update(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_UPDATE) + as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_BODY) as *const Statement<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForStatementWithoutTest<'a>(pub(crate) *const ForStatement<'a>); + +impl<'a> ForStatementWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_INIT) + as *const Option>) + } + } + + #[inline] + pub fn update(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_UPDATE) + as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_BODY) as *const Statement<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForStatementWithoutUpdate<'a>(pub(crate) *const ForStatement<'a>); + +impl<'a> ForStatementWithoutUpdate<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_INIT) + as *const Option>) + } + } + + #[inline] + pub fn test(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_TEST) + as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_BODY) as *const Statement<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForStatementWithoutBody<'a>(pub(crate) *const ForStatement<'a>); + +impl<'a> ForStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn init(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_INIT) + as *const Option>) + } + } + + #[inline] + pub fn test(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_TEST) + as *const Option>) + } + } + + #[inline] + pub fn update(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_STATEMENT_UPDATE) + as *const Option>) + } + } +} + +pub(crate) const OFFSET_FOR_IN_STATEMENT_SPAN: usize = offset_of!(ForInStatement, span); +pub(crate) const OFFSET_FOR_IN_STATEMENT_LEFT: usize = offset_of!(ForInStatement, left); +pub(crate) const OFFSET_FOR_IN_STATEMENT_RIGHT: usize = offset_of!(ForInStatement, right); +pub(crate) const OFFSET_FOR_IN_STATEMENT_BODY: usize = offset_of!(ForInStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForInStatementWithoutLeft<'a>(pub(crate) *const ForInStatement<'a>); + +impl<'a> ForInStatementWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_RIGHT) as *const Expression<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForInStatementWithoutRight<'a>(pub(crate) *const ForInStatement<'a>); + +impl<'a> ForInStatementWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &ForStatementLeft<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_LEFT) + as *const ForStatementLeft<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForInStatementWithoutBody<'a>(pub(crate) *const ForInStatement<'a>); + +impl<'a> ForInStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &ForStatementLeft<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_LEFT) + as *const ForStatementLeft<'a>) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_IN_STATEMENT_RIGHT) as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_FOR_OF_STATEMENT_SPAN: usize = offset_of!(ForOfStatement, span); +pub(crate) const OFFSET_FOR_OF_STATEMENT_AWAIT: usize = offset_of!(ForOfStatement, r#await); +pub(crate) const OFFSET_FOR_OF_STATEMENT_LEFT: usize = offset_of!(ForOfStatement, left); +pub(crate) const OFFSET_FOR_OF_STATEMENT_RIGHT: usize = offset_of!(ForOfStatement, right); +pub(crate) const OFFSET_FOR_OF_STATEMENT_BODY: usize = offset_of!(ForOfStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForOfStatementWithoutLeft<'a>(pub(crate) *const ForOfStatement<'a>); + +impl<'a> ForOfStatementWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn r#await(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_AWAIT) as *const bool) } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_RIGHT) as *const Expression<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForOfStatementWithoutRight<'a>(pub(crate) *const ForOfStatement<'a>); + +impl<'a> ForOfStatementWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn r#await(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_AWAIT) as *const bool) } + } + + #[inline] + pub fn left(&self) -> &ForStatementLeft<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_LEFT) + as *const ForStatementLeft<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ForOfStatementWithoutBody<'a>(pub(crate) *const ForOfStatement<'a>); + +impl<'a> ForOfStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn r#await(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_AWAIT) as *const bool) } + } + + #[inline] + pub fn left(&self) -> &ForStatementLeft<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_LEFT) + as *const ForStatementLeft<'a>) + } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FOR_OF_STATEMENT_RIGHT) as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_CONTINUE_STATEMENT_SPAN: usize = offset_of!(ContinueStatement, span); +pub(crate) const OFFSET_CONTINUE_STATEMENT_LABEL: usize = offset_of!(ContinueStatement, label); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ContinueStatementWithoutLabel<'a>(pub(crate) *const ContinueStatement<'a>); + +impl<'a> ContinueStatementWithoutLabel<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CONTINUE_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_BREAK_STATEMENT_SPAN: usize = offset_of!(BreakStatement, span); +pub(crate) const OFFSET_BREAK_STATEMENT_LABEL: usize = offset_of!(BreakStatement, label); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BreakStatementWithoutLabel<'a>(pub(crate) *const BreakStatement<'a>); + +impl<'a> BreakStatementWithoutLabel<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BREAK_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_RETURN_STATEMENT_SPAN: usize = offset_of!(ReturnStatement, span); +pub(crate) const OFFSET_RETURN_STATEMENT_ARGUMENT: usize = offset_of!(ReturnStatement, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ReturnStatementWithoutArgument<'a>(pub(crate) *const ReturnStatement<'a>); + +impl<'a> ReturnStatementWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_RETURN_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_WITH_STATEMENT_SPAN: usize = offset_of!(WithStatement, span); +pub(crate) const OFFSET_WITH_STATEMENT_OBJECT: usize = offset_of!(WithStatement, object); +pub(crate) const OFFSET_WITH_STATEMENT_BODY: usize = offset_of!(WithStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct WithStatementWithoutObject<'a>(pub(crate) *const WithStatement<'a>); + +impl<'a> WithStatementWithoutObject<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WITH_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_WITH_STATEMENT_BODY) as *const Statement<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct WithStatementWithoutBody<'a>(pub(crate) *const WithStatement<'a>); + +impl<'a> WithStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WITH_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn object(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_WITH_STATEMENT_OBJECT) as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_SWITCH_STATEMENT_SPAN: usize = offset_of!(SwitchStatement, span); +pub(crate) const OFFSET_SWITCH_STATEMENT_DISCRIMINANT: usize = + offset_of!(SwitchStatement, discriminant); +pub(crate) const OFFSET_SWITCH_STATEMENT_CASES: usize = offset_of!(SwitchStatement, cases); + +#[repr(transparent)] +#[derive(Debug)] +pub struct SwitchStatementWithoutDiscriminant<'a>(pub(crate) *const SwitchStatement<'a>); + +impl<'a> SwitchStatementWithoutDiscriminant<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SWITCH_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn cases(&self) -> &Vec<'a, SwitchCase<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_SWITCH_STATEMENT_CASES) + as *const Vec<'a, SwitchCase<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct SwitchStatementWithoutCases<'a>(pub(crate) *const SwitchStatement<'a>); + +impl<'a> SwitchStatementWithoutCases<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SWITCH_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn discriminant(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_SWITCH_STATEMENT_DISCRIMINANT) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_SWITCH_CASE_SPAN: usize = offset_of!(SwitchCase, span); +pub(crate) const OFFSET_SWITCH_CASE_TEST: usize = offset_of!(SwitchCase, test); +pub(crate) const OFFSET_SWITCH_CASE_CONSEQUENT: usize = offset_of!(SwitchCase, consequent); + +#[repr(transparent)] +#[derive(Debug)] +pub struct SwitchCaseWithoutTest<'a>(pub(crate) *const SwitchCase<'a>); + +impl<'a> SwitchCaseWithoutTest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SWITCH_CASE_SPAN) as *const Span) } + } + + #[inline] + pub fn consequent(&self) -> &Vec<'a, Statement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_SWITCH_CASE_CONSEQUENT) + as *const Vec<'a, Statement<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct SwitchCaseWithoutConsequent<'a>(pub(crate) *const SwitchCase<'a>); + +impl<'a> SwitchCaseWithoutConsequent<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_SWITCH_CASE_SPAN) as *const Span) } + } + + #[inline] + pub fn test(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_SWITCH_CASE_TEST) as *const Option>) + } + } +} + +pub(crate) const OFFSET_LABELED_STATEMENT_SPAN: usize = offset_of!(LabeledStatement, span); +pub(crate) const OFFSET_LABELED_STATEMENT_LABEL: usize = offset_of!(LabeledStatement, label); +pub(crate) const OFFSET_LABELED_STATEMENT_BODY: usize = offset_of!(LabeledStatement, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct LabeledStatementWithoutLabel<'a>(pub(crate) *const LabeledStatement<'a>); + +impl<'a> LabeledStatementWithoutLabel<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_LABELED_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Statement<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LABELED_STATEMENT_BODY) as *const Statement<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct LabeledStatementWithoutBody<'a>(pub(crate) *const LabeledStatement<'a>); + +impl<'a> LabeledStatementWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_LABELED_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn label(&self) -> &LabelIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_LABELED_STATEMENT_LABEL) + as *const LabelIdentifier<'a>) + } + } +} + +pub(crate) const OFFSET_THROW_STATEMENT_SPAN: usize = offset_of!(ThrowStatement, span); +pub(crate) const OFFSET_THROW_STATEMENT_ARGUMENT: usize = offset_of!(ThrowStatement, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ThrowStatementWithoutArgument<'a>(pub(crate) *const ThrowStatement<'a>); + +impl<'a> ThrowStatementWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_THROW_STATEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TRY_STATEMENT_SPAN: usize = offset_of!(TryStatement, span); +pub(crate) const OFFSET_TRY_STATEMENT_BLOCK: usize = offset_of!(TryStatement, block); +pub(crate) const OFFSET_TRY_STATEMENT_HANDLER: usize = offset_of!(TryStatement, handler); +pub(crate) const OFFSET_TRY_STATEMENT_FINALIZER: usize = offset_of!(TryStatement, finalizer); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TryStatementWithoutBlock<'a>(pub(crate) *const TryStatement<'a>); + +impl<'a> TryStatementWithoutBlock<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn handler(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_HANDLER) + as *const Option>>) + } + } + + #[inline] + pub fn finalizer(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_FINALIZER) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TryStatementWithoutHandler<'a>(pub(crate) *const TryStatement<'a>); + +impl<'a> TryStatementWithoutHandler<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn block(&self) -> &Box<'a, BlockStatement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_BLOCK) + as *const Box<'a, BlockStatement<'a>>) + } + } + + #[inline] + pub fn finalizer(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_FINALIZER) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TryStatementWithoutFinalizer<'a>(pub(crate) *const TryStatement<'a>); + +impl<'a> TryStatementWithoutFinalizer<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn block(&self) -> &Box<'a, BlockStatement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_BLOCK) + as *const Box<'a, BlockStatement<'a>>) + } + } + + #[inline] + pub fn handler(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TRY_STATEMENT_HANDLER) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_CATCH_CLAUSE_SPAN: usize = offset_of!(CatchClause, span); +pub(crate) const OFFSET_CATCH_CLAUSE_PARAM: usize = offset_of!(CatchClause, param); +pub(crate) const OFFSET_CATCH_CLAUSE_BODY: usize = offset_of!(CatchClause, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct CatchClauseWithoutParam<'a>(pub(crate) *const CatchClause<'a>); + +impl<'a> CatchClauseWithoutParam<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CATCH_CLAUSE_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Box<'a, BlockStatement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CATCH_CLAUSE_BODY) + as *const Box<'a, BlockStatement<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct CatchClauseWithoutBody<'a>(pub(crate) *const CatchClause<'a>); + +impl<'a> CatchClauseWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CATCH_CLAUSE_SPAN) as *const Span) } + } + + #[inline] + pub fn param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CATCH_CLAUSE_PARAM) + as *const Option>) + } + } +} + +pub(crate) const OFFSET_CATCH_PARAMETER_SPAN: usize = offset_of!(CatchParameter, span); +pub(crate) const OFFSET_CATCH_PARAMETER_PATTERN: usize = offset_of!(CatchParameter, pattern); + +#[repr(transparent)] +#[derive(Debug)] +pub struct CatchParameterWithoutPattern<'a>(pub(crate) *const CatchParameter<'a>); + +impl<'a> CatchParameterWithoutPattern<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CATCH_PARAMETER_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_BINDING_PATTERN_KIND: usize = offset_of!(BindingPattern, kind); +pub(crate) const OFFSET_BINDING_PATTERN_TYPE_ANNOTATION: usize = + offset_of!(BindingPattern, type_annotation); +pub(crate) const OFFSET_BINDING_PATTERN_OPTIONAL: usize = offset_of!(BindingPattern, optional); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BindingPatternWithoutKind<'a>(pub(crate) *const BindingPattern<'a>); + +impl<'a> BindingPatternWithoutKind<'a> { + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINDING_PATTERN_TYPE_ANNOTATION) + as *const Option>>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PATTERN_OPTIONAL) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct BindingPatternWithoutTypeAnnotation<'a>(pub(crate) *const BindingPattern<'a>); + +impl<'a> BindingPatternWithoutTypeAnnotation<'a> { + #[inline] + pub fn kind(&self) -> &BindingPatternKind<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINDING_PATTERN_KIND) + as *const BindingPatternKind<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PATTERN_OPTIONAL) as *const bool) } + } +} + +pub(crate) const OFFSET_ASSIGNMENT_PATTERN_SPAN: usize = offset_of!(AssignmentPattern, span); +pub(crate) const OFFSET_ASSIGNMENT_PATTERN_LEFT: usize = offset_of!(AssignmentPattern, left); +pub(crate) const OFFSET_ASSIGNMENT_PATTERN_RIGHT: usize = offset_of!(AssignmentPattern, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentPatternWithoutLeft<'a>(pub(crate) *const AssignmentPattern<'a>); + +impl<'a> AssignmentPatternWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn right(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_PATTERN_RIGHT) as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AssignmentPatternWithoutRight<'a>(pub(crate) *const AssignmentPattern<'a>); + +impl<'a> AssignmentPatternWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &BindingPattern<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ASSIGNMENT_PATTERN_LEFT) + as *const BindingPattern<'a>) + } + } +} + +pub(crate) const OFFSET_OBJECT_PATTERN_SPAN: usize = offset_of!(ObjectPattern, span); +pub(crate) const OFFSET_OBJECT_PATTERN_PROPERTIES: usize = offset_of!(ObjectPattern, properties); +pub(crate) const OFFSET_OBJECT_PATTERN_REST: usize = offset_of!(ObjectPattern, rest); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectPatternWithoutProperties<'a>(pub(crate) *const ObjectPattern<'a>); + +impl<'a> ObjectPatternWithoutProperties<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn rest(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PATTERN_REST) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ObjectPatternWithoutRest<'a>(pub(crate) *const ObjectPattern<'a>); + +impl<'a> ObjectPatternWithoutRest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_OBJECT_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn properties(&self) -> &Vec<'a, BindingProperty<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_OBJECT_PATTERN_PROPERTIES) + as *const Vec<'a, BindingProperty<'a>>) + } + } +} + +pub(crate) const OFFSET_BINDING_PROPERTY_SPAN: usize = offset_of!(BindingProperty, span); +pub(crate) const OFFSET_BINDING_PROPERTY_KEY: usize = offset_of!(BindingProperty, key); +pub(crate) const OFFSET_BINDING_PROPERTY_VALUE: usize = offset_of!(BindingProperty, value); +pub(crate) const OFFSET_BINDING_PROPERTY_SHORTHAND: usize = offset_of!(BindingProperty, shorthand); +pub(crate) const OFFSET_BINDING_PROPERTY_COMPUTED: usize = offset_of!(BindingProperty, computed); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BindingPropertyWithoutKey<'a>(pub(crate) *const BindingProperty<'a>); + +impl<'a> BindingPropertyWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &BindingPattern<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_VALUE) + as *const BindingPattern<'a>) + } + } + + #[inline] + pub fn shorthand(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_SHORTHAND) as *const bool) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_COMPUTED) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct BindingPropertyWithoutValue<'a>(pub(crate) *const BindingProperty<'a>); + +impl<'a> BindingPropertyWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn shorthand(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_SHORTHAND) as *const bool) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_PROPERTY_COMPUTED) as *const bool) } + } +} + +pub(crate) const OFFSET_ARRAY_PATTERN_SPAN: usize = offset_of!(ArrayPattern, span); +pub(crate) const OFFSET_ARRAY_PATTERN_ELEMENTS: usize = offset_of!(ArrayPattern, elements); +pub(crate) const OFFSET_ARRAY_PATTERN_REST: usize = offset_of!(ArrayPattern, rest); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrayPatternWithoutElements<'a>(pub(crate) *const ArrayPattern<'a>); + +impl<'a> ArrayPatternWithoutElements<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ARRAY_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn rest(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_PATTERN_REST) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrayPatternWithoutRest<'a>(pub(crate) *const ArrayPattern<'a>); + +impl<'a> ArrayPatternWithoutRest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ARRAY_PATTERN_SPAN) as *const Span) } + } + + #[inline] + pub fn elements(&self) -> &Vec<'a, Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARRAY_PATTERN_ELEMENTS) + as *const Vec<'a, Option>>) + } + } +} + +pub(crate) const OFFSET_BINDING_REST_ELEMENT_SPAN: usize = offset_of!(BindingRestElement, span); +pub(crate) const OFFSET_BINDING_REST_ELEMENT_ARGUMENT: usize = + offset_of!(BindingRestElement, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct BindingRestElementWithoutArgument<'a>(pub(crate) *const BindingRestElement<'a>); + +impl<'a> BindingRestElementWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_BINDING_REST_ELEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_FUNCTION_TYPE: usize = offset_of!(Function, r#type); +pub(crate) const OFFSET_FUNCTION_SPAN: usize = offset_of!(Function, span); +pub(crate) const OFFSET_FUNCTION_ID: usize = offset_of!(Function, id); +pub(crate) const OFFSET_FUNCTION_GENERATOR: usize = offset_of!(Function, generator); +pub(crate) const OFFSET_FUNCTION_ASYNC: usize = offset_of!(Function, r#async); +pub(crate) const OFFSET_FUNCTION_THIS_PARAM: usize = offset_of!(Function, this_param); +pub(crate) const OFFSET_FUNCTION_PARAMS: usize = offset_of!(Function, params); +pub(crate) const OFFSET_FUNCTION_BODY: usize = offset_of!(Function, body); +pub(crate) const OFFSET_FUNCTION_TYPE_PARAMETERS: usize = offset_of!(Function, type_parameters); +pub(crate) const OFFSET_FUNCTION_RETURN_TYPE: usize = offset_of!(Function, return_type); +pub(crate) const OFFSET_FUNCTION_MODIFIERS: usize = offset_of!(Function, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutId<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutId<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutThisParam<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutThisParam<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_ID) + as *const Option>) + } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutParams<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutParams<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_ID) + as *const Option>) + } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutBody<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutBody<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_ID) + as *const Option>) + } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutTypeParameters<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutTypeParameters<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_ID) + as *const Option>) + } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionWithoutReturnType<'a>(pub(crate) *const Function<'a>); + +impl<'a> FunctionWithoutReturnType<'a> { + #[inline] + pub fn r#type(&self) -> &FunctionType { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_ID) + as *const Option>) + } + } + + #[inline] + pub fn generator(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) } + } +} + +pub(crate) const OFFSET_FORMAL_PARAMETERS_SPAN: usize = offset_of!(FormalParameters, span); +pub(crate) const OFFSET_FORMAL_PARAMETERS_KIND: usize = offset_of!(FormalParameters, kind); +pub(crate) const OFFSET_FORMAL_PARAMETERS_ITEMS: usize = offset_of!(FormalParameters, items); +pub(crate) const OFFSET_FORMAL_PARAMETERS_REST: usize = offset_of!(FormalParameters, rest); + +#[repr(transparent)] +#[derive(Debug)] +pub struct FormalParametersWithoutItems<'a>(pub(crate) *const FormalParameters<'a>); + +impl<'a> FormalParametersWithoutItems<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &FormalParameterKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_KIND) + as *const FormalParameterKind) + } + } + + #[inline] + pub fn rest(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_REST) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FormalParametersWithoutRest<'a>(pub(crate) *const FormalParameters<'a>); + +impl<'a> FormalParametersWithoutRest<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_SPAN) as *const Span) } + } + + #[inline] + pub fn kind(&self) -> &FormalParameterKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_KIND) + as *const FormalParameterKind) + } + } + + #[inline] + pub fn items(&self) -> &Vec<'a, FormalParameter<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETERS_ITEMS) + as *const Vec<'a, FormalParameter<'a>>) + } + } +} + +pub(crate) const OFFSET_FORMAL_PARAMETER_SPAN: usize = offset_of!(FormalParameter, span); +pub(crate) const OFFSET_FORMAL_PARAMETER_PATTERN: usize = offset_of!(FormalParameter, pattern); +pub(crate) const OFFSET_FORMAL_PARAMETER_ACCESSIBILITY: usize = + offset_of!(FormalParameter, accessibility); +pub(crate) const OFFSET_FORMAL_PARAMETER_READONLY: usize = offset_of!(FormalParameter, readonly); +pub(crate) const OFFSET_FORMAL_PARAMETER_OVERRIDE: usize = offset_of!(FormalParameter, r#override); +pub(crate) const OFFSET_FORMAL_PARAMETER_DECORATORS: usize = + offset_of!(FormalParameter, decorators); + +#[repr(transparent)] +#[derive(Debug)] +pub struct FormalParameterWithoutPattern<'a>(pub(crate) *const FormalParameter<'a>); + +impl<'a> FormalParameterWithoutPattern<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_READONLY) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FormalParameterWithoutDecorators<'a>(pub(crate) *const FormalParameter<'a>); + +impl<'a> FormalParameterWithoutDecorators<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn pattern(&self) -> &BindingPattern<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_PATTERN) + as *const BindingPattern<'a>) + } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_READONLY) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_OVERRIDE) as *const bool) } + } +} + +pub(crate) const OFFSET_FUNCTION_BODY_SPAN: usize = offset_of!(FunctionBody, span); +pub(crate) const OFFSET_FUNCTION_BODY_DIRECTIVES: usize = offset_of!(FunctionBody, directives); +pub(crate) const OFFSET_FUNCTION_BODY_STATEMENTS: usize = offset_of!(FunctionBody, statements); + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionBodyWithoutDirectives<'a>(pub(crate) *const FunctionBody<'a>); + +impl<'a> FunctionBodyWithoutDirectives<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY_SPAN) as *const Span) } + } + + #[inline] + pub fn statements(&self) -> &Vec<'a, Statement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY_STATEMENTS) + as *const Vec<'a, Statement<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct FunctionBodyWithoutStatements<'a>(pub(crate) *const FunctionBody<'a>); + +impl<'a> FunctionBodyWithoutStatements<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY_SPAN) as *const Span) } + } + + #[inline] + pub fn directives(&self) -> &Vec<'a, Directive<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY_DIRECTIVES) + as *const Vec<'a, Directive<'a>>) + } + } +} + +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_SPAN: usize = + offset_of!(ArrowFunctionExpression, span); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_EXPRESSION: usize = + offset_of!(ArrowFunctionExpression, expression); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_ASYNC: usize = + offset_of!(ArrowFunctionExpression, r#async); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_PARAMS: usize = + offset_of!(ArrowFunctionExpression, params); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_BODY: usize = + offset_of!(ArrowFunctionExpression, body); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_TYPE_PARAMETERS: usize = + offset_of!(ArrowFunctionExpression, type_parameters); +pub(crate) const OFFSET_ARROW_FUNCTION_EXPRESSION_RETURN_TYPE: usize = + offset_of!(ArrowFunctionExpression, return_type); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrowFunctionExpressionWithoutParams<'a>(pub(crate) *const ArrowFunctionExpression<'a>); + +impl<'a> ArrowFunctionExpressionWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_EXPRESSION) + as *const bool) + } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_ASYNC) as *const bool) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, FunctionBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_BODY) + as *const Box<'a, FunctionBody<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_RETURN_TYPE) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrowFunctionExpressionWithoutBody<'a>(pub(crate) *const ArrowFunctionExpression<'a>); + +impl<'a> ArrowFunctionExpressionWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_EXPRESSION) + as *const bool) + } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_ASYNC) as *const bool) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_RETURN_TYPE) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrowFunctionExpressionWithoutTypeParameters<'a>( + pub(crate) *const ArrowFunctionExpression<'a>, +); + +impl<'a> ArrowFunctionExpressionWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_EXPRESSION) + as *const bool) + } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_ASYNC) as *const bool) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, FunctionBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_BODY) + as *const Box<'a, FunctionBody<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_RETURN_TYPE) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ArrowFunctionExpressionWithoutReturnType<'a>( + pub(crate) *const ArrowFunctionExpression<'a>, +); + +impl<'a> ArrowFunctionExpressionWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_EXPRESSION) + as *const bool) + } + } + + #[inline] + pub fn r#async(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_ASYNC) as *const bool) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, FunctionBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_BODY) + as *const Box<'a, FunctionBody<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ARROW_FUNCTION_EXPRESSION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_YIELD_EXPRESSION_SPAN: usize = offset_of!(YieldExpression, span); +pub(crate) const OFFSET_YIELD_EXPRESSION_DELEGATE: usize = offset_of!(YieldExpression, delegate); +pub(crate) const OFFSET_YIELD_EXPRESSION_ARGUMENT: usize = offset_of!(YieldExpression, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct YieldExpressionWithoutArgument<'a>(pub(crate) *const YieldExpression<'a>); + +impl<'a> YieldExpressionWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_YIELD_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn delegate(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_YIELD_EXPRESSION_DELEGATE) as *const bool) } + } +} + +pub(crate) const OFFSET_CLASS_TYPE: usize = offset_of!(Class, r#type); +pub(crate) const OFFSET_CLASS_SPAN: usize = offset_of!(Class, span); +pub(crate) const OFFSET_CLASS_ID: usize = offset_of!(Class, id); +pub(crate) const OFFSET_CLASS_SUPER_CLASS: usize = offset_of!(Class, super_class); +pub(crate) const OFFSET_CLASS_BODY: usize = offset_of!(Class, body); +pub(crate) const OFFSET_CLASS_TYPE_PARAMETERS: usize = offset_of!(Class, type_parameters); +pub(crate) const OFFSET_CLASS_SUPER_TYPE_PARAMETERS: usize = + offset_of!(Class, super_type_parameters); +pub(crate) const OFFSET_CLASS_IMPLEMENTS: usize = offset_of!(Class, implements); +pub(crate) const OFFSET_CLASS_DECORATORS: usize = offset_of!(Class, decorators); +pub(crate) const OFFSET_CLASS_MODIFIERS: usize = offset_of!(Class, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutId<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutId<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutSuperClass<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutSuperClass<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutBody<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutBody<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutTypeParameters<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutTypeParameters<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutSuperTypeParameters<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutSuperTypeParameters<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutImplements<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutImplements<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_DECORATORS) as *const Vec<'a, Decorator<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassWithoutDecorators<'a>(pub(crate) *const Class<'a>); + +impl<'a> ClassWithoutDecorators<'a> { + #[inline] + pub fn r#type(&self) -> &ClassType { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE) as *const ClassType) } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_ID) as *const Option>) + } + } + + #[inline] + pub fn super_class(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_CLASS) as *const Option>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, ClassBody<'a>> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY) as *const Box<'a, ClassBody<'a>>) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn super_type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn implements(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_CLASS_IMPLEMENTS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_MODIFIERS) as *const Modifiers<'a>) } + } +} + +pub(crate) const OFFSET_CLASS_BODY_SPAN: usize = offset_of!(ClassBody, span); +pub(crate) const OFFSET_CLASS_BODY_BODY: usize = offset_of!(ClassBody, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ClassBodyWithoutBody<'a>(pub(crate) *const ClassBody<'a>); + +impl<'a> ClassBodyWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_CLASS_BODY_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_METHOD_DEFINITION_TYPE: usize = offset_of!(MethodDefinition, r#type); +pub(crate) const OFFSET_METHOD_DEFINITION_SPAN: usize = offset_of!(MethodDefinition, span); +pub(crate) const OFFSET_METHOD_DEFINITION_KEY: usize = offset_of!(MethodDefinition, key); +pub(crate) const OFFSET_METHOD_DEFINITION_VALUE: usize = offset_of!(MethodDefinition, value); +pub(crate) const OFFSET_METHOD_DEFINITION_KIND: usize = offset_of!(MethodDefinition, kind); +pub(crate) const OFFSET_METHOD_DEFINITION_COMPUTED: usize = offset_of!(MethodDefinition, computed); +pub(crate) const OFFSET_METHOD_DEFINITION_STATIC: usize = offset_of!(MethodDefinition, r#static); +pub(crate) const OFFSET_METHOD_DEFINITION_OVERRIDE: usize = + offset_of!(MethodDefinition, r#override); +pub(crate) const OFFSET_METHOD_DEFINITION_OPTIONAL: usize = offset_of!(MethodDefinition, optional); +pub(crate) const OFFSET_METHOD_DEFINITION_ACCESSIBILITY: usize = + offset_of!(MethodDefinition, accessibility); +pub(crate) const OFFSET_METHOD_DEFINITION_DECORATORS: usize = + offset_of!(MethodDefinition, decorators); + +#[repr(transparent)] +#[derive(Debug)] +pub struct MethodDefinitionWithoutKey<'a>(pub(crate) *const MethodDefinition<'a>); + +impl<'a> MethodDefinitionWithoutKey<'a> { + #[inline] + pub fn r#type(&self) -> &MethodDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_TYPE) + as *const MethodDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &Box<'a, Function<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_VALUE) + as *const Box<'a, Function<'a>>) + } + } + + #[inline] + pub fn kind(&self) -> &MethodDefinitionKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_KIND) + as *const MethodDefinitionKind) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct MethodDefinitionWithoutValue<'a>(pub(crate) *const MethodDefinition<'a>); + +impl<'a> MethodDefinitionWithoutValue<'a> { + #[inline] + pub fn r#type(&self) -> &MethodDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_TYPE) + as *const MethodDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn kind(&self) -> &MethodDefinitionKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_KIND) + as *const MethodDefinitionKind) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct MethodDefinitionWithoutDecorators<'a>(pub(crate) *const MethodDefinition<'a>); + +impl<'a> MethodDefinitionWithoutDecorators<'a> { + #[inline] + pub fn r#type(&self) -> &MethodDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_TYPE) + as *const MethodDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn value(&self) -> &Box<'a, Function<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_VALUE) + as *const Box<'a, Function<'a>>) + } + } + + #[inline] + pub fn kind(&self) -> &MethodDefinitionKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_KIND) + as *const MethodDefinitionKind) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_METHOD_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } +} + +pub(crate) const OFFSET_PROPERTY_DEFINITION_TYPE: usize = offset_of!(PropertyDefinition, r#type); +pub(crate) const OFFSET_PROPERTY_DEFINITION_SPAN: usize = offset_of!(PropertyDefinition, span); +pub(crate) const OFFSET_PROPERTY_DEFINITION_KEY: usize = offset_of!(PropertyDefinition, key); +pub(crate) const OFFSET_PROPERTY_DEFINITION_VALUE: usize = offset_of!(PropertyDefinition, value); +pub(crate) const OFFSET_PROPERTY_DEFINITION_COMPUTED: usize = + offset_of!(PropertyDefinition, computed); +pub(crate) const OFFSET_PROPERTY_DEFINITION_STATIC: usize = + offset_of!(PropertyDefinition, r#static); +pub(crate) const OFFSET_PROPERTY_DEFINITION_DECLARE: usize = + offset_of!(PropertyDefinition, declare); +pub(crate) const OFFSET_PROPERTY_DEFINITION_OVERRIDE: usize = + offset_of!(PropertyDefinition, r#override); +pub(crate) const OFFSET_PROPERTY_DEFINITION_OPTIONAL: usize = + offset_of!(PropertyDefinition, optional); +pub(crate) const OFFSET_PROPERTY_DEFINITION_DEFINITE: usize = + offset_of!(PropertyDefinition, definite); +pub(crate) const OFFSET_PROPERTY_DEFINITION_READONLY: usize = + offset_of!(PropertyDefinition, readonly); +pub(crate) const OFFSET_PROPERTY_DEFINITION_TYPE_ANNOTATION: usize = + offset_of!(PropertyDefinition, type_annotation); +pub(crate) const OFFSET_PROPERTY_DEFINITION_ACCESSIBILITY: usize = + offset_of!(PropertyDefinition, accessibility); +pub(crate) const OFFSET_PROPERTY_DEFINITION_DECORATORS: usize = + offset_of!(PropertyDefinition, decorators); + +#[repr(transparent)] +#[derive(Debug)] +pub struct PropertyDefinitionWithoutKey<'a>(pub(crate) *const PropertyDefinition<'a>); + +impl<'a> PropertyDefinitionWithoutKey<'a> { + #[inline] + pub fn r#type(&self) -> &PropertyDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE) + as *const PropertyDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_VALUE) + as *const Option>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn declare(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECLARE) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DEFINITE) as *const bool) } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_READONLY) as *const bool) } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE_ANNOTATION) + as *const Option>>) + } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct PropertyDefinitionWithoutValue<'a>(pub(crate) *const PropertyDefinition<'a>); + +impl<'a> PropertyDefinitionWithoutValue<'a> { + #[inline] + pub fn r#type(&self) -> &PropertyDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE) + as *const PropertyDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn declare(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECLARE) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DEFINITE) as *const bool) } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_READONLY) as *const bool) } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE_ANNOTATION) + as *const Option>>) + } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct PropertyDefinitionWithoutTypeAnnotation<'a>(pub(crate) *const PropertyDefinition<'a>); + +impl<'a> PropertyDefinitionWithoutTypeAnnotation<'a> { + #[inline] + pub fn r#type(&self) -> &PropertyDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE) + as *const PropertyDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_VALUE) + as *const Option>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn declare(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECLARE) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DEFINITE) as *const bool) } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_READONLY) as *const bool) } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct PropertyDefinitionWithoutDecorators<'a>(pub(crate) *const PropertyDefinition<'a>); + +impl<'a> PropertyDefinitionWithoutDecorators<'a> { + #[inline] + pub fn r#type(&self) -> &PropertyDefinitionType { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE) + as *const PropertyDefinitionType) + } + } + + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_VALUE) + as *const Option>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_STATIC) as *const bool) } + } + + #[inline] + pub fn declare(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DECLARE) as *const bool) } + } + + #[inline] + pub fn r#override(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OVERRIDE) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn definite(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_DEFINITE) as *const bool) } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_READONLY) as *const bool) } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_TYPE_ANNOTATION) + as *const Option>>) + } + } + + #[inline] + pub fn accessibility(&self) -> &Option { + unsafe { + &*((self.0 as *const u8).add(OFFSET_PROPERTY_DEFINITION_ACCESSIBILITY) + as *const Option) + } + } +} + +pub(crate) const OFFSET_STATIC_BLOCK_SPAN: usize = offset_of!(StaticBlock, span); +pub(crate) const OFFSET_STATIC_BLOCK_BODY: usize = offset_of!(StaticBlock, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct StaticBlockWithoutBody<'a>(pub(crate) *const StaticBlock<'a>); + +impl<'a> StaticBlockWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_STATIC_BLOCK_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_ACCESSOR_PROPERTY_SPAN: usize = offset_of!(AccessorProperty, span); +pub(crate) const OFFSET_ACCESSOR_PROPERTY_KEY: usize = offset_of!(AccessorProperty, key); +pub(crate) const OFFSET_ACCESSOR_PROPERTY_VALUE: usize = offset_of!(AccessorProperty, value); +pub(crate) const OFFSET_ACCESSOR_PROPERTY_COMPUTED: usize = offset_of!(AccessorProperty, computed); +pub(crate) const OFFSET_ACCESSOR_PROPERTY_STATIC: usize = offset_of!(AccessorProperty, r#static); +pub(crate) const OFFSET_ACCESSOR_PROPERTY_DECORATORS: usize = + offset_of!(AccessorProperty, decorators); + +#[repr(transparent)] +#[derive(Debug)] +pub struct AccessorPropertyWithoutKey<'a>(pub(crate) *const AccessorProperty<'a>); + +impl<'a> AccessorPropertyWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_VALUE) + as *const Option>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AccessorPropertyWithoutValue<'a>(pub(crate) *const AccessorProperty<'a>); + +impl<'a> AccessorPropertyWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) } + } + + #[inline] + pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS) + as *const Vec<'a, Decorator<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct AccessorPropertyWithoutDecorators<'a>(pub(crate) *const AccessorProperty<'a>); + +impl<'a> AccessorPropertyWithoutDecorators<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_VALUE) + as *const Option>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) } + } + + #[inline] + pub fn r#static(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) } + } +} + +pub(crate) const OFFSET_IMPORT_EXPRESSION_SPAN: usize = offset_of!(ImportExpression, span); +pub(crate) const OFFSET_IMPORT_EXPRESSION_SOURCE: usize = offset_of!(ImportExpression, source); +pub(crate) const OFFSET_IMPORT_EXPRESSION_ARGUMENTS: usize = + offset_of!(ImportExpression, arguments); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportExpressionWithoutSource<'a>(pub(crate) *const ImportExpression<'a>); + +impl<'a> ImportExpressionWithoutSource<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn arguments(&self) -> &Vec<'a, Expression<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_EXPRESSION_ARGUMENTS) + as *const Vec<'a, Expression<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportExpressionWithoutArguments<'a>(pub(crate) *const ImportExpression<'a>); + +impl<'a> ImportExpressionWithoutArguments<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn source(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_EXPRESSION_SOURCE) as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_IMPORT_DECLARATION_SPAN: usize = offset_of!(ImportDeclaration, span); +pub(crate) const OFFSET_IMPORT_DECLARATION_SPECIFIERS: usize = + offset_of!(ImportDeclaration, specifiers); +pub(crate) const OFFSET_IMPORT_DECLARATION_SOURCE: usize = offset_of!(ImportDeclaration, source); +pub(crate) const OFFSET_IMPORT_DECLARATION_WITH_CLAUSE: usize = + offset_of!(ImportDeclaration, with_clause); +pub(crate) const OFFSET_IMPORT_DECLARATION_IMPORT_KIND: usize = + offset_of!(ImportDeclaration, import_kind); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportDeclarationWithoutSpecifiers<'a>(pub(crate) *const ImportDeclaration<'a>); + +impl<'a> ImportDeclarationWithoutSpecifiers<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn source(&self) -> &StringLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SOURCE) + as *const StringLiteral<'a>) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportDeclarationWithoutSource<'a>(pub(crate) *const ImportDeclaration<'a>); + +impl<'a> ImportDeclarationWithoutSource<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn specifiers(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SPECIFIERS) + as *const Option>>) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportDeclarationWithoutWithClause<'a>(pub(crate) *const ImportDeclaration<'a>); + +impl<'a> ImportDeclarationWithoutWithClause<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn specifiers(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SPECIFIERS) + as *const Option>>) + } + } + + #[inline] + pub fn source(&self) -> &StringLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_SOURCE) + as *const StringLiteral<'a>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DECLARATION_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_IMPORT_SPECIFIER_SPAN: usize = offset_of!(ImportSpecifier, span); +pub(crate) const OFFSET_IMPORT_SPECIFIER_IMPORTED: usize = offset_of!(ImportSpecifier, imported); +pub(crate) const OFFSET_IMPORT_SPECIFIER_LOCAL: usize = offset_of!(ImportSpecifier, local); +pub(crate) const OFFSET_IMPORT_SPECIFIER_IMPORT_KIND: usize = + offset_of!(ImportSpecifier, import_kind); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportSpecifierWithoutImported<'a>(pub(crate) *const ImportSpecifier<'a>); + +impl<'a> ImportSpecifierWithoutImported<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_SPAN) as *const Span) } + } + + #[inline] + pub fn local(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_LOCAL) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportSpecifierWithoutLocal<'a>(pub(crate) *const ImportSpecifier<'a>); + +impl<'a> ImportSpecifierWithoutLocal<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_SPAN) as *const Span) } + } + + #[inline] + pub fn imported(&self) -> &ModuleExportName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_IMPORTED) + as *const ModuleExportName<'a>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_SPECIFIER_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_IMPORT_DEFAULT_SPECIFIER_SPAN: usize = + offset_of!(ImportDefaultSpecifier, span); +pub(crate) const OFFSET_IMPORT_DEFAULT_SPECIFIER_LOCAL: usize = + offset_of!(ImportDefaultSpecifier, local); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportDefaultSpecifierWithoutLocal<'a>(pub(crate) *const ImportDefaultSpecifier<'a>); + +impl<'a> ImportDefaultSpecifierWithoutLocal<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_DEFAULT_SPECIFIER_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_IMPORT_NAMESPACE_SPECIFIER_SPAN: usize = + offset_of!(ImportNamespaceSpecifier, span); +pub(crate) const OFFSET_IMPORT_NAMESPACE_SPECIFIER_LOCAL: usize = + offset_of!(ImportNamespaceSpecifier, local); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportNamespaceSpecifierWithoutLocal<'a>(pub(crate) *const ImportNamespaceSpecifier<'a>); + +impl<'a> ImportNamespaceSpecifierWithoutLocal<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_NAMESPACE_SPECIFIER_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_WITH_CLAUSE_SPAN: usize = offset_of!(WithClause, span); +pub(crate) const OFFSET_WITH_CLAUSE_ATTRIBUTES_KEYWORD: usize = + offset_of!(WithClause, attributes_keyword); +pub(crate) const OFFSET_WITH_CLAUSE_WITH_ENTRIES: usize = offset_of!(WithClause, with_entries); + +#[repr(transparent)] +#[derive(Debug)] +pub struct WithClauseWithoutAttributesKeyword<'a>(pub(crate) *const WithClause<'a>); + +impl<'a> WithClauseWithoutAttributesKeyword<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WITH_CLAUSE_SPAN) as *const Span) } + } + + #[inline] + pub fn with_entries(&self) -> &Vec<'a, ImportAttribute<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_WITH_CLAUSE_WITH_ENTRIES) + as *const Vec<'a, ImportAttribute<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct WithClauseWithoutWithEntries<'a>(pub(crate) *const WithClause<'a>); + +impl<'a> WithClauseWithoutWithEntries<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_WITH_CLAUSE_SPAN) as *const Span) } + } + + #[inline] + pub fn attributes_keyword(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_WITH_CLAUSE_ATTRIBUTES_KEYWORD) + as *const IdentifierName<'a>) + } + } +} + +pub(crate) const OFFSET_IMPORT_ATTRIBUTE_SPAN: usize = offset_of!(ImportAttribute, span); +pub(crate) const OFFSET_IMPORT_ATTRIBUTE_KEY: usize = offset_of!(ImportAttribute, key); +pub(crate) const OFFSET_IMPORT_ATTRIBUTE_VALUE: usize = offset_of!(ImportAttribute, value); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportAttributeWithoutKey<'a>(pub(crate) *const ImportAttribute<'a>); + +impl<'a> ImportAttributeWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &StringLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_ATTRIBUTE_VALUE) as *const StringLiteral<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ImportAttributeWithoutValue<'a>(pub(crate) *const ImportAttribute<'a>); + +impl<'a> ImportAttributeWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_IMPORT_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &ImportAttributeKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_IMPORT_ATTRIBUTE_KEY) + as *const ImportAttributeKey<'a>) + } + } +} + +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_SPAN: usize = + offset_of!(ExportNamedDeclaration, span); +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_DECLARATION: usize = + offset_of!(ExportNamedDeclaration, declaration); +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_SPECIFIERS: usize = + offset_of!(ExportNamedDeclaration, specifiers); +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_SOURCE: usize = + offset_of!(ExportNamedDeclaration, source); +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_EXPORT_KIND: usize = + offset_of!(ExportNamedDeclaration, export_kind); +pub(crate) const OFFSET_EXPORT_NAMED_DECLARATION_WITH_CLAUSE: usize = + offset_of!(ExportNamedDeclaration, with_clause); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportNamedDeclarationWithoutDeclaration<'a>( + pub(crate) *const ExportNamedDeclaration<'a>, +); + +impl<'a> ExportNamedDeclarationWithoutDeclaration<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn specifiers(&self) -> &Vec<'a, ExportSpecifier<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPECIFIERS) + as *const Vec<'a, ExportSpecifier<'a>>) + } + } + + #[inline] + pub fn source(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SOURCE) + as *const Option>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportNamedDeclarationWithoutSpecifiers<'a>( + pub(crate) *const ExportNamedDeclaration<'a>, +); + +impl<'a> ExportNamedDeclarationWithoutSpecifiers<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn declaration(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_DECLARATION) + as *const Option>) + } + } + + #[inline] + pub fn source(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SOURCE) + as *const Option>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportNamedDeclarationWithoutSource<'a>(pub(crate) *const ExportNamedDeclaration<'a>); + +impl<'a> ExportNamedDeclarationWithoutSource<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn declaration(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_DECLARATION) + as *const Option>) + } + } + + #[inline] + pub fn specifiers(&self) -> &Vec<'a, ExportSpecifier<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPECIFIERS) + as *const Vec<'a, ExportSpecifier<'a>>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportNamedDeclarationWithoutWithClause<'a>( + pub(crate) *const ExportNamedDeclaration<'a>, +); + +impl<'a> ExportNamedDeclarationWithoutWithClause<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn declaration(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_DECLARATION) + as *const Option>) + } + } + + #[inline] + pub fn specifiers(&self) -> &Vec<'a, ExportSpecifier<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SPECIFIERS) + as *const Vec<'a, ExportSpecifier<'a>>) + } + } + + #[inline] + pub fn source(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_SOURCE) + as *const Option>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_NAMED_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_SPAN: usize = + offset_of!(ExportDefaultDeclaration, span); +pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION: usize = + offset_of!(ExportDefaultDeclaration, declaration); +pub(crate) const OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED: usize = + offset_of!(ExportDefaultDeclaration, exported); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportDefaultDeclarationWithoutDeclaration<'a>( + pub(crate) *const ExportDefaultDeclaration<'a>, +); + +impl<'a> ExportDefaultDeclarationWithoutDeclaration<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn exported(&self) -> &ModuleExportName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED) + as *const ModuleExportName<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportDefaultDeclarationWithoutExported<'a>( + pub(crate) *const ExportDefaultDeclaration<'a>, +); + +impl<'a> ExportDefaultDeclarationWithoutExported<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn declaration(&self) -> &ExportDefaultDeclarationKind<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION) + as *const ExportDefaultDeclarationKind<'a>) + } + } +} + +pub(crate) const OFFSET_EXPORT_ALL_DECLARATION_SPAN: usize = offset_of!(ExportAllDeclaration, span); +pub(crate) const OFFSET_EXPORT_ALL_DECLARATION_EXPORTED: usize = + offset_of!(ExportAllDeclaration, exported); +pub(crate) const OFFSET_EXPORT_ALL_DECLARATION_SOURCE: usize = + offset_of!(ExportAllDeclaration, source); +pub(crate) const OFFSET_EXPORT_ALL_DECLARATION_WITH_CLAUSE: usize = + offset_of!(ExportAllDeclaration, with_clause); +pub(crate) const OFFSET_EXPORT_ALL_DECLARATION_EXPORT_KIND: usize = + offset_of!(ExportAllDeclaration, export_kind); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportAllDeclarationWithoutExported<'a>(pub(crate) *const ExportAllDeclaration<'a>); + +impl<'a> ExportAllDeclarationWithoutExported<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn source(&self) -> &StringLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_SOURCE) + as *const StringLiteral<'a>) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportAllDeclarationWithoutSource<'a>(pub(crate) *const ExportAllDeclaration<'a>); + +impl<'a> ExportAllDeclarationWithoutSource<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn exported(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_EXPORTED) + as *const Option>) + } + } + + #[inline] + pub fn with_clause(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_WITH_CLAUSE) + as *const Option>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportAllDeclarationWithoutWithClause<'a>(pub(crate) *const ExportAllDeclaration<'a>); + +impl<'a> ExportAllDeclarationWithoutWithClause<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn exported(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_EXPORTED) + as *const Option>) + } + } + + #[inline] + pub fn source(&self) -> &StringLiteral<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_SOURCE) + as *const StringLiteral<'a>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_ALL_DECLARATION_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_EXPORT_SPECIFIER_SPAN: usize = offset_of!(ExportSpecifier, span); +pub(crate) const OFFSET_EXPORT_SPECIFIER_LOCAL: usize = offset_of!(ExportSpecifier, local); +pub(crate) const OFFSET_EXPORT_SPECIFIER_EXPORTED: usize = offset_of!(ExportSpecifier, exported); +pub(crate) const OFFSET_EXPORT_SPECIFIER_EXPORT_KIND: usize = + offset_of!(ExportSpecifier, export_kind); + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportSpecifierWithoutLocal<'a>(pub(crate) *const ExportSpecifier<'a>); + +impl<'a> ExportSpecifierWithoutLocal<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_SPAN) as *const Span) } + } + + #[inline] + pub fn exported(&self) -> &ModuleExportName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_EXPORTED) + as *const ModuleExportName<'a>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct ExportSpecifierWithoutExported<'a>(pub(crate) *const ExportSpecifier<'a>); + +impl<'a> ExportSpecifierWithoutExported<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_SPAN) as *const Span) } + } + + #[inline] + pub fn local(&self) -> &ModuleExportName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_LOCAL) + as *const ModuleExportName<'a>) + } + } + + #[inline] + pub fn export_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_EXPORT_SPECIFIER_EXPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_JSX_ELEMENT_SPAN: usize = offset_of!(JSXElement, span); +pub(crate) const OFFSET_JSX_ELEMENT_OPENING_ELEMENT: usize = + offset_of!(JSXElement, opening_element); +pub(crate) const OFFSET_JSX_ELEMENT_CLOSING_ELEMENT: usize = + offset_of!(JSXElement, closing_element); +pub(crate) const OFFSET_JSX_ELEMENT_CHILDREN: usize = offset_of!(JSXElement, children); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXElementWithoutOpeningElement<'a>(pub(crate) *const JSXElement<'a>); + +impl<'a> JSXElementWithoutOpeningElement<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn closing_element(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_CLOSING_ELEMENT) + as *const Option>>) + } + } + + #[inline] + pub fn children(&self) -> &Vec<'a, JSXChild<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_CHILDREN) + as *const Vec<'a, JSXChild<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXElementWithoutClosingElement<'a>(pub(crate) *const JSXElement<'a>); + +impl<'a> JSXElementWithoutClosingElement<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn opening_element(&self) -> &Box<'a, JSXOpeningElement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_OPENING_ELEMENT) + as *const Box<'a, JSXOpeningElement<'a>>) + } + } + + #[inline] + pub fn children(&self) -> &Vec<'a, JSXChild<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_CHILDREN) + as *const Vec<'a, JSXChild<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXElementWithoutChildren<'a>(pub(crate) *const JSXElement<'a>); + +impl<'a> JSXElementWithoutChildren<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn opening_element(&self) -> &Box<'a, JSXOpeningElement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_OPENING_ELEMENT) + as *const Box<'a, JSXOpeningElement<'a>>) + } + } + + #[inline] + pub fn closing_element(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ELEMENT_CLOSING_ELEMENT) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_JSX_OPENING_ELEMENT_SPAN: usize = offset_of!(JSXOpeningElement, span); +pub(crate) const OFFSET_JSX_OPENING_ELEMENT_SELF_CLOSING: usize = + offset_of!(JSXOpeningElement, self_closing); +pub(crate) const OFFSET_JSX_OPENING_ELEMENT_NAME: usize = offset_of!(JSXOpeningElement, name); +pub(crate) const OFFSET_JSX_OPENING_ELEMENT_ATTRIBUTES: usize = + offset_of!(JSXOpeningElement, attributes); +pub(crate) const OFFSET_JSX_OPENING_ELEMENT_TYPE_PARAMETERS: usize = + offset_of!(JSXOpeningElement, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXOpeningElementWithoutName<'a>(pub(crate) *const JSXOpeningElement<'a>); + +impl<'a> JSXOpeningElementWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn self_closing(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SELF_CLOSING) as *const bool) + } + } + + #[inline] + pub fn attributes(&self) -> &Vec<'a, JSXAttributeItem<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_ATTRIBUTES) + as *const Vec<'a, JSXAttributeItem<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXOpeningElementWithoutAttributes<'a>(pub(crate) *const JSXOpeningElement<'a>); + +impl<'a> JSXOpeningElementWithoutAttributes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn self_closing(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SELF_CLOSING) as *const bool) + } + } + + #[inline] + pub fn name(&self) -> &JSXElementName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_NAME) + as *const JSXElementName<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXOpeningElementWithoutTypeParameters<'a>(pub(crate) *const JSXOpeningElement<'a>); + +impl<'a> JSXOpeningElementWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn self_closing(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_SELF_CLOSING) as *const bool) + } + } + + #[inline] + pub fn name(&self) -> &JSXElementName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_NAME) + as *const JSXElementName<'a>) + } + } + + #[inline] + pub fn attributes(&self) -> &Vec<'a, JSXAttributeItem<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_OPENING_ELEMENT_ATTRIBUTES) + as *const Vec<'a, JSXAttributeItem<'a>>) + } + } +} + +pub(crate) const OFFSET_JSX_CLOSING_ELEMENT_SPAN: usize = offset_of!(JSXClosingElement, span); +pub(crate) const OFFSET_JSX_CLOSING_ELEMENT_NAME: usize = offset_of!(JSXClosingElement, name); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXClosingElementWithoutName<'a>(pub(crate) *const JSXClosingElement<'a>); + +impl<'a> JSXClosingElementWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_CLOSING_ELEMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_JSX_FRAGMENT_SPAN: usize = offset_of!(JSXFragment, span); +pub(crate) const OFFSET_JSX_FRAGMENT_OPENING_FRAGMENT: usize = + offset_of!(JSXFragment, opening_fragment); +pub(crate) const OFFSET_JSX_FRAGMENT_CLOSING_FRAGMENT: usize = + offset_of!(JSXFragment, closing_fragment); +pub(crate) const OFFSET_JSX_FRAGMENT_CHILDREN: usize = offset_of!(JSXFragment, children); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXFragmentWithoutChildren<'a>(pub(crate) *const JSXFragment<'a>); + +impl<'a> JSXFragmentWithoutChildren<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_FRAGMENT_SPAN) as *const Span) } + } + + #[inline] + pub fn opening_fragment(&self) -> &JSXOpeningFragment { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_FRAGMENT_OPENING_FRAGMENT) + as *const JSXOpeningFragment) + } + } + + #[inline] + pub fn closing_fragment(&self) -> &JSXClosingFragment { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_FRAGMENT_CLOSING_FRAGMENT) + as *const JSXClosingFragment) + } + } +} + +pub(crate) const OFFSET_JSX_NAMESPACED_NAME_SPAN: usize = offset_of!(JSXNamespacedName, span); +pub(crate) const OFFSET_JSX_NAMESPACED_NAME_NAMESPACE: usize = + offset_of!(JSXNamespacedName, namespace); +pub(crate) const OFFSET_JSX_NAMESPACED_NAME_PROPERTY: usize = + offset_of!(JSXNamespacedName, property); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXNamespacedNameWithoutNamespace<'a>(pub(crate) *const JSXNamespacedName<'a>); + +impl<'a> JSXNamespacedNameWithoutNamespace<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_SPAN) as *const Span) } + } + + #[inline] + pub fn property(&self) -> &JSXIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_PROPERTY) + as *const JSXIdentifier<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXNamespacedNameWithoutProperty<'a>(pub(crate) *const JSXNamespacedName<'a>); + +impl<'a> JSXNamespacedNameWithoutProperty<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_SPAN) as *const Span) } + } + + #[inline] + pub fn namespace(&self) -> &JSXIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_NAMESPACED_NAME_NAMESPACE) + as *const JSXIdentifier<'a>) + } + } +} + +pub(crate) const OFFSET_JSX_MEMBER_EXPRESSION_SPAN: usize = offset_of!(JSXMemberExpression, span); +pub(crate) const OFFSET_JSX_MEMBER_EXPRESSION_OBJECT: usize = + offset_of!(JSXMemberExpression, object); +pub(crate) const OFFSET_JSX_MEMBER_EXPRESSION_PROPERTY: usize = + offset_of!(JSXMemberExpression, property); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXMemberExpressionWithoutObject<'a>(pub(crate) *const JSXMemberExpression<'a>); + +impl<'a> JSXMemberExpressionWithoutObject<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_MEMBER_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn property(&self) -> &JSXIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_MEMBER_EXPRESSION_PROPERTY) + as *const JSXIdentifier<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXMemberExpressionWithoutProperty<'a>(pub(crate) *const JSXMemberExpression<'a>); + +impl<'a> JSXMemberExpressionWithoutProperty<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_MEMBER_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn object(&self) -> &JSXMemberExpressionObject<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_MEMBER_EXPRESSION_OBJECT) + as *const JSXMemberExpressionObject<'a>) + } + } +} + +pub(crate) const OFFSET_JSX_EXPRESSION_CONTAINER_SPAN: usize = + offset_of!(JSXExpressionContainer, span); +pub(crate) const OFFSET_JSX_EXPRESSION_CONTAINER_EXPRESSION: usize = + offset_of!(JSXExpressionContainer, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXExpressionContainerWithoutExpression<'a>( + pub(crate) *const JSXExpressionContainer<'a>, +); + +impl<'a> JSXExpressionContainerWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_EXPRESSION_CONTAINER_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_JSX_ATTRIBUTE_SPAN: usize = offset_of!(JSXAttribute, span); +pub(crate) const OFFSET_JSX_ATTRIBUTE_NAME: usize = offset_of!(JSXAttribute, name); +pub(crate) const OFFSET_JSX_ATTRIBUTE_VALUE: usize = offset_of!(JSXAttribute, value); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXAttributeWithoutName<'a>(pub(crate) *const JSXAttribute<'a>); + +impl<'a> JSXAttributeWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ATTRIBUTE_VALUE) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXAttributeWithoutValue<'a>(pub(crate) *const JSXAttribute<'a>); + +impl<'a> JSXAttributeWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn name(&self) -> &JSXAttributeName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_JSX_ATTRIBUTE_NAME) as *const JSXAttributeName<'a>) + } + } +} + +pub(crate) const OFFSET_JSX_SPREAD_ATTRIBUTE_SPAN: usize = offset_of!(JSXSpreadAttribute, span); +pub(crate) const OFFSET_JSX_SPREAD_ATTRIBUTE_ARGUMENT: usize = + offset_of!(JSXSpreadAttribute, argument); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXSpreadAttributeWithoutArgument<'a>(pub(crate) *const JSXSpreadAttribute<'a>); + +impl<'a> JSXSpreadAttributeWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_SPREAD_ATTRIBUTE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_JSX_SPREAD_CHILD_SPAN: usize = offset_of!(JSXSpreadChild, span); +pub(crate) const OFFSET_JSX_SPREAD_CHILD_EXPRESSION: usize = offset_of!(JSXSpreadChild, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSXSpreadChildWithoutExpression<'a>(pub(crate) *const JSXSpreadChild<'a>); + +impl<'a> JSXSpreadChildWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JSX_SPREAD_CHILD_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_THIS_PARAMETER_SPAN: usize = offset_of!(TSThisParameter, span); +pub(crate) const OFFSET_TS_THIS_PARAMETER_THIS: usize = offset_of!(TSThisParameter, this); +pub(crate) const OFFSET_TS_THIS_PARAMETER_TYPE_ANNOTATION: usize = + offset_of!(TSThisParameter, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSThisParameterWithoutThis<'a>(pub(crate) *const TSThisParameter<'a>); + +impl<'a> TSThisParameterWithoutThis<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_TYPE_ANNOTATION) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSThisParameterWithoutTypeAnnotation<'a>(pub(crate) *const TSThisParameter<'a>); + +impl<'a> TSThisParameterWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn this(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_THIS) + as *const IdentifierName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_ENUM_DECLARATION_SPAN: usize = offset_of!(TSEnumDeclaration, span); +pub(crate) const OFFSET_TS_ENUM_DECLARATION_ID: usize = offset_of!(TSEnumDeclaration, id); +pub(crate) const OFFSET_TS_ENUM_DECLARATION_MEMBERS: usize = offset_of!(TSEnumDeclaration, members); +pub(crate) const OFFSET_TS_ENUM_DECLARATION_MODIFIERS: usize = + offset_of!(TSEnumDeclaration, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSEnumDeclarationWithoutId<'a>(pub(crate) *const TSEnumDeclaration<'a>); + +impl<'a> TSEnumDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn members(&self) -> &Vec<'a, TSEnumMember<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_MEMBERS) + as *const Vec<'a, TSEnumMember<'a>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSEnumDeclarationWithoutMembers<'a>(pub(crate) *const TSEnumDeclaration<'a>); + +impl<'a> TSEnumDeclarationWithoutMembers<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +pub(crate) const OFFSET_TS_ENUM_MEMBER_SPAN: usize = offset_of!(TSEnumMember, span); +pub(crate) const OFFSET_TS_ENUM_MEMBER_ID: usize = offset_of!(TSEnumMember, id); +pub(crate) const OFFSET_TS_ENUM_MEMBER_INITIALIZER: usize = offset_of!(TSEnumMember, initializer); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSEnumMemberWithoutId<'a>(pub(crate) *const TSEnumMember<'a>); + +impl<'a> TSEnumMemberWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_ENUM_MEMBER_SPAN) as *const Span) } + } + + #[inline] + pub fn initializer(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_MEMBER_INITIALIZER) + as *const Option>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSEnumMemberWithoutInitializer<'a>(pub(crate) *const TSEnumMember<'a>); + +impl<'a> TSEnumMemberWithoutInitializer<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_ENUM_MEMBER_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &TSEnumMemberName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_ENUM_MEMBER_ID) as *const TSEnumMemberName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_ANNOTATION_SPAN: usize = offset_of!(TSTypeAnnotation, span); +pub(crate) const OFFSET_TS_TYPE_ANNOTATION_TYPE_ANNOTATION: usize = + offset_of!(TSTypeAnnotation, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAnnotationWithoutTypeAnnotation<'a>(pub(crate) *const TSTypeAnnotation<'a>); + +impl<'a> TSTypeAnnotationWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ANNOTATION_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_LITERAL_TYPE_SPAN: usize = offset_of!(TSLiteralType, span); +pub(crate) const OFFSET_TS_LITERAL_TYPE_LITERAL: usize = offset_of!(TSLiteralType, literal); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSLiteralTypeWithoutLiteral<'a>(pub(crate) *const TSLiteralType<'a>); + +impl<'a> TSLiteralTypeWithoutLiteral<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_LITERAL_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_CONDITIONAL_TYPE_SPAN: usize = offset_of!(TSConditionalType, span); +pub(crate) const OFFSET_TS_CONDITIONAL_TYPE_CHECK_TYPE: usize = + offset_of!(TSConditionalType, check_type); +pub(crate) const OFFSET_TS_CONDITIONAL_TYPE_EXTENDS_TYPE: usize = + offset_of!(TSConditionalType, extends_type); +pub(crate) const OFFSET_TS_CONDITIONAL_TYPE_TRUE_TYPE: usize = + offset_of!(TSConditionalType, true_type); +pub(crate) const OFFSET_TS_CONDITIONAL_TYPE_FALSE_TYPE: usize = + offset_of!(TSConditionalType, false_type); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConditionalTypeWithoutCheckType<'a>(pub(crate) *const TSConditionalType<'a>); + +impl<'a> TSConditionalTypeWithoutCheckType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn extends_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_EXTENDS_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn true_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_TRUE_TYPE) as *const TSType<'a>) + } + } + + #[inline] + pub fn false_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_FALSE_TYPE) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConditionalTypeWithoutExtendsType<'a>(pub(crate) *const TSConditionalType<'a>); + +impl<'a> TSConditionalTypeWithoutExtendsType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn check_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_CHECK_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn true_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_TRUE_TYPE) as *const TSType<'a>) + } + } + + #[inline] + pub fn false_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_FALSE_TYPE) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConditionalTypeWithoutTrueType<'a>(pub(crate) *const TSConditionalType<'a>); + +impl<'a> TSConditionalTypeWithoutTrueType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn check_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_CHECK_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn extends_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_EXTENDS_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn false_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_FALSE_TYPE) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConditionalTypeWithoutFalseType<'a>(pub(crate) *const TSConditionalType<'a>); + +impl<'a> TSConditionalTypeWithoutFalseType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn check_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_CHECK_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn extends_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_EXTENDS_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn true_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONDITIONAL_TYPE_TRUE_TYPE) as *const TSType<'a>) + } + } +} + +pub(crate) const OFFSET_TS_UNION_TYPE_SPAN: usize = offset_of!(TSUnionType, span); +pub(crate) const OFFSET_TS_UNION_TYPE_TYPES: usize = offset_of!(TSUnionType, types); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSUnionTypeWithoutTypes<'a>(pub(crate) *const TSUnionType<'a>); + +impl<'a> TSUnionTypeWithoutTypes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_UNION_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_INTERSECTION_TYPE_SPAN: usize = offset_of!(TSIntersectionType, span); +pub(crate) const OFFSET_TS_INTERSECTION_TYPE_TYPES: usize = offset_of!(TSIntersectionType, types); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIntersectionTypeWithoutTypes<'a>(pub(crate) *const TSIntersectionType<'a>); + +impl<'a> TSIntersectionTypeWithoutTypes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INTERSECTION_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_TYPE_OPERATOR_SPAN: usize = offset_of!(TSTypeOperator, span); +pub(crate) const OFFSET_TS_TYPE_OPERATOR_OPERATOR: usize = offset_of!(TSTypeOperator, operator); +pub(crate) const OFFSET_TS_TYPE_OPERATOR_TYPE_ANNOTATION: usize = + offset_of!(TSTypeOperator, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeOperatorWithoutTypeAnnotation<'a>(pub(crate) *const TSTypeOperator<'a>); + +impl<'a> TSTypeOperatorWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_OPERATOR_SPAN) as *const Span) } + } + + #[inline] + pub fn operator(&self) -> &TSTypeOperatorOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_OPERATOR_OPERATOR) + as *const TSTypeOperatorOperator) + } + } +} + +pub(crate) const OFFSET_TS_ARRAY_TYPE_SPAN: usize = offset_of!(TSArrayType, span); +pub(crate) const OFFSET_TS_ARRAY_TYPE_ELEMENT_TYPE: usize = offset_of!(TSArrayType, element_type); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSArrayTypeWithoutElementType<'a>(pub(crate) *const TSArrayType<'a>); + +impl<'a> TSArrayTypeWithoutElementType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_ARRAY_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_INDEXED_ACCESS_TYPE_SPAN: usize = offset_of!(TSIndexedAccessType, span); +pub(crate) const OFFSET_TS_INDEXED_ACCESS_TYPE_OBJECT_TYPE: usize = + offset_of!(TSIndexedAccessType, object_type); +pub(crate) const OFFSET_TS_INDEXED_ACCESS_TYPE_INDEX_TYPE: usize = + offset_of!(TSIndexedAccessType, index_type); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIndexedAccessTypeWithoutObjectType<'a>(pub(crate) *const TSIndexedAccessType<'a>); + +impl<'a> TSIndexedAccessTypeWithoutObjectType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEXED_ACCESS_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn index_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INDEXED_ACCESS_TYPE_INDEX_TYPE) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIndexedAccessTypeWithoutIndexType<'a>(pub(crate) *const TSIndexedAccessType<'a>); + +impl<'a> TSIndexedAccessTypeWithoutIndexType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEXED_ACCESS_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn object_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INDEXED_ACCESS_TYPE_OBJECT_TYPE) + as *const TSType<'a>) + } + } +} + +pub(crate) const OFFSET_TS_TUPLE_TYPE_SPAN: usize = offset_of!(TSTupleType, span); +pub(crate) const OFFSET_TS_TUPLE_TYPE_ELEMENT_TYPES: usize = offset_of!(TSTupleType, element_types); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTupleTypeWithoutElementTypes<'a>(pub(crate) *const TSTupleType<'a>); + +impl<'a> TSTupleTypeWithoutElementTypes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TUPLE_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_NAMED_TUPLE_MEMBER_SPAN: usize = offset_of!(TSNamedTupleMember, span); +pub(crate) const OFFSET_TS_NAMED_TUPLE_MEMBER_ELEMENT_TYPE: usize = + offset_of!(TSNamedTupleMember, element_type); +pub(crate) const OFFSET_TS_NAMED_TUPLE_MEMBER_LABEL: usize = offset_of!(TSNamedTupleMember, label); +pub(crate) const OFFSET_TS_NAMED_TUPLE_MEMBER_OPTIONAL: usize = + offset_of!(TSNamedTupleMember, optional); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSNamedTupleMemberWithoutElementType<'a>(pub(crate) *const TSNamedTupleMember<'a>); + +impl<'a> TSNamedTupleMemberWithoutElementType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_SPAN) as *const Span) } + } + + #[inline] + pub fn label(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_LABEL) + as *const IdentifierName<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_OPTIONAL) as *const bool) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSNamedTupleMemberWithoutLabel<'a>(pub(crate) *const TSNamedTupleMember<'a>); + +impl<'a> TSNamedTupleMemberWithoutLabel<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_SPAN) as *const Span) } + } + + #[inline] + pub fn element_type(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_ELEMENT_TYPE) + as *const TSType<'a>) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_NAMED_TUPLE_MEMBER_OPTIONAL) as *const bool) + } + } +} + +pub(crate) const OFFSET_TS_OPTIONAL_TYPE_SPAN: usize = offset_of!(TSOptionalType, span); +pub(crate) const OFFSET_TS_OPTIONAL_TYPE_TYPE_ANNOTATION: usize = + offset_of!(TSOptionalType, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSOptionalTypeWithoutTypeAnnotation<'a>(pub(crate) *const TSOptionalType<'a>); + +impl<'a> TSOptionalTypeWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_OPTIONAL_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_REST_TYPE_SPAN: usize = offset_of!(TSRestType, span); +pub(crate) const OFFSET_TS_REST_TYPE_TYPE_ANNOTATION: usize = + offset_of!(TSRestType, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSRestTypeWithoutTypeAnnotation<'a>(pub(crate) *const TSRestType<'a>); + +impl<'a> TSRestTypeWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_REST_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_TYPE_REFERENCE_SPAN: usize = offset_of!(TSTypeReference, span); +pub(crate) const OFFSET_TS_TYPE_REFERENCE_TYPE_NAME: usize = offset_of!(TSTypeReference, type_name); +pub(crate) const OFFSET_TS_TYPE_REFERENCE_TYPE_PARAMETERS: usize = + offset_of!(TSTypeReference, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeReferenceWithoutTypeName<'a>(pub(crate) *const TSTypeReference<'a>); + +impl<'a> TSTypeReferenceWithoutTypeName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_REFERENCE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_REFERENCE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeReferenceWithoutTypeParameters<'a>(pub(crate) *const TSTypeReference<'a>); + +impl<'a> TSTypeReferenceWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_REFERENCE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_name(&self) -> &TSTypeName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_REFERENCE_TYPE_NAME) + as *const TSTypeName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_QUALIFIED_NAME_SPAN: usize = offset_of!(TSQualifiedName, span); +pub(crate) const OFFSET_TS_QUALIFIED_NAME_LEFT: usize = offset_of!(TSQualifiedName, left); +pub(crate) const OFFSET_TS_QUALIFIED_NAME_RIGHT: usize = offset_of!(TSQualifiedName, right); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSQualifiedNameWithoutLeft<'a>(pub(crate) *const TSQualifiedName<'a>); + +impl<'a> TSQualifiedNameWithoutLeft<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_QUALIFIED_NAME_SPAN) as *const Span) } + } + + #[inline] + pub fn right(&self) -> &IdentifierName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_QUALIFIED_NAME_RIGHT) + as *const IdentifierName<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSQualifiedNameWithoutRight<'a>(pub(crate) *const TSQualifiedName<'a>); + +impl<'a> TSQualifiedNameWithoutRight<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_QUALIFIED_NAME_SPAN) as *const Span) } + } + + #[inline] + pub fn left(&self) -> &TSTypeName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_QUALIFIED_NAME_LEFT) as *const TSTypeName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_PARAMETER_INSTANTIATION_SPAN: usize = + offset_of!(TSTypeParameterInstantiation, span); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_INSTANTIATION_PARAMS: usize = + offset_of!(TSTypeParameterInstantiation, params); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeParameterInstantiationWithoutParams<'a>( + pub(crate) *const TSTypeParameterInstantiation<'a>, +); + +impl<'a> TSTypeParameterInstantiationWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_INSTANTIATION_SPAN) + as *const Span) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_PARAMETER_SPAN: usize = offset_of!(TSTypeParameter, span); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_NAME: usize = offset_of!(TSTypeParameter, name); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_CONSTRAINT: usize = + offset_of!(TSTypeParameter, constraint); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_DEFAULT: usize = offset_of!(TSTypeParameter, default); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_IN: usize = offset_of!(TSTypeParameter, r#in); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_OUT: usize = offset_of!(TSTypeParameter, out); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_CONST: usize = offset_of!(TSTypeParameter, r#const); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeParameterWithoutName<'a>(pub(crate) *const TSTypeParameter<'a>); + +impl<'a> TSTypeParameterWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn constraint(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_CONSTRAINT) + as *const Option>) + } + } + + #[inline] + pub fn default(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_DEFAULT) + as *const Option>) + } + } + + #[inline] + pub fn r#in(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_IN) as *const bool) } + } + + #[inline] + pub fn out(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_OUT) as *const bool) } + } + + #[inline] + pub fn r#const(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_CONST) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeParameterWithoutConstraint<'a>(pub(crate) *const TSTypeParameter<'a>); + +impl<'a> TSTypeParameterWithoutConstraint<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn name(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_NAME) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn default(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_DEFAULT) + as *const Option>) + } + } + + #[inline] + pub fn r#in(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_IN) as *const bool) } + } + + #[inline] + pub fn out(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_OUT) as *const bool) } + } + + #[inline] + pub fn r#const(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_CONST) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeParameterWithoutDefault<'a>(pub(crate) *const TSTypeParameter<'a>); + +impl<'a> TSTypeParameterWithoutDefault<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_SPAN) as *const Span) } + } + + #[inline] + pub fn name(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_NAME) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn constraint(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_CONSTRAINT) + as *const Option>) + } + } + + #[inline] + pub fn r#in(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_IN) as *const bool) } + } + + #[inline] + pub fn out(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_OUT) as *const bool) } + } + + #[inline] + pub fn r#const(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_CONST) as *const bool) } + } +} + +pub(crate) const OFFSET_TS_TYPE_PARAMETER_DECLARATION_SPAN: usize = + offset_of!(TSTypeParameterDeclaration, span); +pub(crate) const OFFSET_TS_TYPE_PARAMETER_DECLARATION_PARAMS: usize = + offset_of!(TSTypeParameterDeclaration, params); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeParameterDeclarationWithoutParams<'a>( + pub(crate) *const TSTypeParameterDeclaration<'a>, +); + +impl<'a> TSTypeParameterDeclarationWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PARAMETER_DECLARATION_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_ALIAS_DECLARATION_SPAN: usize = + offset_of!(TSTypeAliasDeclaration, span); +pub(crate) const OFFSET_TS_TYPE_ALIAS_DECLARATION_ID: usize = + offset_of!(TSTypeAliasDeclaration, id); +pub(crate) const OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION: usize = + offset_of!(TSTypeAliasDeclaration, type_annotation); +pub(crate) const OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS: usize = + offset_of!(TSTypeAliasDeclaration, type_parameters); +pub(crate) const OFFSET_TS_TYPE_ALIAS_DECLARATION_MODIFIERS: usize = + offset_of!(TSTypeAliasDeclaration, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAliasDeclarationWithoutId<'a>(pub(crate) *const TSTypeAliasDeclaration<'a>); + +impl<'a> TSTypeAliasDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn type_annotation(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION) + as *const TSType<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAliasDeclarationWithoutTypeAnnotation<'a>( + pub(crate) *const TSTypeAliasDeclaration<'a>, +); + +impl<'a> TSTypeAliasDeclarationWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAliasDeclarationWithoutTypeParameters<'a>( + pub(crate) *const TSTypeAliasDeclaration<'a>, +); + +impl<'a> TSTypeAliasDeclarationWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn type_annotation(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION) + as *const TSType<'a>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ALIAS_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +pub(crate) const OFFSET_TS_CLASS_IMPLEMENTS_SPAN: usize = offset_of!(TSClassImplements, span); +pub(crate) const OFFSET_TS_CLASS_IMPLEMENTS_EXPRESSION: usize = + offset_of!(TSClassImplements, expression); +pub(crate) const OFFSET_TS_CLASS_IMPLEMENTS_TYPE_PARAMETERS: usize = + offset_of!(TSClassImplements, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSClassImplementsWithoutExpression<'a>(pub(crate) *const TSClassImplements<'a>); + +impl<'a> TSClassImplementsWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CLASS_IMPLEMENTS_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CLASS_IMPLEMENTS_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSClassImplementsWithoutTypeParameters<'a>(pub(crate) *const TSClassImplements<'a>); + +impl<'a> TSClassImplementsWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CLASS_IMPLEMENTS_SPAN) as *const Span) } + } + + #[inline] + pub fn expression(&self) -> &TSTypeName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CLASS_IMPLEMENTS_EXPRESSION) + as *const TSTypeName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_SPAN: usize = + offset_of!(TSInterfaceDeclaration, span); +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_ID: usize = offset_of!(TSInterfaceDeclaration, id); +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_BODY: usize = + offset_of!(TSInterfaceDeclaration, body); +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS: usize = + offset_of!(TSInterfaceDeclaration, type_parameters); +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_EXTENDS: usize = + offset_of!(TSInterfaceDeclaration, extends); +pub(crate) const OFFSET_TS_INTERFACE_DECLARATION_MODIFIERS: usize = + offset_of!(TSInterfaceDeclaration, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceDeclarationWithoutId<'a>(pub(crate) *const TSInterfaceDeclaration<'a>); + +impl<'a> TSInterfaceDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, TSInterfaceBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_BODY) + as *const Box<'a, TSInterfaceBody<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn extends(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_EXTENDS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceDeclarationWithoutBody<'a>(pub(crate) *const TSInterfaceDeclaration<'a>); + +impl<'a> TSInterfaceDeclarationWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn extends(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_EXTENDS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceDeclarationWithoutTypeParameters<'a>( + pub(crate) *const TSInterfaceDeclaration<'a>, +); + +impl<'a> TSInterfaceDeclarationWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, TSInterfaceBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_BODY) + as *const Box<'a, TSInterfaceBody<'a>>) + } + } + + #[inline] + pub fn extends(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_EXTENDS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceDeclarationWithoutExtends<'a>(pub(crate) *const TSInterfaceDeclaration<'a>); + +impl<'a> TSInterfaceDeclarationWithoutExtends<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn body(&self) -> &Box<'a, TSInterfaceBody<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_BODY) + as *const Box<'a, TSInterfaceBody<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +pub(crate) const OFFSET_TS_INTERFACE_BODY_SPAN: usize = offset_of!(TSInterfaceBody, span); +pub(crate) const OFFSET_TS_INTERFACE_BODY_BODY: usize = offset_of!(TSInterfaceBody, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceBodyWithoutBody<'a>(pub(crate) *const TSInterfaceBody<'a>); + +impl<'a> TSInterfaceBodyWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_BODY_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_SPAN: usize = offset_of!(TSPropertySignature, span); +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_COMPUTED: usize = + offset_of!(TSPropertySignature, computed); +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_OPTIONAL: usize = + offset_of!(TSPropertySignature, optional); +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_READONLY: usize = + offset_of!(TSPropertySignature, readonly); +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_KEY: usize = offset_of!(TSPropertySignature, key); +pub(crate) const OFFSET_TS_PROPERTY_SIGNATURE_TYPE_ANNOTATION: usize = + offset_of!(TSPropertySignature, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSPropertySignatureWithoutKey<'a>(pub(crate) *const TSPropertySignature<'a>); + +impl<'a> TSPropertySignatureWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_COMPUTED) as *const bool) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_OPTIONAL) as *const bool) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_READONLY) as *const bool) + } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_TYPE_ANNOTATION) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSPropertySignatureWithoutTypeAnnotation<'a>(pub(crate) *const TSPropertySignature<'a>); + +impl<'a> TSPropertySignatureWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_COMPUTED) as *const bool) + } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_OPTIONAL) as *const bool) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_READONLY) as *const bool) + } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_PROPERTY_SIGNATURE_KEY) + as *const PropertyKey<'a>) + } + } +} + +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_SPAN: usize = offset_of!(TSIndexSignature, span); +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_PARAMETERS: usize = + offset_of!(TSIndexSignature, parameters); +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_TYPE_ANNOTATION: usize = + offset_of!(TSIndexSignature, type_annotation); +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_READONLY: usize = offset_of!(TSIndexSignature, readonly); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIndexSignatureWithoutParameters<'a>(pub(crate) *const TSIndexSignature<'a>); + +impl<'a> TSIndexSignatureWithoutParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_annotation(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_TYPE_ANNOTATION) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_READONLY) as *const bool) } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIndexSignatureWithoutTypeAnnotation<'a>(pub(crate) *const TSIndexSignature<'a>); + +impl<'a> TSIndexSignatureWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn parameters(&self) -> &Vec<'a, TSIndexSignatureName<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_PARAMETERS) + as *const Vec<'a, TSIndexSignatureName<'a>>) + } + } + + #[inline] + pub fn readonly(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_READONLY) as *const bool) } + } +} + +pub(crate) const OFFSET_TS_CALL_SIGNATURE_DECLARATION_SPAN: usize = + offset_of!(TSCallSignatureDeclaration, span); +pub(crate) const OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM: usize = + offset_of!(TSCallSignatureDeclaration, this_param); +pub(crate) const OFFSET_TS_CALL_SIGNATURE_DECLARATION_PARAMS: usize = + offset_of!(TSCallSignatureDeclaration, params); +pub(crate) const OFFSET_TS_CALL_SIGNATURE_DECLARATION_RETURN_TYPE: usize = + offset_of!(TSCallSignatureDeclaration, return_type); +pub(crate) const OFFSET_TS_CALL_SIGNATURE_DECLARATION_TYPE_PARAMETERS: usize = + offset_of!(TSCallSignatureDeclaration, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSCallSignatureDeclarationWithoutThisParam<'a>( + pub(crate) *const TSCallSignatureDeclaration<'a>, +); + +impl<'a> TSCallSignatureDeclarationWithoutThisParam<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSCallSignatureDeclarationWithoutParams<'a>( + pub(crate) *const TSCallSignatureDeclaration<'a>, +); + +impl<'a> TSCallSignatureDeclarationWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSCallSignatureDeclarationWithoutReturnType<'a>( + pub(crate) *const TSCallSignatureDeclaration<'a>, +); + +impl<'a> TSCallSignatureDeclarationWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSCallSignatureDeclarationWithoutTypeParameters<'a>( + pub(crate) *const TSCallSignatureDeclaration<'a>, +); + +impl<'a> TSCallSignatureDeclarationWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_RETURN_TYPE) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_SPAN: usize = offset_of!(TSMethodSignature, span); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_KEY: usize = offset_of!(TSMethodSignature, key); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_COMPUTED: usize = + offset_of!(TSMethodSignature, computed); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_OPTIONAL: usize = + offset_of!(TSMethodSignature, optional); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_KIND: usize = offset_of!(TSMethodSignature, kind); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM: usize = + offset_of!(TSMethodSignature, this_param); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_PARAMS: usize = offset_of!(TSMethodSignature, params); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE: usize = + offset_of!(TSMethodSignature, return_type); +pub(crate) const OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS: usize = + offset_of!(TSMethodSignature, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMethodSignatureWithoutKey<'a>(pub(crate) *const TSMethodSignature<'a>); + +impl<'a> TSMethodSignatureWithoutKey<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_COMPUTED) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn kind(&self) -> &TSMethodSignatureKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KIND) + as *const TSMethodSignatureKind) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMethodSignatureWithoutThisParam<'a>(pub(crate) *const TSMethodSignature<'a>); + +impl<'a> TSMethodSignatureWithoutThisParam<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_COMPUTED) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn kind(&self) -> &TSMethodSignatureKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KIND) + as *const TSMethodSignatureKind) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMethodSignatureWithoutParams<'a>(pub(crate) *const TSMethodSignature<'a>); + +impl<'a> TSMethodSignatureWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_COMPUTED) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn kind(&self) -> &TSMethodSignatureKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KIND) + as *const TSMethodSignatureKind) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMethodSignatureWithoutReturnType<'a>(pub(crate) *const TSMethodSignature<'a>); + +impl<'a> TSMethodSignatureWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_COMPUTED) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn kind(&self) -> &TSMethodSignatureKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KIND) + as *const TSMethodSignatureKind) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMethodSignatureWithoutTypeParameters<'a>(pub(crate) *const TSMethodSignature<'a>); + +impl<'a> TSMethodSignatureWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_SPAN) as *const Span) } + } + + #[inline] + pub fn key(&self) -> &PropertyKey<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KEY) as *const PropertyKey<'a>) + } + } + + #[inline] + pub fn computed(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_COMPUTED) as *const bool) } + } + + #[inline] + pub fn optional(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_OPTIONAL) as *const bool) } + } + + #[inline] + pub fn kind(&self) -> &TSMethodSignatureKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_KIND) + as *const TSMethodSignatureKind) + } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SPAN: usize = + offset_of!(TSConstructSignatureDeclaration, span); +pub(crate) const OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_PARAMS: usize = + offset_of!(TSConstructSignatureDeclaration, params); +pub(crate) const OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_RETURN_TYPE: usize = + offset_of!(TSConstructSignatureDeclaration, return_type); +pub(crate) const OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_TYPE_PARAMETERS: usize = + offset_of!(TSConstructSignatureDeclaration, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructSignatureDeclarationWithoutParams<'a>( + pub(crate) *const TSConstructSignatureDeclaration<'a>, +); + +impl<'a> TSConstructSignatureDeclarationWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SPAN) + as *const Span) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_RETURN_TYPE) + as *const Option>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructSignatureDeclarationWithoutReturnType<'a>( + pub(crate) *const TSConstructSignatureDeclaration<'a>, +); + +impl<'a> TSConstructSignatureDeclarationWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SPAN) + as *const Span) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructSignatureDeclarationWithoutTypeParameters<'a>( + pub(crate) *const TSConstructSignatureDeclaration<'a>, +); + +impl<'a> TSConstructSignatureDeclarationWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SPAN) + as *const Span) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_RETURN_TYPE) + as *const Option>>) + } + } +} + +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_NAME_SPAN: usize = + offset_of!(TSIndexSignatureName, span); +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_NAME_NAME: usize = + offset_of!(TSIndexSignatureName, name); +pub(crate) const OFFSET_TS_INDEX_SIGNATURE_NAME_TYPE_ANNOTATION: usize = + offset_of!(TSIndexSignatureName, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSIndexSignatureNameWithoutTypeAnnotation<'a>( + pub(crate) *const TSIndexSignatureName<'a>, +); + +impl<'a> TSIndexSignatureNameWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_NAME_SPAN) as *const Span) } + } + + #[inline] + pub fn name(&self) -> &Atom<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INDEX_SIGNATURE_NAME_NAME) as *const Atom<'a>) + } + } +} + +pub(crate) const OFFSET_TS_INTERFACE_HERITAGE_SPAN: usize = offset_of!(TSInterfaceHeritage, span); +pub(crate) const OFFSET_TS_INTERFACE_HERITAGE_EXPRESSION: usize = + offset_of!(TSInterfaceHeritage, expression); +pub(crate) const OFFSET_TS_INTERFACE_HERITAGE_TYPE_PARAMETERS: usize = + offset_of!(TSInterfaceHeritage, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceHeritageWithoutExpression<'a>(pub(crate) *const TSInterfaceHeritage<'a>); + +impl<'a> TSInterfaceHeritageWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_HERITAGE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_HERITAGE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInterfaceHeritageWithoutTypeParameters<'a>(pub(crate) *const TSInterfaceHeritage<'a>); + +impl<'a> TSInterfaceHeritageWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_HERITAGE_SPAN) as *const Span) } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INTERFACE_HERITAGE_EXPRESSION) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_PREDICATE_SPAN: usize = offset_of!(TSTypePredicate, span); +pub(crate) const OFFSET_TS_TYPE_PREDICATE_PARAMETER_NAME: usize = + offset_of!(TSTypePredicate, parameter_name); +pub(crate) const OFFSET_TS_TYPE_PREDICATE_ASSERTS: usize = offset_of!(TSTypePredicate, asserts); +pub(crate) const OFFSET_TS_TYPE_PREDICATE_TYPE_ANNOTATION: usize = + offset_of!(TSTypePredicate, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypePredicateWithoutParameterName<'a>(pub(crate) *const TSTypePredicate<'a>); + +impl<'a> TSTypePredicateWithoutParameterName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_SPAN) as *const Span) } + } + + #[inline] + pub fn asserts(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_ASSERTS) as *const bool) } + } + + #[inline] + pub fn type_annotation(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_TYPE_ANNOTATION) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypePredicateWithoutTypeAnnotation<'a>(pub(crate) *const TSTypePredicate<'a>); + +impl<'a> TSTypePredicateWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_SPAN) as *const Span) } + } + + #[inline] + pub fn parameter_name(&self) -> &TSTypePredicateName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_PARAMETER_NAME) + as *const TSTypePredicateName<'a>) + } + } + + #[inline] + pub fn asserts(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_PREDICATE_ASSERTS) as *const bool) } + } +} + +pub(crate) const OFFSET_TS_MODULE_DECLARATION_SPAN: usize = offset_of!(TSModuleDeclaration, span); +pub(crate) const OFFSET_TS_MODULE_DECLARATION_ID: usize = offset_of!(TSModuleDeclaration, id); +pub(crate) const OFFSET_TS_MODULE_DECLARATION_BODY: usize = offset_of!(TSModuleDeclaration, body); +pub(crate) const OFFSET_TS_MODULE_DECLARATION_KIND: usize = offset_of!(TSModuleDeclaration, kind); +pub(crate) const OFFSET_TS_MODULE_DECLARATION_MODIFIERS: usize = + offset_of!(TSModuleDeclaration, modifiers); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSModuleDeclarationWithoutId<'a>(pub(crate) *const TSModuleDeclaration<'a>); + +impl<'a> TSModuleDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn body(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_BODY) + as *const Option>) + } + } + + #[inline] + pub fn kind(&self) -> &TSModuleDeclarationKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_KIND) + as *const TSModuleDeclarationKind) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSModuleDeclarationWithoutBody<'a>(pub(crate) *const TSModuleDeclaration<'a>); + +impl<'a> TSModuleDeclarationWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_SPAN) as *const Span) } + } + + #[inline] + pub fn id(&self) -> &TSModuleDeclarationName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_ID) + as *const TSModuleDeclarationName<'a>) + } + } + + #[inline] + pub fn kind(&self) -> &TSModuleDeclarationKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_KIND) + as *const TSModuleDeclarationKind) + } + } + + #[inline] + pub fn modifiers(&self) -> &Modifiers<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MODULE_DECLARATION_MODIFIERS) + as *const Modifiers<'a>) + } + } +} + +pub(crate) const OFFSET_TS_MODULE_BLOCK_SPAN: usize = offset_of!(TSModuleBlock, span); +pub(crate) const OFFSET_TS_MODULE_BLOCK_BODY: usize = offset_of!(TSModuleBlock, body); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSModuleBlockWithoutBody<'a>(pub(crate) *const TSModuleBlock<'a>); + +impl<'a> TSModuleBlockWithoutBody<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MODULE_BLOCK_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_TYPE_LITERAL_SPAN: usize = offset_of!(TSTypeLiteral, span); +pub(crate) const OFFSET_TS_TYPE_LITERAL_MEMBERS: usize = offset_of!(TSTypeLiteral, members); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeLiteralWithoutMembers<'a>(pub(crate) *const TSTypeLiteral<'a>); + +impl<'a> TSTypeLiteralWithoutMembers<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_LITERAL_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_INFER_TYPE_SPAN: usize = offset_of!(TSInferType, span); +pub(crate) const OFFSET_TS_INFER_TYPE_TYPE_PARAMETER: usize = + offset_of!(TSInferType, type_parameter); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInferTypeWithoutTypeParameter<'a>(pub(crate) *const TSInferType<'a>); + +impl<'a> TSInferTypeWithoutTypeParameter<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_INFER_TYPE_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_TYPE_QUERY_SPAN: usize = offset_of!(TSTypeQuery, span); +pub(crate) const OFFSET_TS_TYPE_QUERY_EXPR_NAME: usize = offset_of!(TSTypeQuery, expr_name); +pub(crate) const OFFSET_TS_TYPE_QUERY_TYPE_PARAMETERS: usize = + offset_of!(TSTypeQuery, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeQueryWithoutExprName<'a>(pub(crate) *const TSTypeQuery<'a>); + +impl<'a> TSTypeQueryWithoutExprName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_QUERY_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_QUERY_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeQueryWithoutTypeParameters<'a>(pub(crate) *const TSTypeQuery<'a>); + +impl<'a> TSTypeQueryWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_QUERY_SPAN) as *const Span) } + } + + #[inline] + pub fn expr_name(&self) -> &TSTypeQueryExprName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_QUERY_EXPR_NAME) + as *const TSTypeQueryExprName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_IMPORT_TYPE_SPAN: usize = offset_of!(TSImportType, span); +pub(crate) const OFFSET_TS_IMPORT_TYPE_ARGUMENT: usize = offset_of!(TSImportType, argument); +pub(crate) const OFFSET_TS_IMPORT_TYPE_QUALIFIER: usize = offset_of!(TSImportType, qualifier); +pub(crate) const OFFSET_TS_IMPORT_TYPE_ATTRIBUTES: usize = offset_of!(TSImportType, attributes); +pub(crate) const OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS: usize = + offset_of!(TSImportType, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportTypeWithoutArgument<'a>(pub(crate) *const TSImportType<'a>); + +impl<'a> TSImportTypeWithoutArgument<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn qualifier(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_QUALIFIER) + as *const Option>) + } + } + + #[inline] + pub fn attributes(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) + as *const Option>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportTypeWithoutQualifier<'a>(pub(crate) *const TSImportType<'a>); + +impl<'a> TSImportTypeWithoutQualifier<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn argument(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) + } + } + + #[inline] + pub fn attributes(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) + as *const Option>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportTypeWithoutAttributes<'a>(pub(crate) *const TSImportType<'a>); + +impl<'a> TSImportTypeWithoutAttributes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn argument(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) + } + } + + #[inline] + pub fn qualifier(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_QUALIFIER) + as *const Option>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportTypeWithoutTypeParameters<'a>(pub(crate) *const TSImportType<'a>); + +impl<'a> TSImportTypeWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn argument(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *const TSType<'a>) + } + } + + #[inline] + pub fn qualifier(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_QUALIFIER) + as *const Option>) + } + } + + #[inline] + pub fn attributes(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) + as *const Option>) + } + } +} + +pub(crate) const OFFSET_TS_IMPORT_ATTRIBUTES_SPAN: usize = offset_of!(TSImportAttributes, span); +pub(crate) const OFFSET_TS_IMPORT_ATTRIBUTES_ELEMENTS: usize = + offset_of!(TSImportAttributes, elements); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportAttributesWithoutElements<'a>(pub(crate) *const TSImportAttributes<'a>); + +impl<'a> TSImportAttributesWithoutElements<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_ATTRIBUTES_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_IMPORT_ATTRIBUTE_SPAN: usize = offset_of!(TSImportAttribute, span); +pub(crate) const OFFSET_TS_IMPORT_ATTRIBUTE_NAME: usize = offset_of!(TSImportAttribute, name); +pub(crate) const OFFSET_TS_IMPORT_ATTRIBUTE_VALUE: usize = offset_of!(TSImportAttribute, value); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportAttributeWithoutName<'a>(pub(crate) *const TSImportAttribute<'a>); + +impl<'a> TSImportAttributeWithoutName<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn value(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_ATTRIBUTE_VALUE) as *const Expression<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportAttributeWithoutValue<'a>(pub(crate) *const TSImportAttribute<'a>); + +impl<'a> TSImportAttributeWithoutValue<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_ATTRIBUTE_SPAN) as *const Span) } + } + + #[inline] + pub fn name(&self) -> &TSImportAttributeName<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_ATTRIBUTE_NAME) + as *const TSImportAttributeName<'a>) + } + } +} + +pub(crate) const OFFSET_TS_FUNCTION_TYPE_SPAN: usize = offset_of!(TSFunctionType, span); +pub(crate) const OFFSET_TS_FUNCTION_TYPE_THIS_PARAM: usize = offset_of!(TSFunctionType, this_param); +pub(crate) const OFFSET_TS_FUNCTION_TYPE_PARAMS: usize = offset_of!(TSFunctionType, params); +pub(crate) const OFFSET_TS_FUNCTION_TYPE_RETURN_TYPE: usize = + offset_of!(TSFunctionType, return_type); +pub(crate) const OFFSET_TS_FUNCTION_TYPE_TYPE_PARAMETERS: usize = + offset_of!(TSFunctionType, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSFunctionTypeWithoutThisParam<'a>(pub(crate) *const TSFunctionType<'a>); + +impl<'a> TSFunctionTypeWithoutThisParam<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_RETURN_TYPE) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSFunctionTypeWithoutParams<'a>(pub(crate) *const TSFunctionType<'a>); + +impl<'a> TSFunctionTypeWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn return_type(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_RETURN_TYPE) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSFunctionTypeWithoutReturnType<'a>(pub(crate) *const TSFunctionType<'a>); + +impl<'a> TSFunctionTypeWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSFunctionTypeWithoutTypeParameters<'a>(pub(crate) *const TSFunctionType<'a>); + +impl<'a> TSFunctionTypeWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn this_param(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_THIS_PARAM) + as *const Option>) + } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_FUNCTION_TYPE_RETURN_TYPE) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } +} + +pub(crate) const OFFSET_TS_CONSTRUCTOR_TYPE_SPAN: usize = offset_of!(TSConstructorType, span); +pub(crate) const OFFSET_TS_CONSTRUCTOR_TYPE_ABSTRACT: usize = + offset_of!(TSConstructorType, r#abstract); +pub(crate) const OFFSET_TS_CONSTRUCTOR_TYPE_PARAMS: usize = offset_of!(TSConstructorType, params); +pub(crate) const OFFSET_TS_CONSTRUCTOR_TYPE_RETURN_TYPE: usize = + offset_of!(TSConstructorType, return_type); +pub(crate) const OFFSET_TS_CONSTRUCTOR_TYPE_TYPE_PARAMETERS: usize = + offset_of!(TSConstructorType, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructorTypeWithoutParams<'a>(pub(crate) *const TSConstructorType<'a>); + +impl<'a> TSConstructorTypeWithoutParams<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn r#abstract(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_ABSTRACT) as *const bool) } + } + + #[inline] + pub fn return_type(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_RETURN_TYPE) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructorTypeWithoutReturnType<'a>(pub(crate) *const TSConstructorType<'a>); + +impl<'a> TSConstructorTypeWithoutReturnType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn r#abstract(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_ABSTRACT) as *const bool) } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Option>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_TYPE_PARAMETERS) + as *const Option>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSConstructorTypeWithoutTypeParameters<'a>(pub(crate) *const TSConstructorType<'a>); + +impl<'a> TSConstructorTypeWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn r#abstract(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_ABSTRACT) as *const bool) } + } + + #[inline] + pub fn params(&self) -> &Box<'a, FormalParameters<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_PARAMS) + as *const Box<'a, FormalParameters<'a>>) + } + } + + #[inline] + pub fn return_type(&self) -> &Box<'a, TSTypeAnnotation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_CONSTRUCTOR_TYPE_RETURN_TYPE) + as *const Box<'a, TSTypeAnnotation<'a>>) + } + } +} + +pub(crate) const OFFSET_TS_MAPPED_TYPE_SPAN: usize = offset_of!(TSMappedType, span); +pub(crate) const OFFSET_TS_MAPPED_TYPE_TYPE_PARAMETER: usize = + offset_of!(TSMappedType, type_parameter); +pub(crate) const OFFSET_TS_MAPPED_TYPE_NAME_TYPE: usize = offset_of!(TSMappedType, name_type); +pub(crate) const OFFSET_TS_MAPPED_TYPE_TYPE_ANNOTATION: usize = + offset_of!(TSMappedType, type_annotation); +pub(crate) const OFFSET_TS_MAPPED_TYPE_OPTIONAL: usize = offset_of!(TSMappedType, optional); +pub(crate) const OFFSET_TS_MAPPED_TYPE_READONLY: usize = offset_of!(TSMappedType, readonly); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMappedTypeWithoutTypeParameter<'a>(pub(crate) *const TSMappedType<'a>); + +impl<'a> TSMappedTypeWithoutTypeParameter<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn name_type(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_NAME_TYPE) + as *const Option>) + } + } + + #[inline] + pub fn type_annotation(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_TYPE_ANNOTATION) + as *const Option>) + } + } + + #[inline] + pub fn optional(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_OPTIONAL) + as *const TSMappedTypeModifierOperator) + } + } + + #[inline] + pub fn readonly(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_READONLY) + as *const TSMappedTypeModifierOperator) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMappedTypeWithoutNameType<'a>(pub(crate) *const TSMappedType<'a>); + +impl<'a> TSMappedTypeWithoutNameType<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameter(&self) -> &Box<'a, TSTypeParameter<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_TYPE_PARAMETER) + as *const Box<'a, TSTypeParameter<'a>>) + } + } + + #[inline] + pub fn type_annotation(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_TYPE_ANNOTATION) + as *const Option>) + } + } + + #[inline] + pub fn optional(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_OPTIONAL) + as *const TSMappedTypeModifierOperator) + } + } + + #[inline] + pub fn readonly(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_READONLY) + as *const TSMappedTypeModifierOperator) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSMappedTypeWithoutTypeAnnotation<'a>(pub(crate) *const TSMappedType<'a>); + +impl<'a> TSMappedTypeWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn type_parameter(&self) -> &Box<'a, TSTypeParameter<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_TYPE_PARAMETER) + as *const Box<'a, TSTypeParameter<'a>>) + } + } + + #[inline] + pub fn name_type(&self) -> &Option> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_NAME_TYPE) + as *const Option>) + } + } + + #[inline] + pub fn optional(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_OPTIONAL) + as *const TSMappedTypeModifierOperator) + } + } + + #[inline] + pub fn readonly(&self) -> &TSMappedTypeModifierOperator { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_MAPPED_TYPE_READONLY) + as *const TSMappedTypeModifierOperator) + } + } +} + +pub(crate) const OFFSET_TS_TEMPLATE_LITERAL_TYPE_SPAN: usize = + offset_of!(TSTemplateLiteralType, span); +pub(crate) const OFFSET_TS_TEMPLATE_LITERAL_TYPE_QUASIS: usize = + offset_of!(TSTemplateLiteralType, quasis); +pub(crate) const OFFSET_TS_TEMPLATE_LITERAL_TYPE_TYPES: usize = + offset_of!(TSTemplateLiteralType, types); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTemplateLiteralTypeWithoutQuasis<'a>(pub(crate) *const TSTemplateLiteralType<'a>); + +impl<'a> TSTemplateLiteralTypeWithoutQuasis<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TEMPLATE_LITERAL_TYPE_SPAN) as *const Span) + } + } + + #[inline] + pub fn types(&self) -> &Vec<'a, TSType<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TEMPLATE_LITERAL_TYPE_TYPES) + as *const Vec<'a, TSType<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTemplateLiteralTypeWithoutTypes<'a>(pub(crate) *const TSTemplateLiteralType<'a>); + +impl<'a> TSTemplateLiteralTypeWithoutTypes<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TEMPLATE_LITERAL_TYPE_SPAN) as *const Span) + } + } + + #[inline] + pub fn quasis(&self) -> &Vec<'a, TemplateElement<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TEMPLATE_LITERAL_TYPE_QUASIS) + as *const Vec<'a, TemplateElement<'a>>) + } + } +} + +pub(crate) const OFFSET_TS_AS_EXPRESSION_SPAN: usize = offset_of!(TSAsExpression, span); +pub(crate) const OFFSET_TS_AS_EXPRESSION_EXPRESSION: usize = offset_of!(TSAsExpression, expression); +pub(crate) const OFFSET_TS_AS_EXPRESSION_TYPE_ANNOTATION: usize = + offset_of!(TSAsExpression, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSAsExpressionWithoutExpression<'a>(pub(crate) *const TSAsExpression<'a>); + +impl<'a> TSAsExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_AS_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn type_annotation(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_AS_EXPRESSION_TYPE_ANNOTATION) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSAsExpressionWithoutTypeAnnotation<'a>(pub(crate) *const TSAsExpression<'a>); + +impl<'a> TSAsExpressionWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_AS_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_AS_EXPRESSION_EXPRESSION) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_TS_SATISFIES_EXPRESSION_SPAN: usize = + offset_of!(TSSatisfiesExpression, span); +pub(crate) const OFFSET_TS_SATISFIES_EXPRESSION_EXPRESSION: usize = + offset_of!(TSSatisfiesExpression, expression); +pub(crate) const OFFSET_TS_SATISFIES_EXPRESSION_TYPE_ANNOTATION: usize = + offset_of!(TSSatisfiesExpression, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSSatisfiesExpressionWithoutExpression<'a>(pub(crate) *const TSSatisfiesExpression<'a>); + +impl<'a> TSSatisfiesExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_SATISFIES_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn type_annotation(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_SATISFIES_EXPRESSION_TYPE_ANNOTATION) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSSatisfiesExpressionWithoutTypeAnnotation<'a>( + pub(crate) *const TSSatisfiesExpression<'a>, +); + +impl<'a> TSSatisfiesExpressionWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_SATISFIES_EXPRESSION_SPAN) as *const Span) } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_SATISFIES_EXPRESSION_EXPRESSION) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_TS_TYPE_ASSERTION_SPAN: usize = offset_of!(TSTypeAssertion, span); +pub(crate) const OFFSET_TS_TYPE_ASSERTION_EXPRESSION: usize = + offset_of!(TSTypeAssertion, expression); +pub(crate) const OFFSET_TS_TYPE_ASSERTION_TYPE_ANNOTATION: usize = + offset_of!(TSTypeAssertion, type_annotation); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAssertionWithoutExpression<'a>(pub(crate) *const TSTypeAssertion<'a>); + +impl<'a> TSTypeAssertionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ASSERTION_SPAN) as *const Span) } + } + + #[inline] + pub fn type_annotation(&self) -> &TSType<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ASSERTION_TYPE_ANNOTATION) + as *const TSType<'a>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSTypeAssertionWithoutTypeAnnotation<'a>(pub(crate) *const TSTypeAssertion<'a>); + +impl<'a> TSTypeAssertionWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ASSERTION_SPAN) as *const Span) } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_TYPE_ASSERTION_EXPRESSION) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_TS_IMPORT_EQUALS_DECLARATION_SPAN: usize = + offset_of!(TSImportEqualsDeclaration, span); +pub(crate) const OFFSET_TS_IMPORT_EQUALS_DECLARATION_ID: usize = + offset_of!(TSImportEqualsDeclaration, id); +pub(crate) const OFFSET_TS_IMPORT_EQUALS_DECLARATION_MODULE_REFERENCE: usize = + offset_of!(TSImportEqualsDeclaration, module_reference); +pub(crate) const OFFSET_TS_IMPORT_EQUALS_DECLARATION_IMPORT_KIND: usize = + offset_of!(TSImportEqualsDeclaration, import_kind); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportEqualsDeclarationWithoutId<'a>(pub(crate) *const TSImportEqualsDeclaration<'a>); + +impl<'a> TSImportEqualsDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn module_reference(&self) -> &TSModuleReference<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_MODULE_REFERENCE) + as *const TSModuleReference<'a>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSImportEqualsDeclarationWithoutModuleReference<'a>( + pub(crate) *const TSImportEqualsDeclaration<'a>, +); + +impl<'a> TSImportEqualsDeclarationWithoutModuleReference<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_SPAN) as *const Span) + } + } + + #[inline] + pub fn id(&self) -> &BindingIdentifier<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_ID) + as *const BindingIdentifier<'a>) + } + } + + #[inline] + pub fn import_kind(&self) -> &ImportOrExportKind { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_IMPORT_EQUALS_DECLARATION_IMPORT_KIND) + as *const ImportOrExportKind) + } + } +} + +pub(crate) const OFFSET_TS_EXTERNAL_MODULE_REFERENCE_SPAN: usize = + offset_of!(TSExternalModuleReference, span); +pub(crate) const OFFSET_TS_EXTERNAL_MODULE_REFERENCE_EXPRESSION: usize = + offset_of!(TSExternalModuleReference, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSExternalModuleReferenceWithoutExpression<'a>( + pub(crate) *const TSExternalModuleReference<'a>, +); + +impl<'a> TSExternalModuleReferenceWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_EXTERNAL_MODULE_REFERENCE_SPAN) as *const Span) + } + } +} + +pub(crate) const OFFSET_TS_NON_NULL_EXPRESSION_SPAN: usize = offset_of!(TSNonNullExpression, span); +pub(crate) const OFFSET_TS_NON_NULL_EXPRESSION_EXPRESSION: usize = + offset_of!(TSNonNullExpression, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSNonNullExpressionWithoutExpression<'a>(pub(crate) *const TSNonNullExpression<'a>); + +impl<'a> TSNonNullExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_NON_NULL_EXPRESSION_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_DECORATOR_SPAN: usize = offset_of!(Decorator, span); +pub(crate) const OFFSET_DECORATOR_EXPRESSION: usize = offset_of!(Decorator, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct DecoratorWithoutExpression<'a>(pub(crate) *const Decorator<'a>); + +impl<'a> DecoratorWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_DECORATOR_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_EXPORT_ASSIGNMENT_SPAN: usize = offset_of!(TSExportAssignment, span); +pub(crate) const OFFSET_TS_EXPORT_ASSIGNMENT_EXPRESSION: usize = + offset_of!(TSExportAssignment, expression); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSExportAssignmentWithoutExpression<'a>(pub(crate) *const TSExportAssignment<'a>); + +impl<'a> TSExportAssignmentWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_TS_EXPORT_ASSIGNMENT_SPAN) as *const Span) } + } +} + +pub(crate) const OFFSET_TS_NAMESPACE_EXPORT_DECLARATION_SPAN: usize = + offset_of!(TSNamespaceExportDeclaration, span); +pub(crate) const OFFSET_TS_NAMESPACE_EXPORT_DECLARATION_ID: usize = + offset_of!(TSNamespaceExportDeclaration, id); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSNamespaceExportDeclarationWithoutId<'a>( + pub(crate) *const TSNamespaceExportDeclaration<'a>, +); + +impl<'a> TSNamespaceExportDeclarationWithoutId<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_NAMESPACE_EXPORT_DECLARATION_SPAN) + as *const Span) + } + } +} + +pub(crate) const OFFSET_TS_INSTANTIATION_EXPRESSION_SPAN: usize = + offset_of!(TSInstantiationExpression, span); +pub(crate) const OFFSET_TS_INSTANTIATION_EXPRESSION_EXPRESSION: usize = + offset_of!(TSInstantiationExpression, expression); +pub(crate) const OFFSET_TS_INSTANTIATION_EXPRESSION_TYPE_PARAMETERS: usize = + offset_of!(TSInstantiationExpression, type_parameters); + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInstantiationExpressionWithoutExpression<'a>( + pub(crate) *const TSInstantiationExpression<'a>, +); + +impl<'a> TSInstantiationExpressionWithoutExpression<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INSTANTIATION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn type_parameters(&self) -> &Box<'a, TSTypeParameterInstantiation<'a>> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INSTANTIATION_EXPRESSION_TYPE_PARAMETERS) + as *const Box<'a, TSTypeParameterInstantiation<'a>>) + } + } +} + +#[repr(transparent)] +#[derive(Debug)] +pub struct TSInstantiationExpressionWithoutTypeParameters<'a>( + pub(crate) *const TSInstantiationExpression<'a>, +); + +impl<'a> TSInstantiationExpressionWithoutTypeParameters<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INSTANTIATION_EXPRESSION_SPAN) as *const Span) + } + } + + #[inline] + pub fn expression(&self) -> &Expression<'a> { + unsafe { + &*((self.0 as *const u8).add(OFFSET_TS_INSTANTIATION_EXPRESSION_EXPRESSION) + as *const Expression<'a>) + } + } +} + +pub(crate) const OFFSET_JS_DOC_NULLABLE_TYPE_SPAN: usize = offset_of!(JSDocNullableType, span); +pub(crate) const OFFSET_JS_DOC_NULLABLE_TYPE_TYPE_ANNOTATION: usize = + offset_of!(JSDocNullableType, type_annotation); +pub(crate) const OFFSET_JS_DOC_NULLABLE_TYPE_POSTFIX: usize = + offset_of!(JSDocNullableType, postfix); + +#[repr(transparent)] +#[derive(Debug)] +pub struct JSDocNullableTypeWithoutTypeAnnotation<'a>(pub(crate) *const JSDocNullableType<'a>); + +impl<'a> JSDocNullableTypeWithoutTypeAnnotation<'a> { + #[inline] + pub fn span(&self) -> &Span { + unsafe { &*((self.0 as *const u8).add(OFFSET_JS_DOC_NULLABLE_TYPE_SPAN) as *const Span) } + } + + #[inline] + pub fn postfix(&self) -> &bool { + unsafe { &*((self.0 as *const u8).add(OFFSET_JS_DOC_NULLABLE_TYPE_POSTFIX) as *const bool) } + } +} diff --git a/crates/oxc_traverse/src/context.rs b/crates/oxc_traverse/src/context.rs new file mode 100644 index 0000000000000..5e1c0f342df29 --- /dev/null +++ b/crates/oxc_traverse/src/context.rs @@ -0,0 +1,143 @@ +use oxc_allocator::{Allocator, Box}; +use oxc_ast::AstBuilder; + +use crate::ancestor::{Ancestor, AncestorDiscriminant}; + +const INITIAL_STACK_CAPACITY: usize = 64; + +/// Traverse context. +/// +/// Passed to all AST visitor functions. +/// +/// Provides ability to: +/// * Query parent/ancestor of current node via [`parent`], [`ancestor`], [`find_ancestor`]. +/// * Create AST nodes via AST builder [`ast`]. +/// * Allocate into arena via [`alloc`]. +/// +/// [`parent`]: `TraverseCtx::parent` +/// [`ancestor`]: `TraverseCtx::ancestor` +/// [`find_ancestor`]: `TraverseCtx::find_ancestor` +/// [`ast`]: `TraverseCtx::ast` +/// [`alloc`]: `TraverseCtx::alloc` +pub struct TraverseCtx<'a> { + stack: Vec>, + pub ast: AstBuilder<'a>, +} + +/// Return value when using [`TraverseCtx::find_ancestor`]. +pub enum FinderRet { + Found(T), + Stop, + Continue, +} + +// Public methods +impl<'a> TraverseCtx<'a> { + /// Create new traversal context. + pub fn new(allocator: &'a Allocator) -> Self { + let mut stack = Vec::with_capacity(INITIAL_STACK_CAPACITY); + stack.push(Ancestor::None); + Self { stack, ast: AstBuilder::new(allocator) } + } + + /// Allocate a node in the arena. + /// Returns a [`Box`]. + #[inline] + pub fn alloc(&self, node: T) -> Box<'a, T> { + self.ast.alloc(node) + } + + /// Get parent of current node. + #[inline] + #[allow(unsafe_code)] + pub fn parent(&self) -> &Ancestor<'a> { + // SAFETY: Stack contains 1 entry initially. Entries are pushed as traverse down the AST, + // and popped as go back up. So even when visiting `Program`, the initial entry is in the stack. + unsafe { self.stack.last().unwrap_unchecked() } + } + + /// Get ancestor of current node. + /// `level` is number of levels above. + /// `ancestor(1).unwrap()` is equivalent to `parent()`. + #[inline] + pub fn ancestor(&self, level: usize) -> Option<&Ancestor<'a>> { + self.stack.get(self.stack.len() - level) + } + + /// Walk up trail of ancestors to find a node. + /// + /// `finder` should return: + /// * `FinderRet::Found(value)` to stop walking and return `Some(value)`. + /// * `FinderRet::Stop` to stop walking and return `None`. + /// * `FinderRet::Continue` to continue walking up. + pub fn find_ancestor(&self, finder: F) -> Option + where + F: Fn(&Ancestor<'a>) -> FinderRet, + { + for ancestor in self.stack.iter().rev() { + match finder(ancestor) { + FinderRet::Found(res) => return Some(res), + FinderRet::Stop => return None, + FinderRet::Continue => {} + } + } + None + } + + /// Get depth of ancestry stack. + /// i.e. How many nodes above this one in the tree. + /// + /// NB: A "no parent" ancestor above `Program` counts towards this total. + /// The current node does not. + #[inline] + pub fn ancestors_depth(&self) -> usize { + self.stack.len() + } +} + +// Methods used internally within crate +impl<'a> TraverseCtx<'a> { + /// Push item onto stack. + #[inline] + pub(crate) fn push_stack(&mut self, ancestor: Ancestor<'a>) { + self.stack.push(ancestor); + } + + /// Pop last item off stack. + /// # SAFETY + /// * Stack must not be empty. + /// * Each `pop_stack` call must correspond to a `push_stack` call for same type. + #[inline] + #[allow(unsafe_code)] + pub(crate) unsafe fn pop_stack(&mut self) { + self.stack.pop().unwrap_unchecked(); + } + + /// Retag last item on stack. + /// + /// i.e. Alter discriminant of `Ancestor` enum, without changing the "payload" it contains + /// of pointer to the ancestor node. + /// + /// This is purely a performance optimization. If the last item on stack already contains the + /// correct pointer, then `ctx.retag_stack(3)` is equivalent to: + /// + /// ```nocompile + /// ctx.pop_stack(); + /// ctx.push_stack(Ancestor::ProgramBody(ProgramWithoutBody(node_ptr))); + /// ``` + /// + /// (3 is the discriminant for `Ancestor::ProgramBody`) + /// + /// `retag_stack` is only a single 2-byte write operation. + /// + /// # SAFETY + /// * Stack must not be empty. + /// * `discriminant` must be valid discriminant value for `Ancestor` enum. + /// * Last item on stack must contain pointer to type corresponding to provided discriminant. + #[inline] + #[allow(unsafe_code, clippy::ptr_as_ptr, clippy::ref_as_ptr)] + pub(crate) unsafe fn retag_stack(&mut self, discriminant: AncestorDiscriminant) { + *(self.stack.last_mut().unwrap_unchecked() as *mut _ as *mut AncestorDiscriminant) = + discriminant; + } +} diff --git a/crates/oxc_traverse/src/lib.rs b/crates/oxc_traverse/src/lib.rs new file mode 100644 index 0000000000000..ae32c71f65cf5 --- /dev/null +++ b/crates/oxc_traverse/src/lib.rs @@ -0,0 +1,149 @@ +//! AST traversal with ability to read up the tree from visitors. +//! +//! Please see [`traverse_mut`] for an explanation of API. +//! +//! # Implementation details +//! +//! Most of the code in this crate is generated by a codegen. +//! Codegen is currently written in JavaScript (`scripts/build.mjs`). +//! +//! Do not edit those files, as they'll be over-written by the build script on next run. +//! +//! The scheme which allows reading up the tree is based on making it statically impossible +//! to violate Rust's aliasing rules. +//! +//! Rust's aliasing rules are (roughly): +//! 1. For any object, you can have as many immutable `&` references simultaneously as you like. +//! 2. For any object, you cannot obtain a mutable `&mut` reference if any other references +//! (immutable or mutable) to that same object exist. +//! 3. A `&`/`&mut` ref covers the object itself and the entire tree below it. +//! i.e. you can't hold a `&mut` to child and any reference to parent at same time (except by +//! "re-borrowing"). +//! +//! This poses a problem for reading back up the tree in a mutating visitor. +//! In a visitor you hold a `&mut` reference to a node, so therefore cannot obtain a `&` ref to +//! its parent, because the parent owns the node. If you had a `&` ref to the parent, that also acts +//! as a `&` ref to the current node = holding `&` and `&mut` refs to same node simultaneously. +//! Disaster! +//! +//! The solution this crate uses is: +//! 1. Don't create references while traversing down the AST in `walk_*` functions. +//! Use raw pointers instead. `&mut` references are only created in the `enter_*` / `exit_*` methods. +//! 2. Don't allow `enter_*` / `exit_*` to access its entire parent or ancestor, only *other branches* +//! of the tree which lead from the parent/ancestor. The parts of the tree above current node +//! which can be accessed via `ctx.parent()` etc **do not overlap** the part of the tree which +//! is available via `&mut` ref inside `enter_*` / `exit_*`. This makes it impossible to obtain +//! 2 references to same AST node at same time. +//! 3. Again, don't create transient references while getting the fields of ancestors. Use raw pointers +//! to go to the field directly, before creating a `&` ref. +//! +//! The mechanism for this is the `Ancestor` enum. Each AST node type has several `Ancestor` variants +//! e.g. `ProgramWithoutDirectives`, `ProgramWithoutHashbang`, `ProgramWithoutBody`. +//! As the names suggest, each of these types grants access to all the fields of `Program` except one. +//! +//! As `walk_*` functions walk down the tree, they add to the stack of `Ancestors` the appropriate type +//! to prevent access to the path which is being walked down. +//! +//! `walk_*` uses `TraverseCtx::retag_stack` to make it as cheap as possible to update the ancestry +//! stack, but this is purely a performance optimization, not essential to the safety of the scheme. +//! +//! # SAFETY +//! This crate contains a great deal of unsafe code. The entirety of `walk.rs` is unsafe functions +//! using raw pointers. +//! +//! To avoid a drain on compile time asking Rust to parse 1000s of `# SAFETY` comments, the codegen-ed +//! files do not contain comments explaining the safety of every unsafe operation. +//! But everything works according to the principles outlined above. +//! +//! Almost all the code is currently codegen-ed. I (@overlookmotel) would recommend continuing to +//! exclusively use a codegen, and not manually editing these files for "special cases". The safety +//! scheme could very easily be derailed entirely by a single mistake, so in my opinion, it's unwise +//! to edit by hand. + +use oxc_allocator::Allocator; + +use oxc_ast::ast::Program; + +pub mod ancestor; +pub use ancestor::Ancestor; +mod context; +pub use context::{FinderRet, TraverseCtx}; +#[allow(clippy::module_inception)] +mod traverse; +pub use traverse::Traverse; +mod walk; + +/// Traverse AST with a [`Traverse`] impl. +/// +/// This allows: +/// 1. Reading and mutating down the tree (i.e. children, children's children, ...) +/// 2. Reading up the tree (i.e. parent, grandparent, ...) +/// +/// `traverser`'s `enter_*` and `exit_*` methods will be called with a `&mut` ref to current AST node +/// and a [`TraverseCtx`] object. +/// +/// [`TraverseCtx`] can be used to access parent or ancestors further up the tree. +/// [`TraverseCtx::parent`] and [`TraverseCtx::ancestor`] return an [`Ancestor`] type. +/// +/// [`Ancestor`] is an enum, whose discriminant encodes both the *type* of the parent, +/// and *location* of the child within the parent. +/// e.g. `Ancestor` has variants for `BinaryExpressionLeft` and `BinaryExpressionRight`, +/// not just `BinaryExpression`. +/// +/// To avoid violating Rust's aliasing rules, you cannot access the property of the parent +/// which current node is the child of. +/// +/// Or, to state the rule more generally: You can read from any branch of the AST *except* +/// the one you are on. +/// +/// A silly analogy: You are a tree surgeon working on pruning an old oak tree. You are sitting +/// on a branch high up in the tree. From that position, you can cut off other branches of the tree +/// no problem, but it would be unwise to saw off the branch that you are sitting on. +/// +/// In practice: For this JS code: +/// +/// ```js +/// x == 1 +/// ``` +/// +/// ``` +/// use oxc_ast::ast::*; +/// use oxc_traverse::{Ancestor, Traverse, TraverseCtx}; +/// +/// struct MyTransform; +/// +/// impl<'a> Traverse<'a> for MyTransform { +/// fn enter_numeric_literal(&mut self, node: &mut NumericLiteral<'a>, ctx: &TraverseCtx<'a>) { +/// // Read parent +/// if let Ancestor::BinaryExpressionRight(bin_expr_ref) = ctx.parent() { +/// // This is legal +/// if let Expression::Identifier(id) = bin_expr_ref.left() { +/// println!("left side is ID: {}", &id.name); +/// } +/// +/// // This would be a compile failure, because the right side is where we came from +/// // dbg!(bin_expr_ref.right()); +/// } +/// +/// // Read grandparent +/// if let Some(Ancestor::ExpressionStatementExpression(stmt_ref)) = ctx.ancestor(2) { +/// // This is legal +/// println!("expression stmt's span: {:?}", stmt_ref.span()); +/// +/// // This would be a compile failure, because the expression is where we came from +/// // dbg!(stmt_ref.expression()); +/// } +/// } +/// } +/// ``` +#[allow(unsafe_code)] +pub fn traverse_mut<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + program: &mut Program<'a>, + allocator: &'a Allocator, +) { + let mut ctx = TraverseCtx::new(allocator); + // SAFETY: Walk functions are constructed to avoid unsoundness + unsafe { walk::walk_program(traverser, program as *mut Program, &mut ctx) }; + debug_assert!(ctx.ancestors_depth() == 1); +} diff --git a/crates/oxc_traverse/src/traverse.rs b/crates/oxc_traverse/src/traverse.rs new file mode 100644 index 0000000000000..0ac553362213c --- /dev/null +++ b/crates/oxc_traverse/src/traverse.rs @@ -0,0 +1,1993 @@ +// Generated by `scripts/build.mjs`. + +use oxc_allocator::Vec; +#[allow(clippy::wildcard_imports)] +use oxc_ast::ast::*; + +use crate::TraverseCtx; + +#[allow(unused_variables)] +pub trait Traverse<'a> { + #[inline] + fn enter_program(&mut self, node: &mut Program<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_program(&mut self, node: &mut Program<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_expression(&mut self, node: &mut Expression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_expression(&mut self, node: &mut Expression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_identifier_name(&mut self, node: &mut IdentifierName<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_identifier_name(&mut self, node: &mut IdentifierName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_identifier_reference( + &mut self, + node: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_identifier_reference( + &mut self, + node: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_binding_identifier( + &mut self, + node: &mut BindingIdentifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_binding_identifier(&mut self, node: &mut BindingIdentifier<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_label_identifier(&mut self, node: &mut LabelIdentifier<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_label_identifier(&mut self, node: &mut LabelIdentifier<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_this_expression(&mut self, node: &mut ThisExpression, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_this_expression(&mut self, node: &mut ThisExpression, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_array_expression(&mut self, node: &mut ArrayExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_array_expression(&mut self, node: &mut ArrayExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_array_expression_element( + &mut self, + node: &mut ArrayExpressionElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_array_expression_element( + &mut self, + node: &mut ArrayExpressionElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_elision(&mut self, node: &mut Elision, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_elision(&mut self, node: &mut Elision, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_object_expression(&mut self, node: &mut ObjectExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_object_expression(&mut self, node: &mut ObjectExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_object_property_kind( + &mut self, + node: &mut ObjectPropertyKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_object_property_kind( + &mut self, + node: &mut ObjectPropertyKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_object_property(&mut self, node: &mut ObjectProperty<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_object_property(&mut self, node: &mut ObjectProperty<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_property_key(&mut self, node: &mut PropertyKey<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_property_key(&mut self, node: &mut PropertyKey<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_template_literal(&mut self, node: &mut TemplateLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_template_literal(&mut self, node: &mut TemplateLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_tagged_template_expression( + &mut self, + node: &mut TaggedTemplateExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_tagged_template_expression( + &mut self, + node: &mut TaggedTemplateExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_template_element(&mut self, node: &mut TemplateElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_template_element(&mut self, node: &mut TemplateElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_member_expression(&mut self, node: &mut MemberExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_member_expression(&mut self, node: &mut MemberExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_computed_member_expression( + &mut self, + node: &mut ComputedMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_computed_member_expression( + &mut self, + node: &mut ComputedMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_static_member_expression( + &mut self, + node: &mut StaticMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_static_member_expression( + &mut self, + node: &mut StaticMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_private_field_expression( + &mut self, + node: &mut PrivateFieldExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_private_field_expression( + &mut self, + node: &mut PrivateFieldExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_call_expression(&mut self, node: &mut CallExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_call_expression(&mut self, node: &mut CallExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_new_expression(&mut self, node: &mut NewExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_new_expression(&mut self, node: &mut NewExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_meta_property(&mut self, node: &mut MetaProperty<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_meta_property(&mut self, node: &mut MetaProperty<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_spread_element(&mut self, node: &mut SpreadElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_spread_element(&mut self, node: &mut SpreadElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_argument(&mut self, node: &mut Argument<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_argument(&mut self, node: &mut Argument<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_update_expression(&mut self, node: &mut UpdateExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_update_expression(&mut self, node: &mut UpdateExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_unary_expression(&mut self, node: &mut UnaryExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_unary_expression(&mut self, node: &mut UnaryExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_binary_expression(&mut self, node: &mut BinaryExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_binary_expression(&mut self, node: &mut BinaryExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_private_in_expression( + &mut self, + node: &mut PrivateInExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_private_in_expression( + &mut self, + node: &mut PrivateInExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_logical_expression( + &mut self, + node: &mut LogicalExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_logical_expression(&mut self, node: &mut LogicalExpression<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_conditional_expression( + &mut self, + node: &mut ConditionalExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_conditional_expression( + &mut self, + node: &mut ConditionalExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_expression( + &mut self, + node: &mut AssignmentExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_expression( + &mut self, + node: &mut AssignmentExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target(&mut self, node: &mut AssignmentTarget<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_assignment_target(&mut self, node: &mut AssignmentTarget<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_simple_assignment_target( + &mut self, + node: &mut SimpleAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_simple_assignment_target( + &mut self, + node: &mut SimpleAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_pattern( + &mut self, + node: &mut AssignmentTargetPattern<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_pattern( + &mut self, + node: &mut AssignmentTargetPattern<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_array_assignment_target( + &mut self, + node: &mut ArrayAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_array_assignment_target( + &mut self, + node: &mut ArrayAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_object_assignment_target( + &mut self, + node: &mut ObjectAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_object_assignment_target( + &mut self, + node: &mut ObjectAssignmentTarget<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_rest( + &mut self, + node: &mut AssignmentTargetRest<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_rest( + &mut self, + node: &mut AssignmentTargetRest<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_maybe_default( + &mut self, + node: &mut AssignmentTargetMaybeDefault<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_maybe_default( + &mut self, + node: &mut AssignmentTargetMaybeDefault<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_with_default( + &mut self, + node: &mut AssignmentTargetWithDefault<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_with_default( + &mut self, + node: &mut AssignmentTargetWithDefault<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_property( + &mut self, + node: &mut AssignmentTargetProperty<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_property( + &mut self, + node: &mut AssignmentTargetProperty<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_property_identifier( + &mut self, + node: &mut AssignmentTargetPropertyIdentifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_property_identifier( + &mut self, + node: &mut AssignmentTargetPropertyIdentifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_target_property_property( + &mut self, + node: &mut AssignmentTargetPropertyProperty<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_target_property_property( + &mut self, + node: &mut AssignmentTargetPropertyProperty<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_sequence_expression( + &mut self, + node: &mut SequenceExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_sequence_expression( + &mut self, + node: &mut SequenceExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_super(&mut self, node: &mut Super, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_super(&mut self, node: &mut Super, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_await_expression(&mut self, node: &mut AwaitExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_await_expression(&mut self, node: &mut AwaitExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_chain_expression(&mut self, node: &mut ChainExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_chain_expression(&mut self, node: &mut ChainExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_chain_element(&mut self, node: &mut ChainElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_chain_element(&mut self, node: &mut ChainElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_parenthesized_expression( + &mut self, + node: &mut ParenthesizedExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_parenthesized_expression( + &mut self, + node: &mut ParenthesizedExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_statement(&mut self, node: &mut Statement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_statement(&mut self, node: &mut Statement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_directive(&mut self, node: &mut Directive<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_directive(&mut self, node: &mut Directive<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_hashbang(&mut self, node: &mut Hashbang<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_hashbang(&mut self, node: &mut Hashbang<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_block_statement(&mut self, node: &mut BlockStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_block_statement(&mut self, node: &mut BlockStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_declaration(&mut self, node: &mut Declaration<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_declaration(&mut self, node: &mut Declaration<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_variable_declaration( + &mut self, + node: &mut VariableDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_variable_declaration( + &mut self, + node: &mut VariableDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_variable_declarator( + &mut self, + node: &mut VariableDeclarator<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_variable_declarator( + &mut self, + node: &mut VariableDeclarator<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_using_declaration(&mut self, node: &mut UsingDeclaration<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_using_declaration(&mut self, node: &mut UsingDeclaration<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_empty_statement(&mut self, node: &mut EmptyStatement, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_empty_statement(&mut self, node: &mut EmptyStatement, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_expression_statement( + &mut self, + node: &mut ExpressionStatement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_expression_statement( + &mut self, + node: &mut ExpressionStatement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_if_statement(&mut self, node: &mut IfStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_if_statement(&mut self, node: &mut IfStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_do_while_statement(&mut self, node: &mut DoWhileStatement<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_do_while_statement(&mut self, node: &mut DoWhileStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_while_statement(&mut self, node: &mut WhileStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_while_statement(&mut self, node: &mut WhileStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_for_statement(&mut self, node: &mut ForStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_for_statement(&mut self, node: &mut ForStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_for_statement_init(&mut self, node: &mut ForStatementInit<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_for_statement_init(&mut self, node: &mut ForStatementInit<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_for_in_statement(&mut self, node: &mut ForInStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_for_in_statement(&mut self, node: &mut ForInStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_for_of_statement(&mut self, node: &mut ForOfStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_for_of_statement(&mut self, node: &mut ForOfStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_for_statement_left(&mut self, node: &mut ForStatementLeft<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_for_statement_left(&mut self, node: &mut ForStatementLeft<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_continue_statement( + &mut self, + node: &mut ContinueStatement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_continue_statement(&mut self, node: &mut ContinueStatement<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_break_statement(&mut self, node: &mut BreakStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_break_statement(&mut self, node: &mut BreakStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_return_statement(&mut self, node: &mut ReturnStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_return_statement(&mut self, node: &mut ReturnStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_with_statement(&mut self, node: &mut WithStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_with_statement(&mut self, node: &mut WithStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_switch_statement(&mut self, node: &mut SwitchStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_switch_statement(&mut self, node: &mut SwitchStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_switch_case(&mut self, node: &mut SwitchCase<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_switch_case(&mut self, node: &mut SwitchCase<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_labeled_statement(&mut self, node: &mut LabeledStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_labeled_statement(&mut self, node: &mut LabeledStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_throw_statement(&mut self, node: &mut ThrowStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_throw_statement(&mut self, node: &mut ThrowStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_try_statement(&mut self, node: &mut TryStatement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_try_statement(&mut self, node: &mut TryStatement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_catch_clause(&mut self, node: &mut CatchClause<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_catch_clause(&mut self, node: &mut CatchClause<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_catch_parameter(&mut self, node: &mut CatchParameter<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_catch_parameter(&mut self, node: &mut CatchParameter<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_debugger_statement(&mut self, node: &mut DebuggerStatement, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_debugger_statement(&mut self, node: &mut DebuggerStatement, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_binding_pattern(&mut self, node: &mut BindingPattern<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_binding_pattern(&mut self, node: &mut BindingPattern<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_binding_pattern_kind( + &mut self, + node: &mut BindingPatternKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_binding_pattern_kind( + &mut self, + node: &mut BindingPatternKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_assignment_pattern( + &mut self, + node: &mut AssignmentPattern<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_assignment_pattern(&mut self, node: &mut AssignmentPattern<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_object_pattern(&mut self, node: &mut ObjectPattern<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_object_pattern(&mut self, node: &mut ObjectPattern<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_binding_property(&mut self, node: &mut BindingProperty<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_binding_property(&mut self, node: &mut BindingProperty<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_array_pattern(&mut self, node: &mut ArrayPattern<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_array_pattern(&mut self, node: &mut ArrayPattern<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_binding_rest_element( + &mut self, + node: &mut BindingRestElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_binding_rest_element( + &mut self, + node: &mut BindingRestElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_function(&mut self, node: &mut Function<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_function(&mut self, node: &mut Function<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_formal_parameters(&mut self, node: &mut FormalParameters<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_formal_parameters(&mut self, node: &mut FormalParameters<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_formal_parameter(&mut self, node: &mut FormalParameter<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_formal_parameter(&mut self, node: &mut FormalParameter<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_function_body(&mut self, node: &mut FunctionBody<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_function_body(&mut self, node: &mut FunctionBody<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_arrow_function_expression( + &mut self, + node: &mut ArrowFunctionExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_arrow_function_expression( + &mut self, + node: &mut ArrowFunctionExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_yield_expression(&mut self, node: &mut YieldExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_yield_expression(&mut self, node: &mut YieldExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_class(&mut self, node: &mut Class<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_class(&mut self, node: &mut Class<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_class_body(&mut self, node: &mut ClassBody<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_class_body(&mut self, node: &mut ClassBody<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_class_element(&mut self, node: &mut ClassElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_class_element(&mut self, node: &mut ClassElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_method_definition(&mut self, node: &mut MethodDefinition<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_method_definition(&mut self, node: &mut MethodDefinition<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_property_definition( + &mut self, + node: &mut PropertyDefinition<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_property_definition( + &mut self, + node: &mut PropertyDefinition<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_private_identifier( + &mut self, + node: &mut PrivateIdentifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_private_identifier(&mut self, node: &mut PrivateIdentifier<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_static_block(&mut self, node: &mut StaticBlock<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_static_block(&mut self, node: &mut StaticBlock<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_module_declaration( + &mut self, + node: &mut ModuleDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_module_declaration(&mut self, node: &mut ModuleDeclaration<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_accessor_property(&mut self, node: &mut AccessorProperty<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_accessor_property(&mut self, node: &mut AccessorProperty<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_import_expression(&mut self, node: &mut ImportExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_import_expression(&mut self, node: &mut ImportExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_import_declaration( + &mut self, + node: &mut ImportDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_import_declaration(&mut self, node: &mut ImportDeclaration<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_import_declaration_specifier( + &mut self, + node: &mut ImportDeclarationSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_import_declaration_specifier( + &mut self, + node: &mut ImportDeclarationSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_import_specifier(&mut self, node: &mut ImportSpecifier<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_import_specifier(&mut self, node: &mut ImportSpecifier<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_import_default_specifier( + &mut self, + node: &mut ImportDefaultSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_import_default_specifier( + &mut self, + node: &mut ImportDefaultSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_import_namespace_specifier( + &mut self, + node: &mut ImportNamespaceSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_import_namespace_specifier( + &mut self, + node: &mut ImportNamespaceSpecifier<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_with_clause(&mut self, node: &mut WithClause<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_with_clause(&mut self, node: &mut WithClause<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_import_attribute(&mut self, node: &mut ImportAttribute<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_import_attribute(&mut self, node: &mut ImportAttribute<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_import_attribute_key( + &mut self, + node: &mut ImportAttributeKey<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_import_attribute_key( + &mut self, + node: &mut ImportAttributeKey<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_export_named_declaration( + &mut self, + node: &mut ExportNamedDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_export_named_declaration( + &mut self, + node: &mut ExportNamedDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_export_default_declaration( + &mut self, + node: &mut ExportDefaultDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_export_default_declaration( + &mut self, + node: &mut ExportDefaultDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_export_all_declaration( + &mut self, + node: &mut ExportAllDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_export_all_declaration( + &mut self, + node: &mut ExportAllDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_export_specifier(&mut self, node: &mut ExportSpecifier<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_export_specifier(&mut self, node: &mut ExportSpecifier<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_export_default_declaration_kind( + &mut self, + node: &mut ExportDefaultDeclarationKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_export_default_declaration_kind( + &mut self, + node: &mut ExportDefaultDeclarationKind<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_module_export_name(&mut self, node: &mut ModuleExportName<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_module_export_name(&mut self, node: &mut ModuleExportName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_element(&mut self, node: &mut JSXElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_element(&mut self, node: &mut JSXElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_opening_element( + &mut self, + node: &mut JSXOpeningElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_opening_element( + &mut self, + node: &mut JSXOpeningElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_closing_element( + &mut self, + node: &mut JSXClosingElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_closing_element( + &mut self, + node: &mut JSXClosingElement<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_fragment(&mut self, node: &mut JSXFragment<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_fragment(&mut self, node: &mut JSXFragment<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_element_name(&mut self, node: &mut JSXElementName<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_element_name(&mut self, node: &mut JSXElementName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_namespaced_name( + &mut self, + node: &mut JSXNamespacedName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_namespaced_name( + &mut self, + node: &mut JSXNamespacedName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_member_expression( + &mut self, + node: &mut JSXMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_member_expression( + &mut self, + node: &mut JSXMemberExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_member_expression_object( + &mut self, + node: &mut JSXMemberExpressionObject<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_member_expression_object( + &mut self, + node: &mut JSXMemberExpressionObject<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_expression_container( + &mut self, + node: &mut JSXExpressionContainer<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_expression_container( + &mut self, + node: &mut JSXExpressionContainer<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_expression(&mut self, node: &mut JSXExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_expression(&mut self, node: &mut JSXExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_empty_expression(&mut self, node: &mut JSXEmptyExpression, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_jsx_empty_expression(&mut self, node: &mut JSXEmptyExpression, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_attribute_item(&mut self, node: &mut JSXAttributeItem<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_jsx_attribute_item(&mut self, node: &mut JSXAttributeItem<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_attribute(&mut self, node: &mut JSXAttribute<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_attribute(&mut self, node: &mut JSXAttribute<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_spread_attribute( + &mut self, + node: &mut JSXSpreadAttribute<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_spread_attribute( + &mut self, + node: &mut JSXSpreadAttribute<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_attribute_name(&mut self, node: &mut JSXAttributeName<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_jsx_attribute_name(&mut self, node: &mut JSXAttributeName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_attribute_value( + &mut self, + node: &mut JSXAttributeValue<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_jsx_attribute_value( + &mut self, + node: &mut JSXAttributeValue<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_jsx_identifier(&mut self, node: &mut JSXIdentifier<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_identifier(&mut self, node: &mut JSXIdentifier<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_child(&mut self, node: &mut JSXChild<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_child(&mut self, node: &mut JSXChild<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_spread_child(&mut self, node: &mut JSXSpreadChild<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_spread_child(&mut self, node: &mut JSXSpreadChild<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_jsx_text(&mut self, node: &mut JSXText<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_jsx_text(&mut self, node: &mut JSXText<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_boolean_literal(&mut self, node: &mut BooleanLiteral, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_boolean_literal(&mut self, node: &mut BooleanLiteral, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_null_literal(&mut self, node: &mut NullLiteral, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_null_literal(&mut self, node: &mut NullLiteral, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_numeric_literal(&mut self, node: &mut NumericLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_numeric_literal(&mut self, node: &mut NumericLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_big_int_literal(&mut self, node: &mut BigIntLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_big_int_literal(&mut self, node: &mut BigIntLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_reg_exp_literal(&mut self, node: &mut RegExpLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_reg_exp_literal(&mut self, node: &mut RegExpLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_string_literal(&mut self, node: &mut StringLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_string_literal(&mut self, node: &mut StringLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_this_parameter(&mut self, node: &mut TSThisParameter<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_this_parameter(&mut self, node: &mut TSThisParameter<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_enum_declaration( + &mut self, + node: &mut TSEnumDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_enum_declaration( + &mut self, + node: &mut TSEnumDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_enum_member(&mut self, node: &mut TSEnumMember<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_enum_member(&mut self, node: &mut TSEnumMember<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_enum_member_name( + &mut self, + node: &mut TSEnumMemberName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_enum_member_name(&mut self, node: &mut TSEnumMemberName<'a>, ctx: &TraverseCtx<'a>) { + } + + #[inline] + fn enter_ts_type_annotation(&mut self, node: &mut TSTypeAnnotation<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_ts_type_annotation(&mut self, node: &mut TSTypeAnnotation<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_literal_type(&mut self, node: &mut TSLiteralType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_literal_type(&mut self, node: &mut TSLiteralType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_literal(&mut self, node: &mut TSLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_literal(&mut self, node: &mut TSLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type(&mut self, node: &mut TSType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type(&mut self, node: &mut TSType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_conditional_type( + &mut self, + node: &mut TSConditionalType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_conditional_type( + &mut self, + node: &mut TSConditionalType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_union_type(&mut self, node: &mut TSUnionType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_union_type(&mut self, node: &mut TSUnionType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_intersection_type( + &mut self, + node: &mut TSIntersectionType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_intersection_type( + &mut self, + node: &mut TSIntersectionType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_type_operator(&mut self, node: &mut TSTypeOperator<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_operator(&mut self, node: &mut TSTypeOperator<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_array_type(&mut self, node: &mut TSArrayType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_array_type(&mut self, node: &mut TSArrayType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_indexed_access_type( + &mut self, + node: &mut TSIndexedAccessType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_indexed_access_type( + &mut self, + node: &mut TSIndexedAccessType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_tuple_type(&mut self, node: &mut TSTupleType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_tuple_type(&mut self, node: &mut TSTupleType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_named_tuple_member( + &mut self, + node: &mut TSNamedTupleMember<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_named_tuple_member( + &mut self, + node: &mut TSNamedTupleMember<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_optional_type(&mut self, node: &mut TSOptionalType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_optional_type(&mut self, node: &mut TSOptionalType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_rest_type(&mut self, node: &mut TSRestType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_rest_type(&mut self, node: &mut TSRestType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_tuple_element(&mut self, node: &mut TSTupleElement<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_tuple_element(&mut self, node: &mut TSTupleElement<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_any_keyword(&mut self, node: &mut TSAnyKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_any_keyword(&mut self, node: &mut TSAnyKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_string_keyword(&mut self, node: &mut TSStringKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_string_keyword(&mut self, node: &mut TSStringKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_boolean_keyword(&mut self, node: &mut TSBooleanKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_boolean_keyword(&mut self, node: &mut TSBooleanKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_number_keyword(&mut self, node: &mut TSNumberKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_number_keyword(&mut self, node: &mut TSNumberKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_never_keyword(&mut self, node: &mut TSNeverKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_never_keyword(&mut self, node: &mut TSNeverKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_unknown_keyword(&mut self, node: &mut TSUnknownKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_unknown_keyword(&mut self, node: &mut TSUnknownKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_null_keyword(&mut self, node: &mut TSNullKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_null_keyword(&mut self, node: &mut TSNullKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_undefined_keyword(&mut self, node: &mut TSUndefinedKeyword, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_ts_undefined_keyword(&mut self, node: &mut TSUndefinedKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_void_keyword(&mut self, node: &mut TSVoidKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_void_keyword(&mut self, node: &mut TSVoidKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_symbol_keyword(&mut self, node: &mut TSSymbolKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_symbol_keyword(&mut self, node: &mut TSSymbolKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_this_type(&mut self, node: &mut TSThisType, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_this_type(&mut self, node: &mut TSThisType, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_object_keyword(&mut self, node: &mut TSObjectKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_object_keyword(&mut self, node: &mut TSObjectKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_big_int_keyword(&mut self, node: &mut TSBigIntKeyword, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_big_int_keyword(&mut self, node: &mut TSBigIntKeyword, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_reference(&mut self, node: &mut TSTypeReference<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_reference(&mut self, node: &mut TSTypeReference<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_name(&mut self, node: &mut TSTypeName<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_name(&mut self, node: &mut TSTypeName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_qualified_name(&mut self, node: &mut TSQualifiedName<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_qualified_name(&mut self, node: &mut TSQualifiedName<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_parameter_instantiation( + &mut self, + node: &mut TSTypeParameterInstantiation<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_type_parameter_instantiation( + &mut self, + node: &mut TSTypeParameterInstantiation<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_type_parameter(&mut self, node: &mut TSTypeParameter<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_parameter(&mut self, node: &mut TSTypeParameter<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_parameter_declaration( + &mut self, + node: &mut TSTypeParameterDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_type_parameter_declaration( + &mut self, + node: &mut TSTypeParameterDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_type_alias_declaration( + &mut self, + node: &mut TSTypeAliasDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_type_alias_declaration( + &mut self, + node: &mut TSTypeAliasDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_class_implements( + &mut self, + node: &mut TSClassImplements<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_class_implements( + &mut self, + node: &mut TSClassImplements<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_interface_declaration( + &mut self, + node: &mut TSInterfaceDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_interface_declaration( + &mut self, + node: &mut TSInterfaceDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_interface_body(&mut self, node: &mut TSInterfaceBody<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_interface_body(&mut self, node: &mut TSInterfaceBody<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_property_signature( + &mut self, + node: &mut TSPropertySignature<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_property_signature( + &mut self, + node: &mut TSPropertySignature<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_signature(&mut self, node: &mut TSSignature<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_signature(&mut self, node: &mut TSSignature<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_index_signature(&mut self, node: &mut TSIndexSignature<'a>, ctx: &TraverseCtx<'a>) { + } + #[inline] + fn exit_ts_index_signature(&mut self, node: &mut TSIndexSignature<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_call_signature_declaration( + &mut self, + node: &mut TSCallSignatureDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_call_signature_declaration( + &mut self, + node: &mut TSCallSignatureDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_method_signature( + &mut self, + node: &mut TSMethodSignature<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_method_signature( + &mut self, + node: &mut TSMethodSignature<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_construct_signature_declaration( + &mut self, + node: &mut TSConstructSignatureDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_construct_signature_declaration( + &mut self, + node: &mut TSConstructSignatureDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_index_signature_name( + &mut self, + node: &mut TSIndexSignatureName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_index_signature_name( + &mut self, + node: &mut TSIndexSignatureName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_interface_heritage( + &mut self, + node: &mut TSInterfaceHeritage<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_interface_heritage( + &mut self, + node: &mut TSInterfaceHeritage<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_type_predicate(&mut self, node: &mut TSTypePredicate<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_predicate(&mut self, node: &mut TSTypePredicate<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_predicate_name( + &mut self, + node: &mut TSTypePredicateName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_type_predicate_name( + &mut self, + node: &mut TSTypePredicateName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_module_declaration( + &mut self, + node: &mut TSModuleDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_module_declaration( + &mut self, + node: &mut TSModuleDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_module_declaration_name( + &mut self, + node: &mut TSModuleDeclarationName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_module_declaration_name( + &mut self, + node: &mut TSModuleDeclarationName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_module_declaration_body( + &mut self, + node: &mut TSModuleDeclarationBody<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_module_declaration_body( + &mut self, + node: &mut TSModuleDeclarationBody<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_module_block(&mut self, node: &mut TSModuleBlock<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_module_block(&mut self, node: &mut TSModuleBlock<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_literal(&mut self, node: &mut TSTypeLiteral<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_literal(&mut self, node: &mut TSTypeLiteral<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_infer_type(&mut self, node: &mut TSInferType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_infer_type(&mut self, node: &mut TSInferType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_query(&mut self, node: &mut TSTypeQuery<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_query(&mut self, node: &mut TSTypeQuery<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_type_query_expr_name( + &mut self, + node: &mut TSTypeQueryExprName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_type_query_expr_name( + &mut self, + node: &mut TSTypeQueryExprName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_import_type(&mut self, node: &mut TSImportType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_import_type(&mut self, node: &mut TSImportType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_import_attributes( + &mut self, + node: &mut TSImportAttributes<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_import_attributes( + &mut self, + node: &mut TSImportAttributes<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_import_attribute( + &mut self, + node: &mut TSImportAttribute<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_import_attribute( + &mut self, + node: &mut TSImportAttribute<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_import_attribute_name( + &mut self, + node: &mut TSImportAttributeName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_import_attribute_name( + &mut self, + node: &mut TSImportAttributeName<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_function_type(&mut self, node: &mut TSFunctionType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_function_type(&mut self, node: &mut TSFunctionType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_constructor_type( + &mut self, + node: &mut TSConstructorType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_constructor_type( + &mut self, + node: &mut TSConstructorType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_mapped_type(&mut self, node: &mut TSMappedType<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_mapped_type(&mut self, node: &mut TSMappedType<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_template_literal_type( + &mut self, + node: &mut TSTemplateLiteralType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_template_literal_type( + &mut self, + node: &mut TSTemplateLiteralType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_as_expression(&mut self, node: &mut TSAsExpression<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_as_expression(&mut self, node: &mut TSAsExpression<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_satisfies_expression( + &mut self, + node: &mut TSSatisfiesExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_satisfies_expression( + &mut self, + node: &mut TSSatisfiesExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_type_assertion(&mut self, node: &mut TSTypeAssertion<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_ts_type_assertion(&mut self, node: &mut TSTypeAssertion<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_import_equals_declaration( + &mut self, + node: &mut TSImportEqualsDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_import_equals_declaration( + &mut self, + node: &mut TSImportEqualsDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_module_reference( + &mut self, + node: &mut TSModuleReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_module_reference( + &mut self, + node: &mut TSModuleReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_external_module_reference( + &mut self, + node: &mut TSExternalModuleReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_external_module_reference( + &mut self, + node: &mut TSExternalModuleReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_non_null_expression( + &mut self, + node: &mut TSNonNullExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_non_null_expression( + &mut self, + node: &mut TSNonNullExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_decorator(&mut self, node: &mut Decorator<'a>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_decorator(&mut self, node: &mut Decorator<'a>, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_ts_export_assignment( + &mut self, + node: &mut TSExportAssignment<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_export_assignment( + &mut self, + node: &mut TSExportAssignment<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_namespace_export_declaration( + &mut self, + node: &mut TSNamespaceExportDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_namespace_export_declaration( + &mut self, + node: &mut TSNamespaceExportDeclaration<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_ts_instantiation_expression( + &mut self, + node: &mut TSInstantiationExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_ts_instantiation_expression( + &mut self, + node: &mut TSInstantiationExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_js_doc_nullable_type( + &mut self, + node: &mut JSDocNullableType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + #[inline] + fn exit_js_doc_nullable_type( + &mut self, + node: &mut JSDocNullableType<'a>, + ctx: &TraverseCtx<'a>, + ) { + } + + #[inline] + fn enter_js_doc_unknown_type(&mut self, node: &mut JSDocUnknownType, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_js_doc_unknown_type(&mut self, node: &mut JSDocUnknownType, ctx: &TraverseCtx<'a>) {} + + #[inline] + fn enter_statements(&mut self, node: &mut Vec<'a, Statement<'a>>, ctx: &TraverseCtx<'a>) {} + #[inline] + fn exit_statements(&mut self, node: &mut Vec<'a, Statement<'a>>, ctx: &TraverseCtx<'a>) {} +} diff --git a/crates/oxc_traverse/src/walk.rs b/crates/oxc_traverse/src/walk.rs new file mode 100644 index 0000000000000..052455ff589bc --- /dev/null +++ b/crates/oxc_traverse/src/walk.rs @@ -0,0 +1,5302 @@ +// Generated by `scripts/build.mjs`. + +#![allow( + unsafe_code, + clippy::missing_safety_doc, + clippy::missing_panics_doc, + clippy::undocumented_unsafe_blocks, + clippy::semicolon_if_nothing_returned, + clippy::ptr_as_ptr, + clippy::borrow_as_ptr, + clippy::cast_ptr_alignment +)] + +use oxc_allocator::Vec; +#[allow(clippy::wildcard_imports)] +use oxc_ast::ast::*; + +use crate::{ancestor, Ancestor, Traverse, TraverseCtx}; + +pub(crate) unsafe fn walk_program<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Program<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_program(&mut *node, ctx); + ctx.push_stack(Ancestor::ProgramDirectives(ancestor::ProgramWithoutDirectives(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_PROGRAM_DIRECTIVES) + as *mut Vec)) + .iter_mut() + { + walk_directive(traverser, item as *mut _, ctx); + } + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_PROGRAM_HASHBANG) as *mut Option) + { + ctx.retag_stack(2); + walk_hashbang(traverser, field as *mut _, ctx); + } + ctx.retag_stack(3); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PROGRAM_BODY) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_program(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Expression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_expression(&mut *node, ctx); + match &mut *node { + Expression::BooleanLiteral(node) => { + walk_boolean_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::NullLiteral(node) => walk_null_literal(traverser, (&mut **node) as *mut _, ctx), + Expression::NumericLiteral(node) => { + walk_numeric_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::BigintLiteral(node) => { + walk_big_int_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::RegExpLiteral(node) => { + walk_reg_exp_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::StringLiteral(node) => { + walk_string_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TemplateLiteral(node) => { + walk_template_literal(traverser, (&mut **node) as *mut _, ctx) + } + Expression::Identifier(node) => { + walk_identifier_reference(traverser, (&mut **node) as *mut _, ctx) + } + Expression::MetaProperty(node) => { + walk_meta_property(traverser, (&mut **node) as *mut _, ctx) + } + Expression::Super(node) => walk_super(traverser, (&mut **node) as *mut _, ctx), + Expression::ArrayExpression(node) => { + walk_array_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ArrowFunctionExpression(node) => { + walk_arrow_function_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::AssignmentExpression(node) => { + walk_assignment_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::AwaitExpression(node) => { + walk_await_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::BinaryExpression(node) => { + walk_binary_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::CallExpression(node) => { + walk_call_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ChainExpression(node) => { + walk_chain_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ClassExpression(node) => walk_class(traverser, (&mut **node) as *mut _, ctx), + Expression::ConditionalExpression(node) => { + walk_conditional_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::FunctionExpression(node) => { + walk_function(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ImportExpression(node) => { + walk_import_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::LogicalExpression(node) => { + walk_logical_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::NewExpression(node) => { + walk_new_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ObjectExpression(node) => { + walk_object_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ParenthesizedExpression(node) => { + walk_parenthesized_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::SequenceExpression(node) => { + walk_sequence_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TaggedTemplateExpression(node) => { + walk_tagged_template_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ThisExpression(node) => { + walk_this_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::UnaryExpression(node) => { + walk_unary_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::UpdateExpression(node) => { + walk_update_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::YieldExpression(node) => { + walk_yield_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::PrivateInExpression(node) => { + walk_private_in_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::JSXElement(node) => walk_jsx_element(traverser, (&mut **node) as *mut _, ctx), + Expression::JSXFragment(node) => walk_jsx_fragment(traverser, (&mut **node) as *mut _, ctx), + Expression::TSAsExpression(node) => { + walk_ts_as_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TSSatisfiesExpression(node) => { + walk_ts_satisfies_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TSTypeAssertion(node) => { + walk_ts_type_assertion(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TSNonNullExpression(node) => { + walk_ts_non_null_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::TSInstantiationExpression(node) => { + walk_ts_instantiation_expression(traverser, (&mut **node) as *mut _, ctx) + } + Expression::ComputedMemberExpression(_) + | Expression::StaticMemberExpression(_) + | Expression::PrivateFieldExpression(_) => { + walk_member_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_identifier_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut IdentifierName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_identifier_name(&mut *node, ctx); + traverser.exit_identifier_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_identifier_reference<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut IdentifierReference<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_identifier_reference(&mut *node, ctx); + traverser.exit_identifier_reference(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binding_identifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BindingIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binding_identifier(&mut *node, ctx); + traverser.exit_binding_identifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_label_identifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut LabelIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_label_identifier(&mut *node, ctx); + traverser.exit_label_identifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_this_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ThisExpression, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_this_expression(&mut *node, ctx); + traverser.exit_this_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_array_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ArrayExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_array_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ArrayExpressionElements(ancestor::ArrayExpressionWithoutElements( + node, + ))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_ARRAY_EXPRESSION_ELEMENTS) + as *mut Vec)) + .iter_mut() + { + walk_array_expression_element(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_array_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_array_expression_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ArrayExpressionElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_array_expression_element(&mut *node, ctx); + match &mut *node { + ArrayExpressionElement::SpreadElement(node) => { + walk_spread_element(traverser, (&mut **node) as *mut _, ctx) + } + ArrayExpressionElement::Elision(node) => walk_elision(traverser, node as *mut _, ctx), + ArrayExpressionElement::BooleanLiteral(_) + | ArrayExpressionElement::NullLiteral(_) + | ArrayExpressionElement::NumericLiteral(_) + | ArrayExpressionElement::BigintLiteral(_) + | ArrayExpressionElement::RegExpLiteral(_) + | ArrayExpressionElement::StringLiteral(_) + | ArrayExpressionElement::TemplateLiteral(_) + | ArrayExpressionElement::Identifier(_) + | ArrayExpressionElement::MetaProperty(_) + | ArrayExpressionElement::Super(_) + | ArrayExpressionElement::ArrayExpression(_) + | ArrayExpressionElement::ArrowFunctionExpression(_) + | ArrayExpressionElement::AssignmentExpression(_) + | ArrayExpressionElement::AwaitExpression(_) + | ArrayExpressionElement::BinaryExpression(_) + | ArrayExpressionElement::CallExpression(_) + | ArrayExpressionElement::ChainExpression(_) + | ArrayExpressionElement::ClassExpression(_) + | ArrayExpressionElement::ConditionalExpression(_) + | ArrayExpressionElement::FunctionExpression(_) + | ArrayExpressionElement::ImportExpression(_) + | ArrayExpressionElement::LogicalExpression(_) + | ArrayExpressionElement::NewExpression(_) + | ArrayExpressionElement::ObjectExpression(_) + | ArrayExpressionElement::ParenthesizedExpression(_) + | ArrayExpressionElement::SequenceExpression(_) + | ArrayExpressionElement::TaggedTemplateExpression(_) + | ArrayExpressionElement::ThisExpression(_) + | ArrayExpressionElement::UnaryExpression(_) + | ArrayExpressionElement::UpdateExpression(_) + | ArrayExpressionElement::YieldExpression(_) + | ArrayExpressionElement::PrivateInExpression(_) + | ArrayExpressionElement::JSXElement(_) + | ArrayExpressionElement::JSXFragment(_) + | ArrayExpressionElement::TSAsExpression(_) + | ArrayExpressionElement::TSSatisfiesExpression(_) + | ArrayExpressionElement::TSTypeAssertion(_) + | ArrayExpressionElement::TSNonNullExpression(_) + | ArrayExpressionElement::TSInstantiationExpression(_) + | ArrayExpressionElement::ComputedMemberExpression(_) + | ArrayExpressionElement::StaticMemberExpression(_) + | ArrayExpressionElement::PrivateFieldExpression(_) => { + walk_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_array_expression_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_elision<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Elision, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_elision(&mut *node, ctx); + traverser.exit_elision(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_object_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ObjectExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_object_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ObjectExpressionProperties( + ancestor::ObjectExpressionWithoutProperties(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_OBJECT_EXPRESSION_PROPERTIES) + as *mut Vec)) + .iter_mut() + { + walk_object_property_kind(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_object_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_object_property_kind<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ObjectPropertyKind<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_object_property_kind(&mut *node, ctx); + match &mut *node { + ObjectPropertyKind::ObjectProperty(node) => { + walk_object_property(traverser, (&mut **node) as *mut _, ctx) + } + ObjectPropertyKind::SpreadProperty(node) => { + walk_spread_element(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_object_property_kind(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_object_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ObjectProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_object_property(&mut *node, ctx); + ctx.push_stack(Ancestor::ObjectPropertyKey(ancestor::ObjectPropertyWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_OBJECT_PROPERTY_KEY) as *mut PropertyKey, + ctx, + ); + ctx.retag_stack(7); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_OBJECT_PROPERTY_VALUE) as *mut Expression, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_OBJECT_PROPERTY_INIT) + as *mut Option) + { + ctx.retag_stack(8); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_object_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_property_key<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut PropertyKey<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_property_key(&mut *node, ctx); + match &mut *node { + PropertyKey::StaticIdentifier(node) => { + walk_identifier_name(traverser, (&mut **node) as *mut _, ctx) + } + PropertyKey::PrivateIdentifier(node) => { + walk_private_identifier(traverser, (&mut **node) as *mut _, ctx) + } + PropertyKey::BooleanLiteral(_) + | PropertyKey::NullLiteral(_) + | PropertyKey::NumericLiteral(_) + | PropertyKey::BigintLiteral(_) + | PropertyKey::RegExpLiteral(_) + | PropertyKey::StringLiteral(_) + | PropertyKey::TemplateLiteral(_) + | PropertyKey::Identifier(_) + | PropertyKey::MetaProperty(_) + | PropertyKey::Super(_) + | PropertyKey::ArrayExpression(_) + | PropertyKey::ArrowFunctionExpression(_) + | PropertyKey::AssignmentExpression(_) + | PropertyKey::AwaitExpression(_) + | PropertyKey::BinaryExpression(_) + | PropertyKey::CallExpression(_) + | PropertyKey::ChainExpression(_) + | PropertyKey::ClassExpression(_) + | PropertyKey::ConditionalExpression(_) + | PropertyKey::FunctionExpression(_) + | PropertyKey::ImportExpression(_) + | PropertyKey::LogicalExpression(_) + | PropertyKey::NewExpression(_) + | PropertyKey::ObjectExpression(_) + | PropertyKey::ParenthesizedExpression(_) + | PropertyKey::SequenceExpression(_) + | PropertyKey::TaggedTemplateExpression(_) + | PropertyKey::ThisExpression(_) + | PropertyKey::UnaryExpression(_) + | PropertyKey::UpdateExpression(_) + | PropertyKey::YieldExpression(_) + | PropertyKey::PrivateInExpression(_) + | PropertyKey::JSXElement(_) + | PropertyKey::JSXFragment(_) + | PropertyKey::TSAsExpression(_) + | PropertyKey::TSSatisfiesExpression(_) + | PropertyKey::TSTypeAssertion(_) + | PropertyKey::TSNonNullExpression(_) + | PropertyKey::TSInstantiationExpression(_) + | PropertyKey::ComputedMemberExpression(_) + | PropertyKey::StaticMemberExpression(_) + | PropertyKey::PrivateFieldExpression(_) => walk_expression(traverser, node as *mut _, ctx), + } + traverser.exit_property_key(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_template_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TemplateLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_template_literal(&mut *node, ctx); + ctx.push_stack(Ancestor::TemplateLiteralQuasis(ancestor::TemplateLiteralWithoutQuasis(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TEMPLATE_LITERAL_QUASIS) + as *mut Vec)) + .iter_mut() + { + walk_template_element(traverser, item as *mut _, ctx); + } + ctx.retag_stack(10); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TEMPLATE_LITERAL_EXPRESSIONS) + as *mut Vec)) + .iter_mut() + { + walk_expression(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_template_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_tagged_template_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TaggedTemplateExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_tagged_template_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::TaggedTemplateExpressionTag( + ancestor::TaggedTemplateExpressionWithoutTag(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TAGGED_TEMPLATE_EXPRESSION_TAG) as *mut Expression, + ctx, + ); + ctx.retag_stack(12); + walk_template_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TAGGED_TEMPLATE_EXPRESSION_QUASI) + as *mut TemplateLiteral, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TAGGED_TEMPLATE_EXPRESSION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(13); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_tagged_template_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_template_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TemplateElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_template_element(&mut *node, ctx); + traverser.exit_template_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_member_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut MemberExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_member_expression(&mut *node, ctx); + match &mut *node { + MemberExpression::ComputedMemberExpression(node) => { + walk_computed_member_expression(traverser, (&mut **node) as *mut _, ctx) + } + MemberExpression::StaticMemberExpression(node) => { + walk_static_member_expression(traverser, (&mut **node) as *mut _, ctx) + } + MemberExpression::PrivateFieldExpression(node) => { + walk_private_field_expression(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_member_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_computed_member_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ComputedMemberExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_computed_member_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ComputedMemberExpressionObject( + ancestor::ComputedMemberExpressionWithoutObject(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_COMPUTED_MEMBER_EXPRESSION_OBJECT) + as *mut Expression, + ctx, + ); + ctx.retag_stack(15); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_COMPUTED_MEMBER_EXPRESSION_EXPRESSION) + as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_computed_member_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_static_member_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut StaticMemberExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_static_member_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::StaticMemberExpressionObject( + ancestor::StaticMemberExpressionWithoutObject(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_STATIC_MEMBER_EXPRESSION_OBJECT) as *mut Expression, + ctx, + ); + ctx.retag_stack(17); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_STATIC_MEMBER_EXPRESSION_PROPERTY) + as *mut IdentifierName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_static_member_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_private_field_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut PrivateFieldExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_private_field_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::PrivateFieldExpressionObject( + ancestor::PrivateFieldExpressionWithoutObject(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PRIVATE_FIELD_EXPRESSION_OBJECT) as *mut Expression, + ctx, + ); + ctx.retag_stack(19); + walk_private_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PRIVATE_FIELD_EXPRESSION_FIELD) + as *mut PrivateIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_private_field_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_call_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut CallExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_call_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::CallExpressionCallee(ancestor::CallExpressionWithoutCallee(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CALL_EXPRESSION_CALLEE) as *mut Expression, + ctx, + ); + ctx.retag_stack(21); + for item in (*((node as *mut u8).add(ancestor::OFFSET_CALL_EXPRESSION_ARGUMENTS) + as *mut Vec)) + .iter_mut() + { + walk_argument(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_CALL_EXPRESSION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(22); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_call_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_new_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut NewExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_new_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::NewExpressionCallee(ancestor::NewExpressionWithoutCallee(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_NEW_EXPRESSION_CALLEE) as *mut Expression, + ctx, + ); + ctx.retag_stack(24); + for item in (*((node as *mut u8).add(ancestor::OFFSET_NEW_EXPRESSION_ARGUMENTS) + as *mut Vec)) + .iter_mut() + { + walk_argument(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_NEW_EXPRESSION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(25); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_new_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_meta_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut MetaProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_meta_property(&mut *node, ctx); + ctx.push_stack(Ancestor::MetaPropertyMeta(ancestor::MetaPropertyWithoutMeta(node))); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_META_PROPERTY_META) as *mut IdentifierName, + ctx, + ); + ctx.retag_stack(27); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_META_PROPERTY_PROPERTY) as *mut IdentifierName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_meta_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_spread_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut SpreadElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_spread_element(&mut *node, ctx); + ctx.push_stack(Ancestor::SpreadElementArgument(ancestor::SpreadElementWithoutArgument(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_SPREAD_ELEMENT_ARGUMENT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_spread_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_argument<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Argument<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_argument(&mut *node, ctx); + match &mut *node { + Argument::SpreadElement(node) => { + walk_spread_element(traverser, (&mut **node) as *mut _, ctx) + } + Argument::BooleanLiteral(_) + | Argument::NullLiteral(_) + | Argument::NumericLiteral(_) + | Argument::BigintLiteral(_) + | Argument::RegExpLiteral(_) + | Argument::StringLiteral(_) + | Argument::TemplateLiteral(_) + | Argument::Identifier(_) + | Argument::MetaProperty(_) + | Argument::Super(_) + | Argument::ArrayExpression(_) + | Argument::ArrowFunctionExpression(_) + | Argument::AssignmentExpression(_) + | Argument::AwaitExpression(_) + | Argument::BinaryExpression(_) + | Argument::CallExpression(_) + | Argument::ChainExpression(_) + | Argument::ClassExpression(_) + | Argument::ConditionalExpression(_) + | Argument::FunctionExpression(_) + | Argument::ImportExpression(_) + | Argument::LogicalExpression(_) + | Argument::NewExpression(_) + | Argument::ObjectExpression(_) + | Argument::ParenthesizedExpression(_) + | Argument::SequenceExpression(_) + | Argument::TaggedTemplateExpression(_) + | Argument::ThisExpression(_) + | Argument::UnaryExpression(_) + | Argument::UpdateExpression(_) + | Argument::YieldExpression(_) + | Argument::PrivateInExpression(_) + | Argument::JSXElement(_) + | Argument::JSXFragment(_) + | Argument::TSAsExpression(_) + | Argument::TSSatisfiesExpression(_) + | Argument::TSTypeAssertion(_) + | Argument::TSNonNullExpression(_) + | Argument::TSInstantiationExpression(_) + | Argument::ComputedMemberExpression(_) + | Argument::StaticMemberExpression(_) + | Argument::PrivateFieldExpression(_) => walk_expression(traverser, node as *mut _, ctx), + } + traverser.exit_argument(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_update_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut UpdateExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_update_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::UpdateExpressionArgument(ancestor::UpdateExpressionWithoutArgument( + node, + ))); + walk_simple_assignment_target( + traverser, + (node as *mut u8).add(ancestor::OFFSET_UPDATE_EXPRESSION_ARGUMENT) + as *mut SimpleAssignmentTarget, + ctx, + ); + ctx.pop_stack(); + traverser.exit_update_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_unary_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut UnaryExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_unary_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::UnaryExpressionArgument(ancestor::UnaryExpressionWithoutArgument( + node, + ))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_UNARY_EXPRESSION_ARGUMENT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_unary_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binary_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BinaryExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binary_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::BinaryExpressionLeft(ancestor::BinaryExpressionWithoutLeft(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINARY_EXPRESSION_LEFT) as *mut Expression, + ctx, + ); + ctx.retag_stack(32); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINARY_EXPRESSION_RIGHT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_binary_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_private_in_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut PrivateInExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_private_in_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::PrivateInExpressionLeft(ancestor::PrivateInExpressionWithoutLeft( + node, + ))); + walk_private_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PRIVATE_IN_EXPRESSION_LEFT) + as *mut PrivateIdentifier, + ctx, + ); + ctx.retag_stack(34); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PRIVATE_IN_EXPRESSION_RIGHT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_private_in_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_logical_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut LogicalExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_logical_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::LogicalExpressionLeft(ancestor::LogicalExpressionWithoutLeft(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_LOGICAL_EXPRESSION_LEFT) as *mut Expression, + ctx, + ); + ctx.retag_stack(36); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_LOGICAL_EXPRESSION_RIGHT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_logical_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_conditional_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ConditionalExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_conditional_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ConditionalExpressionTest( + ancestor::ConditionalExpressionWithoutTest(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CONDITIONAL_EXPRESSION_TEST) as *mut Expression, + ctx, + ); + ctx.retag_stack(38); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CONDITIONAL_EXPRESSION_CONSEQUENT) + as *mut Expression, + ctx, + ); + ctx.retag_stack(39); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CONDITIONAL_EXPRESSION_ALTERNATE) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_conditional_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentExpressionLeft(ancestor::AssignmentExpressionWithoutLeft( + node, + ))); + walk_assignment_target( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_EXPRESSION_LEFT) as *mut AssignmentTarget, + ctx, + ); + ctx.retag_stack(41); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_EXPRESSION_RIGHT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_assignment_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTarget<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target(&mut *node, ctx); + match &mut *node { + AssignmentTarget::AssignmentTargetIdentifier(_) + | AssignmentTarget::TSAsExpression(_) + | AssignmentTarget::TSSatisfiesExpression(_) + | AssignmentTarget::TSNonNullExpression(_) + | AssignmentTarget::TSTypeAssertion(_) + | AssignmentTarget::ComputedMemberExpression(_) + | AssignmentTarget::StaticMemberExpression(_) + | AssignmentTarget::PrivateFieldExpression(_) => { + walk_simple_assignment_target(traverser, node as *mut _, ctx) + } + AssignmentTarget::ArrayAssignmentTarget(_) + | AssignmentTarget::ObjectAssignmentTarget(_) => { + walk_assignment_target_pattern(traverser, node as *mut _, ctx) + } + } + traverser.exit_assignment_target(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_simple_assignment_target<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut SimpleAssignmentTarget<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_simple_assignment_target(&mut *node, ctx); + match &mut *node { + SimpleAssignmentTarget::AssignmentTargetIdentifier(node) => { + walk_identifier_reference(traverser, (&mut **node) as *mut _, ctx) + } + SimpleAssignmentTarget::TSAsExpression(node) => { + walk_ts_as_expression(traverser, (&mut **node) as *mut _, ctx) + } + SimpleAssignmentTarget::TSSatisfiesExpression(node) => { + walk_ts_satisfies_expression(traverser, (&mut **node) as *mut _, ctx) + } + SimpleAssignmentTarget::TSNonNullExpression(node) => { + walk_ts_non_null_expression(traverser, (&mut **node) as *mut _, ctx) + } + SimpleAssignmentTarget::TSTypeAssertion(node) => { + walk_ts_type_assertion(traverser, (&mut **node) as *mut _, ctx) + } + SimpleAssignmentTarget::ComputedMemberExpression(_) + | SimpleAssignmentTarget::StaticMemberExpression(_) + | SimpleAssignmentTarget::PrivateFieldExpression(_) => { + walk_member_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_simple_assignment_target(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_pattern<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetPattern<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_pattern(&mut *node, ctx); + match &mut *node { + AssignmentTargetPattern::ArrayAssignmentTarget(node) => { + walk_array_assignment_target(traverser, (&mut **node) as *mut _, ctx) + } + AssignmentTargetPattern::ObjectAssignmentTarget(node) => { + walk_object_assignment_target(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_assignment_target_pattern(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_array_assignment_target<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ArrayAssignmentTarget<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_array_assignment_target(&mut *node, ctx); + ctx.push_stack(Ancestor::ArrayAssignmentTargetElements( + ancestor::ArrayAssignmentTargetWithoutElements(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_ARRAY_ASSIGNMENT_TARGET_ELEMENTS) + as *mut Vec>)) + .iter_mut() + .flatten() + { + walk_assignment_target_maybe_default(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_ARRAY_ASSIGNMENT_TARGET_REST) + as *mut Option) + { + ctx.retag_stack(43); + walk_assignment_target_rest(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_array_assignment_target(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_object_assignment_target<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ObjectAssignmentTarget<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_object_assignment_target(&mut *node, ctx); + ctx.push_stack(Ancestor::ObjectAssignmentTargetProperties( + ancestor::ObjectAssignmentTargetWithoutProperties(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_OBJECT_ASSIGNMENT_TARGET_PROPERTIES) + as *mut Vec)) + .iter_mut() + { + walk_assignment_target_property(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_OBJECT_ASSIGNMENT_TARGET_REST) + as *mut Option) + { + ctx.retag_stack(45); + walk_assignment_target_rest(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_object_assignment_target(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_rest<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetRest<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_rest(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentTargetRestTarget( + ancestor::AssignmentTargetRestWithoutTarget(node), + )); + walk_assignment_target( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_REST_TARGET) + as *mut AssignmentTarget, + ctx, + ); + ctx.pop_stack(); + traverser.exit_assignment_target_rest(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_maybe_default<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetMaybeDefault<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_maybe_default(&mut *node, ctx); + match &mut *node { + AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(node) => { + walk_assignment_target_with_default(traverser, (&mut **node) as *mut _, ctx) + } + AssignmentTargetMaybeDefault::AssignmentTargetIdentifier(_) + | AssignmentTargetMaybeDefault::TSAsExpression(_) + | AssignmentTargetMaybeDefault::TSSatisfiesExpression(_) + | AssignmentTargetMaybeDefault::TSNonNullExpression(_) + | AssignmentTargetMaybeDefault::TSTypeAssertion(_) + | AssignmentTargetMaybeDefault::ArrayAssignmentTarget(_) + | AssignmentTargetMaybeDefault::ObjectAssignmentTarget(_) + | AssignmentTargetMaybeDefault::ComputedMemberExpression(_) + | AssignmentTargetMaybeDefault::StaticMemberExpression(_) + | AssignmentTargetMaybeDefault::PrivateFieldExpression(_) => { + walk_assignment_target(traverser, node as *mut _, ctx) + } + } + traverser.exit_assignment_target_maybe_default(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_with_default<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetWithDefault<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_with_default(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentTargetWithDefaultBinding( + ancestor::AssignmentTargetWithDefaultWithoutBinding(node), + )); + walk_assignment_target( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_BINDING) + as *mut AssignmentTarget, + ctx, + ); + ctx.retag_stack(48); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_WITH_DEFAULT_INIT) + as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_assignment_target_with_default(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_property(&mut *node, ctx); + match &mut *node { + AssignmentTargetProperty::AssignmentTargetPropertyIdentifier(node) => { + walk_assignment_target_property_identifier(traverser, (&mut **node) as *mut _, ctx) + } + AssignmentTargetProperty::AssignmentTargetPropertyProperty(node) => { + walk_assignment_target_property_property(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_assignment_target_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_property_identifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetPropertyIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_property_identifier(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentTargetPropertyIdentifierBinding( + ancestor::AssignmentTargetPropertyIdentifierWithoutBinding(node), + )); + walk_identifier_reference( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_BINDING) + as *mut IdentifierReference, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_ASSIGNMENT_TARGET_PROPERTY_IDENTIFIER_INIT) + as *mut Option) + { + ctx.retag_stack(50); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_assignment_target_property_identifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_target_property_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentTargetPropertyProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_target_property_property(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentTargetPropertyPropertyName( + ancestor::AssignmentTargetPropertyPropertyWithoutName(node), + )); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_NAME) + as *mut PropertyKey, + ctx, + ); + ctx.retag_stack(52); + walk_assignment_target_maybe_default( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_TARGET_PROPERTY_PROPERTY_BINDING) + as *mut AssignmentTargetMaybeDefault, + ctx, + ); + ctx.pop_stack(); + traverser.exit_assignment_target_property_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_sequence_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut SequenceExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_sequence_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::SequenceExpressionExpressions( + ancestor::SequenceExpressionWithoutExpressions(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_SEQUENCE_EXPRESSION_EXPRESSIONS) + as *mut Vec)) + .iter_mut() + { + walk_expression(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_sequence_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_super<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Super, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_super(&mut *node, ctx); + traverser.exit_super(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_await_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AwaitExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_await_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::AwaitExpressionArgument(ancestor::AwaitExpressionWithoutArgument( + node, + ))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_AWAIT_EXPRESSION_ARGUMENT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_await_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_chain_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ChainExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_chain_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ChainExpressionExpression( + ancestor::ChainExpressionWithoutExpression(node), + )); + walk_chain_element( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CHAIN_EXPRESSION_EXPRESSION) as *mut ChainElement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_chain_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_chain_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ChainElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_chain_element(&mut *node, ctx); + match &mut *node { + ChainElement::CallExpression(node) => { + walk_call_expression(traverser, (&mut **node) as *mut _, ctx) + } + ChainElement::ComputedMemberExpression(_) + | ChainElement::StaticMemberExpression(_) + | ChainElement::PrivateFieldExpression(_) => { + walk_member_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_chain_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_parenthesized_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ParenthesizedExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_parenthesized_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ParenthesizedExpressionExpression( + ancestor::ParenthesizedExpressionWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PARENTHESIZED_EXPRESSION_EXPRESSION) + as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_parenthesized_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Statement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_statement(&mut *node, ctx); + match &mut *node { + Statement::BlockStatement(node) => { + walk_block_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::BreakStatement(node) => { + walk_break_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ContinueStatement(node) => { + walk_continue_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::DebuggerStatement(node) => { + walk_debugger_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::DoWhileStatement(node) => { + walk_do_while_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::EmptyStatement(node) => { + walk_empty_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ExpressionStatement(node) => { + walk_expression_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ForInStatement(node) => { + walk_for_in_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ForOfStatement(node) => { + walk_for_of_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ForStatement(node) => { + walk_for_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::IfStatement(node) => walk_if_statement(traverser, (&mut **node) as *mut _, ctx), + Statement::LabeledStatement(node) => { + walk_labeled_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ReturnStatement(node) => { + walk_return_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::SwitchStatement(node) => { + walk_switch_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::ThrowStatement(node) => { + walk_throw_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::TryStatement(node) => { + walk_try_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::WhileStatement(node) => { + walk_while_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::WithStatement(node) => { + walk_with_statement(traverser, (&mut **node) as *mut _, ctx) + } + Statement::VariableDeclaration(_) + | Statement::FunctionDeclaration(_) + | Statement::ClassDeclaration(_) + | Statement::UsingDeclaration(_) + | Statement::TSTypeAliasDeclaration(_) + | Statement::TSInterfaceDeclaration(_) + | Statement::TSEnumDeclaration(_) + | Statement::TSModuleDeclaration(_) + | Statement::TSImportEqualsDeclaration(_) => { + walk_declaration(traverser, node as *mut _, ctx) + } + Statement::ImportDeclaration(_) + | Statement::ExportAllDeclaration(_) + | Statement::ExportDefaultDeclaration(_) + | Statement::ExportNamedDeclaration(_) + | Statement::TSExportAssignment(_) + | Statement::TSNamespaceExportDeclaration(_) => { + walk_module_declaration(traverser, node as *mut _, ctx) + } + } + traverser.exit_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_directive<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Directive<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_directive(&mut *node, ctx); + ctx.push_stack(Ancestor::DirectiveExpression(ancestor::DirectiveWithoutExpression(node))); + walk_string_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_DIRECTIVE_EXPRESSION) as *mut StringLiteral, + ctx, + ); + ctx.pop_stack(); + traverser.exit_directive(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_hashbang<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Hashbang<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_hashbang(&mut *node, ctx); + traverser.exit_hashbang(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_block_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BlockStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_block_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::BlockStatementBody(ancestor::BlockStatementWithoutBody(node))); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BLOCK_STATEMENT_BODY) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_block_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Declaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_declaration(&mut *node, ctx); + match &mut *node { + Declaration::VariableDeclaration(node) => { + walk_variable_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::FunctionDeclaration(node) => { + walk_function(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::ClassDeclaration(node) => walk_class(traverser, (&mut **node) as *mut _, ctx), + Declaration::UsingDeclaration(node) => { + walk_using_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::TSTypeAliasDeclaration(node) => { + walk_ts_type_alias_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::TSInterfaceDeclaration(node) => { + walk_ts_interface_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::TSEnumDeclaration(node) => { + walk_ts_enum_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::TSModuleDeclaration(node) => { + walk_ts_module_declaration(traverser, (&mut **node) as *mut _, ctx) + } + Declaration::TSImportEqualsDeclaration(node) => { + walk_ts_import_equals_declaration(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_variable_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut VariableDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_variable_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::VariableDeclarationDeclarations( + ancestor::VariableDeclarationWithoutDeclarations(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_VARIABLE_DECLARATION_DECLARATIONS) + as *mut Vec)) + .iter_mut() + { + walk_variable_declarator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_variable_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_variable_declarator<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut VariableDeclarator<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_variable_declarator(&mut *node, ctx); + ctx.push_stack(Ancestor::VariableDeclaratorId(ancestor::VariableDeclaratorWithoutId(node))); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_VARIABLE_DECLARATOR_ID) as *mut BindingPattern, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_VARIABLE_DECLARATOR_INIT) + as *mut Option) + { + ctx.retag_stack(61); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_variable_declarator(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_using_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut UsingDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_using_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::UsingDeclarationDeclarations( + ancestor::UsingDeclarationWithoutDeclarations(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_USING_DECLARATION_DECLARATIONS) + as *mut Vec)) + .iter_mut() + { + walk_variable_declarator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_using_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_empty_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut EmptyStatement, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_empty_statement(&mut *node, ctx); + traverser.exit_empty_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_expression_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExpressionStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_expression_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ExpressionStatementExpression( + ancestor::ExpressionStatementWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPRESSION_STATEMENT_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_expression_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_if_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut IfStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_if_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::IfStatementTest(ancestor::IfStatementWithoutTest(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IF_STATEMENT_TEST) as *mut Expression, + ctx, + ); + ctx.retag_stack(65); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IF_STATEMENT_CONSEQUENT) as *mut Statement, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_IF_STATEMENT_ALTERNATE) + as *mut Option) + { + ctx.retag_stack(66); + walk_statement(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_if_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_do_while_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut DoWhileStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_do_while_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::DoWhileStatementBody(ancestor::DoWhileStatementWithoutBody(node))); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_DO_WHILE_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.retag_stack(68); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_DO_WHILE_STATEMENT_TEST) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_do_while_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_while_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut WhileStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_while_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::WhileStatementTest(ancestor::WhileStatementWithoutTest(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_WHILE_STATEMENT_TEST) as *mut Expression, + ctx, + ); + ctx.retag_stack(70); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_WHILE_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_while_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_for_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ForStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_for_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ForStatementInit(ancestor::ForStatementWithoutInit(node))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FOR_STATEMENT_INIT) + as *mut Option) + { + walk_for_statement_init(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FOR_STATEMENT_TEST) + as *mut Option) + { + ctx.retag_stack(72); + walk_expression(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FOR_STATEMENT_UPDATE) + as *mut Option) + { + ctx.retag_stack(73); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.retag_stack(74); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_for_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_for_statement_init<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ForStatementInit<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_for_statement_init(&mut *node, ctx); + match &mut *node { + ForStatementInit::VariableDeclaration(node) => { + walk_variable_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ForStatementInit::UsingDeclaration(node) => { + walk_using_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ForStatementInit::BooleanLiteral(_) + | ForStatementInit::NullLiteral(_) + | ForStatementInit::NumericLiteral(_) + | ForStatementInit::BigintLiteral(_) + | ForStatementInit::RegExpLiteral(_) + | ForStatementInit::StringLiteral(_) + | ForStatementInit::TemplateLiteral(_) + | ForStatementInit::Identifier(_) + | ForStatementInit::MetaProperty(_) + | ForStatementInit::Super(_) + | ForStatementInit::ArrayExpression(_) + | ForStatementInit::ArrowFunctionExpression(_) + | ForStatementInit::AssignmentExpression(_) + | ForStatementInit::AwaitExpression(_) + | ForStatementInit::BinaryExpression(_) + | ForStatementInit::CallExpression(_) + | ForStatementInit::ChainExpression(_) + | ForStatementInit::ClassExpression(_) + | ForStatementInit::ConditionalExpression(_) + | ForStatementInit::FunctionExpression(_) + | ForStatementInit::ImportExpression(_) + | ForStatementInit::LogicalExpression(_) + | ForStatementInit::NewExpression(_) + | ForStatementInit::ObjectExpression(_) + | ForStatementInit::ParenthesizedExpression(_) + | ForStatementInit::SequenceExpression(_) + | ForStatementInit::TaggedTemplateExpression(_) + | ForStatementInit::ThisExpression(_) + | ForStatementInit::UnaryExpression(_) + | ForStatementInit::UpdateExpression(_) + | ForStatementInit::YieldExpression(_) + | ForStatementInit::PrivateInExpression(_) + | ForStatementInit::JSXElement(_) + | ForStatementInit::JSXFragment(_) + | ForStatementInit::TSAsExpression(_) + | ForStatementInit::TSSatisfiesExpression(_) + | ForStatementInit::TSTypeAssertion(_) + | ForStatementInit::TSNonNullExpression(_) + | ForStatementInit::TSInstantiationExpression(_) + | ForStatementInit::ComputedMemberExpression(_) + | ForStatementInit::StaticMemberExpression(_) + | ForStatementInit::PrivateFieldExpression(_) => { + walk_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_for_statement_init(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_for_in_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ForInStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_for_in_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ForInStatementLeft(ancestor::ForInStatementWithoutLeft(node))); + walk_for_statement_left( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_IN_STATEMENT_LEFT) as *mut ForStatementLeft, + ctx, + ); + ctx.retag_stack(76); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_IN_STATEMENT_RIGHT) as *mut Expression, + ctx, + ); + ctx.retag_stack(77); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_IN_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_for_in_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_for_of_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ForOfStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_for_of_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ForOfStatementLeft(ancestor::ForOfStatementWithoutLeft(node))); + walk_for_statement_left( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_OF_STATEMENT_LEFT) as *mut ForStatementLeft, + ctx, + ); + ctx.retag_stack(79); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_OF_STATEMENT_RIGHT) as *mut Expression, + ctx, + ); + ctx.retag_stack(80); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FOR_OF_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_for_of_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_for_statement_left<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ForStatementLeft<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_for_statement_left(&mut *node, ctx); + match &mut *node { + ForStatementLeft::VariableDeclaration(node) => { + walk_variable_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ForStatementLeft::UsingDeclaration(node) => { + walk_using_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ForStatementLeft::AssignmentTargetIdentifier(_) + | ForStatementLeft::TSAsExpression(_) + | ForStatementLeft::TSSatisfiesExpression(_) + | ForStatementLeft::TSNonNullExpression(_) + | ForStatementLeft::TSTypeAssertion(_) + | ForStatementLeft::ArrayAssignmentTarget(_) + | ForStatementLeft::ObjectAssignmentTarget(_) + | ForStatementLeft::ComputedMemberExpression(_) + | ForStatementLeft::StaticMemberExpression(_) + | ForStatementLeft::PrivateFieldExpression(_) => { + walk_assignment_target(traverser, node as *mut _, ctx) + } + } + traverser.exit_for_statement_left(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_continue_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ContinueStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_continue_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ContinueStatementLabel(ancestor::ContinueStatementWithoutLabel(node))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CONTINUE_STATEMENT_LABEL) + as *mut Option) + { + walk_label_identifier(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_continue_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_break_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BreakStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_break_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::BreakStatementLabel(ancestor::BreakStatementWithoutLabel(node))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_BREAK_STATEMENT_LABEL) + as *mut Option) + { + walk_label_identifier(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_break_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_return_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ReturnStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_return_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ReturnStatementArgument(ancestor::ReturnStatementWithoutArgument( + node, + ))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_RETURN_STATEMENT_ARGUMENT) + as *mut Option) + { + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_return_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_with_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut WithStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_with_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::WithStatementObject(ancestor::WithStatementWithoutObject(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_WITH_STATEMENT_OBJECT) as *mut Expression, + ctx, + ); + ctx.retag_stack(85); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_WITH_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_with_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_switch_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut SwitchStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_switch_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::SwitchStatementDiscriminant( + ancestor::SwitchStatementWithoutDiscriminant(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_DISCRIMINANT) as *mut Expression, + ctx, + ); + ctx.retag_stack(87); + for item in (*((node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_CASES) + as *mut Vec)) + .iter_mut() + { + walk_switch_case(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_switch_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_switch_case<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut SwitchCase<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_switch_case(&mut *node, ctx); + ctx.push_stack(Ancestor::SwitchCaseTest(ancestor::SwitchCaseWithoutTest(node))); + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_SWITCH_CASE_TEST) as *mut Option) + { + walk_expression(traverser, field as *mut _, ctx); + } + ctx.retag_stack(89); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_SWITCH_CASE_CONSEQUENT) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_switch_case(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_labeled_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut LabeledStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_labeled_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::LabeledStatementLabel(ancestor::LabeledStatementWithoutLabel(node))); + walk_label_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_LABELED_STATEMENT_LABEL) as *mut LabelIdentifier, + ctx, + ); + ctx.retag_stack(91); + walk_statement( + traverser, + (node as *mut u8).add(ancestor::OFFSET_LABELED_STATEMENT_BODY) as *mut Statement, + ctx, + ); + ctx.pop_stack(); + traverser.exit_labeled_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_throw_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ThrowStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_throw_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::ThrowStatementArgument(ancestor::ThrowStatementWithoutArgument(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_THROW_STATEMENT_ARGUMENT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_throw_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_try_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TryStatement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_try_statement(&mut *node, ctx); + ctx.push_stack(Ancestor::TryStatementBlock(ancestor::TryStatementWithoutBlock(node))); + walk_block_statement( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TRY_STATEMENT_BLOCK) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TRY_STATEMENT_HANDLER) + as *mut Option>) + { + ctx.retag_stack(94); + walk_catch_clause(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TRY_STATEMENT_FINALIZER) + as *mut Option>) + { + ctx.retag_stack(95); + walk_block_statement(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_try_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_catch_clause<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut CatchClause<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_catch_clause(&mut *node, ctx); + ctx.push_stack(Ancestor::CatchClauseParam(ancestor::CatchClauseWithoutParam(node))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CATCH_CLAUSE_PARAM) + as *mut Option) + { + walk_catch_parameter(traverser, field as *mut _, ctx); + } + ctx.retag_stack(97); + walk_block_statement( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_CATCH_CLAUSE_BODY) + as *mut Box)) as *mut _, + ctx, + ); + ctx.pop_stack(); + traverser.exit_catch_clause(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_catch_parameter<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut CatchParameter<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_catch_parameter(&mut *node, ctx); + ctx.push_stack(Ancestor::CatchParameterPattern(ancestor::CatchParameterWithoutPattern(node))); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_CATCH_PARAMETER_PATTERN) as *mut BindingPattern, + ctx, + ); + ctx.pop_stack(); + traverser.exit_catch_parameter(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_debugger_statement<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut DebuggerStatement, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_debugger_statement(&mut *node, ctx); + traverser.exit_debugger_statement(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binding_pattern<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BindingPattern<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binding_pattern(&mut *node, ctx); + ctx.push_stack(Ancestor::BindingPatternKind(ancestor::BindingPatternWithoutKind(node))); + walk_binding_pattern_kind( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINDING_PATTERN_KIND) as *mut BindingPatternKind, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_BINDING_PATTERN_TYPE_ANNOTATION) + as *mut Option>) + { + ctx.retag_stack(100); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_binding_pattern(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binding_pattern_kind<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BindingPatternKind<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binding_pattern_kind(&mut *node, ctx); + match &mut *node { + BindingPatternKind::BindingIdentifier(node) => { + walk_binding_identifier(traverser, (&mut **node) as *mut _, ctx) + } + BindingPatternKind::ObjectPattern(node) => { + walk_object_pattern(traverser, (&mut **node) as *mut _, ctx) + } + BindingPatternKind::ArrayPattern(node) => { + walk_array_pattern(traverser, (&mut **node) as *mut _, ctx) + } + BindingPatternKind::AssignmentPattern(node) => { + walk_assignment_pattern(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_binding_pattern_kind(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_assignment_pattern<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AssignmentPattern<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_assignment_pattern(&mut *node, ctx); + ctx.push_stack(Ancestor::AssignmentPatternLeft(ancestor::AssignmentPatternWithoutLeft(node))); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_PATTERN_LEFT) as *mut BindingPattern, + ctx, + ); + ctx.retag_stack(102); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ASSIGNMENT_PATTERN_RIGHT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_assignment_pattern(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_object_pattern<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ObjectPattern<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_object_pattern(&mut *node, ctx); + ctx.push_stack(Ancestor::ObjectPatternProperties(ancestor::ObjectPatternWithoutProperties( + node, + ))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_OBJECT_PATTERN_PROPERTIES) + as *mut Vec)) + .iter_mut() + { + walk_binding_property(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_OBJECT_PATTERN_REST) + as *mut Option>) + { + ctx.retag_stack(104); + walk_binding_rest_element(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_object_pattern(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binding_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BindingProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binding_property(&mut *node, ctx); + ctx.push_stack(Ancestor::BindingPropertyKey(ancestor::BindingPropertyWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINDING_PROPERTY_KEY) as *mut PropertyKey, + ctx, + ); + ctx.retag_stack(106); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINDING_PROPERTY_VALUE) as *mut BindingPattern, + ctx, + ); + ctx.pop_stack(); + traverser.exit_binding_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_array_pattern<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ArrayPattern<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_array_pattern(&mut *node, ctx); + ctx.push_stack(Ancestor::ArrayPatternElements(ancestor::ArrayPatternWithoutElements(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_ARRAY_PATTERN_ELEMENTS) + as *mut Vec>)) + .iter_mut() + .flatten() + { + walk_binding_pattern(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_ARRAY_PATTERN_REST) + as *mut Option>) + { + ctx.retag_stack(108); + walk_binding_rest_element(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_array_pattern(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_binding_rest_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BindingRestElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_binding_rest_element(&mut *node, ctx); + ctx.push_stack(Ancestor::BindingRestElementArgument( + ancestor::BindingRestElementWithoutArgument(node), + )); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_BINDING_REST_ELEMENT_ARGUMENT) + as *mut BindingPattern, + ctx, + ); + ctx.pop_stack(); + traverser.exit_binding_rest_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Function<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_function(&mut *node, ctx); + ctx.push_stack(Ancestor::FunctionId(ancestor::FunctionWithoutId(node))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_ID) + as *mut Option) + { + walk_binding_identifier(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_THIS_PARAM) + as *mut Option) + { + ctx.retag_stack(111); + walk_ts_this_parameter(traverser, field as *mut _, ctx); + } + ctx.retag_stack(112); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_FUNCTION_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_BODY) + as *mut Option>) + { + ctx.retag_stack(113); + walk_function_body(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(114); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_RETURN_TYPE) + as *mut Option>) + { + ctx.retag_stack(115); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_function(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_formal_parameters<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut FormalParameters<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_formal_parameters(&mut *node, ctx); + ctx.push_stack(Ancestor::FormalParametersItems(ancestor::FormalParametersWithoutItems(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETERS_ITEMS) + as *mut Vec)) + .iter_mut() + { + walk_formal_parameter(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETERS_REST) + as *mut Option>) + { + ctx.retag_stack(117); + walk_binding_rest_element(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_formal_parameters(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_formal_parameter<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut FormalParameter<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_formal_parameter(&mut *node, ctx); + ctx.push_stack(Ancestor::FormalParameterPattern(ancestor::FormalParameterWithoutPattern(node))); + walk_binding_pattern( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETER_PATTERN) as *mut BindingPattern, + ctx, + ); + ctx.retag_stack(119); + for item in (*((node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETER_DECORATORS) + as *mut Vec)) + .iter_mut() + { + walk_decorator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_formal_parameter(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_function_body<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut FunctionBody<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_function_body(&mut *node, ctx); + ctx.push_stack(Ancestor::FunctionBodyDirectives(ancestor::FunctionBodyWithoutDirectives(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_FUNCTION_BODY_DIRECTIVES) + as *mut Vec)) + .iter_mut() + { + walk_directive(traverser, item as *mut _, ctx); + } + ctx.retag_stack(121); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_FUNCTION_BODY_STATEMENTS) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_function_body(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_arrow_function_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ArrowFunctionExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_arrow_function_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ArrowFunctionExpressionParams( + ancestor::ArrowFunctionExpressionWithoutParams(node), + )); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + ctx.retag_stack(123); + walk_function_body( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_BODY) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(124); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_RETURN_TYPE) + as *mut Option>) + { + ctx.retag_stack(125); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_arrow_function_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_yield_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut YieldExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_yield_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::YieldExpressionArgument(ancestor::YieldExpressionWithoutArgument( + node, + ))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_YIELD_EXPRESSION_ARGUMENT) + as *mut Option) + { + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_yield_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Class<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_class(&mut *node, ctx); + ctx.push_stack(Ancestor::ClassId(ancestor::ClassWithoutId(node))); + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_ID) as *mut Option) + { + walk_binding_identifier(traverser, field as *mut _, ctx); + } + if let Some(field) = + &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_CLASS) as *mut Option) + { + ctx.retag_stack(128); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.retag_stack(129); + walk_class_body( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY) as *mut Box)) + as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(130); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_SUPER_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(131); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_IMPLEMENTS) + as *mut Option>) + { + ctx.retag_stack(132); + for item in field.iter_mut() { + walk_ts_class_implements(traverser, item as *mut _, ctx); + } + } + ctx.retag_stack(133); + for item in (*((node as *mut u8).add(ancestor::OFFSET_CLASS_DECORATORS) as *mut Vec)) + .iter_mut() + { + walk_decorator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_class(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_class_body<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ClassBody<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_class_body(&mut *node, ctx); + ctx.push_stack(Ancestor::ClassBodyBody(ancestor::ClassBodyWithoutBody(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_CLASS_BODY_BODY) + as *mut Vec)) + .iter_mut() + { + walk_class_element(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_class_body(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_class_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ClassElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_class_element(&mut *node, ctx); + match &mut *node { + ClassElement::StaticBlock(node) => { + walk_static_block(traverser, (&mut **node) as *mut _, ctx) + } + ClassElement::MethodDefinition(node) => { + walk_method_definition(traverser, (&mut **node) as *mut _, ctx) + } + ClassElement::PropertyDefinition(node) => { + walk_property_definition(traverser, (&mut **node) as *mut _, ctx) + } + ClassElement::AccessorProperty(node) => { + walk_accessor_property(traverser, (&mut **node) as *mut _, ctx) + } + ClassElement::TSIndexSignature(node) => { + walk_ts_index_signature(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_class_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_method_definition<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut MethodDefinition<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_method_definition(&mut *node, ctx); + ctx.push_stack(Ancestor::MethodDefinitionKey(ancestor::MethodDefinitionWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_METHOD_DEFINITION_KEY) as *mut PropertyKey, + ctx, + ); + ctx.retag_stack(136); + walk_function( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_METHOD_DEFINITION_VALUE) + as *mut Box)) as *mut _, + ctx, + ); + ctx.retag_stack(137); + for item in (*((node as *mut u8).add(ancestor::OFFSET_METHOD_DEFINITION_DECORATORS) + as *mut Vec)) + .iter_mut() + { + walk_decorator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_method_definition(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_property_definition<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut PropertyDefinition<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_property_definition(&mut *node, ctx); + ctx.push_stack(Ancestor::PropertyDefinitionKey(ancestor::PropertyDefinitionWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_KEY) as *mut PropertyKey, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_VALUE) + as *mut Option) + { + ctx.retag_stack(139); + walk_expression(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_PROPERTY_DEFINITION_TYPE_ANNOTATION) + as *mut Option>) + { + ctx.retag_stack(140); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.retag_stack(141); + for item in (*((node as *mut u8).add(ancestor::OFFSET_PROPERTY_DEFINITION_DECORATORS) + as *mut Vec)) + .iter_mut() + { + walk_decorator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_property_definition(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_private_identifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut PrivateIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_private_identifier(&mut *node, ctx); + traverser.exit_private_identifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_static_block<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut StaticBlock<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_static_block(&mut *node, ctx); + ctx.push_stack(Ancestor::StaticBlockBody(ancestor::StaticBlockWithoutBody(node))); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_STATIC_BLOCK_BODY) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_static_block(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_module_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ModuleDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_module_declaration(&mut *node, ctx); + match &mut *node { + ModuleDeclaration::ImportDeclaration(node) => { + walk_import_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ModuleDeclaration::ExportAllDeclaration(node) => { + walk_export_all_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ModuleDeclaration::ExportDefaultDeclaration(node) => { + walk_export_default_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ModuleDeclaration::ExportNamedDeclaration(node) => { + walk_export_named_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ModuleDeclaration::TSExportAssignment(node) => { + walk_ts_export_assignment(traverser, (&mut **node) as *mut _, ctx) + } + ModuleDeclaration::TSNamespaceExportDeclaration(node) => { + walk_ts_namespace_export_declaration(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_module_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_accessor_property<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut AccessorProperty<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_accessor_property(&mut *node, ctx); + ctx.push_stack(Ancestor::AccessorPropertyKey(ancestor::AccessorPropertyWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_KEY) as *mut PropertyKey, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_VALUE) + as *mut Option) + { + ctx.retag_stack(144); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.retag_stack(145); + for item in (*((node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_DECORATORS) + as *mut Vec)) + .iter_mut() + { + walk_decorator(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_accessor_property(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportExpressionSource(ancestor::ImportExpressionWithoutSource(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_EXPRESSION_SOURCE) as *mut Expression, + ctx, + ); + ctx.retag_stack(147); + for item in (*((node as *mut u8).add(ancestor::OFFSET_IMPORT_EXPRESSION_ARGUMENTS) + as *mut Vec)) + .iter_mut() + { + walk_expression(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_import_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportDeclarationSpecifiers( + ancestor::ImportDeclarationWithoutSpecifiers(node), + )); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_IMPORT_DECLARATION_SPECIFIERS) + as *mut Option>) + { + for item in field.iter_mut() { + walk_import_declaration_specifier(traverser, item as *mut _, ctx); + } + } + ctx.retag_stack(149); + walk_string_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_DECLARATION_SOURCE) as *mut StringLiteral, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_IMPORT_DECLARATION_WITH_CLAUSE) + as *mut Option) + { + ctx.retag_stack(150); + walk_with_clause(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_import_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_declaration_specifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportDeclarationSpecifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_declaration_specifier(&mut *node, ctx); + match &mut *node { + ImportDeclarationSpecifier::ImportSpecifier(node) => { + walk_import_specifier(traverser, (&mut **node) as *mut _, ctx) + } + ImportDeclarationSpecifier::ImportDefaultSpecifier(node) => { + walk_import_default_specifier(traverser, (&mut **node) as *mut _, ctx) + } + ImportDeclarationSpecifier::ImportNamespaceSpecifier(node) => { + walk_import_namespace_specifier(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_import_declaration_specifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_specifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportSpecifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_specifier(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportSpecifierImported(ancestor::ImportSpecifierWithoutImported( + node, + ))); + walk_module_export_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_SPECIFIER_IMPORTED) as *mut ModuleExportName, + ctx, + ); + ctx.retag_stack(152); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_SPECIFIER_LOCAL) as *mut BindingIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_import_specifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_default_specifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportDefaultSpecifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_default_specifier(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportDefaultSpecifierLocal( + ancestor::ImportDefaultSpecifierWithoutLocal(node), + )); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_DEFAULT_SPECIFIER_LOCAL) + as *mut BindingIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_import_default_specifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_namespace_specifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportNamespaceSpecifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_namespace_specifier(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportNamespaceSpecifierLocal( + ancestor::ImportNamespaceSpecifierWithoutLocal(node), + )); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_NAMESPACE_SPECIFIER_LOCAL) + as *mut BindingIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_import_namespace_specifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_with_clause<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut WithClause<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_with_clause(&mut *node, ctx); + ctx.push_stack(Ancestor::WithClauseAttributesKeyword( + ancestor::WithClauseWithoutAttributesKeyword(node), + )); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_WITH_CLAUSE_ATTRIBUTES_KEYWORD) + as *mut IdentifierName, + ctx, + ); + ctx.retag_stack(156); + for item in (*((node as *mut u8).add(ancestor::OFFSET_WITH_CLAUSE_WITH_ENTRIES) + as *mut Vec)) + .iter_mut() + { + walk_import_attribute(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_with_clause(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_attribute<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportAttribute<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_attribute(&mut *node, ctx); + ctx.push_stack(Ancestor::ImportAttributeKey(ancestor::ImportAttributeWithoutKey(node))); + walk_import_attribute_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_ATTRIBUTE_KEY) as *mut ImportAttributeKey, + ctx, + ); + ctx.retag_stack(158); + walk_string_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_IMPORT_ATTRIBUTE_VALUE) as *mut StringLiteral, + ctx, + ); + ctx.pop_stack(); + traverser.exit_import_attribute(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_import_attribute_key<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ImportAttributeKey<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_import_attribute_key(&mut *node, ctx); + match &mut *node { + ImportAttributeKey::Identifier(node) => { + walk_identifier_name(traverser, node as *mut _, ctx) + } + ImportAttributeKey::StringLiteral(node) => { + walk_string_literal(traverser, node as *mut _, ctx) + } + } + traverser.exit_import_attribute_key(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_export_named_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExportNamedDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_export_named_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::ExportNamedDeclarationDeclaration( + ancestor::ExportNamedDeclarationWithoutDeclaration(node), + )); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_EXPORT_NAMED_DECLARATION_DECLARATION) + as *mut Option) + { + walk_declaration(traverser, field as *mut _, ctx); + } + ctx.retag_stack(160); + for item in (*((node as *mut u8).add(ancestor::OFFSET_EXPORT_NAMED_DECLARATION_SPECIFIERS) + as *mut Vec)) + .iter_mut() + { + walk_export_specifier(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_EXPORT_NAMED_DECLARATION_SOURCE) + as *mut Option) + { + ctx.retag_stack(161); + walk_string_literal(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_EXPORT_NAMED_DECLARATION_WITH_CLAUSE) + as *mut Option) + { + ctx.retag_stack(162); + walk_with_clause(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_export_named_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_export_default_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExportDefaultDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_export_default_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::ExportDefaultDeclarationDeclaration( + ancestor::ExportDefaultDeclarationWithoutDeclaration(node), + )); + walk_export_default_declaration_kind( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPORT_DEFAULT_DECLARATION_DECLARATION) + as *mut ExportDefaultDeclarationKind, + ctx, + ); + ctx.retag_stack(164); + walk_module_export_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPORT_DEFAULT_DECLARATION_EXPORTED) + as *mut ModuleExportName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_export_default_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_export_all_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExportAllDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_export_all_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::ExportAllDeclarationExported( + ancestor::ExportAllDeclarationWithoutExported(node), + )); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_EXPORT_ALL_DECLARATION_EXPORTED) + as *mut Option) + { + walk_module_export_name(traverser, field as *mut _, ctx); + } + ctx.retag_stack(166); + walk_string_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPORT_ALL_DECLARATION_SOURCE) as *mut StringLiteral, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_EXPORT_ALL_DECLARATION_WITH_CLAUSE) + as *mut Option) + { + ctx.retag_stack(167); + walk_with_clause(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_export_all_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_export_specifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExportSpecifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_export_specifier(&mut *node, ctx); + ctx.push_stack(Ancestor::ExportSpecifierLocal(ancestor::ExportSpecifierWithoutLocal(node))); + walk_module_export_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPORT_SPECIFIER_LOCAL) as *mut ModuleExportName, + ctx, + ); + ctx.retag_stack(169); + walk_module_export_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_EXPORT_SPECIFIER_EXPORTED) as *mut ModuleExportName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_export_specifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_export_default_declaration_kind<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ExportDefaultDeclarationKind<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_export_default_declaration_kind(&mut *node, ctx); + match &mut *node { + ExportDefaultDeclarationKind::FunctionDeclaration(node) => { + walk_function(traverser, (&mut **node) as *mut _, ctx) + } + ExportDefaultDeclarationKind::ClassDeclaration(node) => { + walk_class(traverser, (&mut **node) as *mut _, ctx) + } + ExportDefaultDeclarationKind::TSInterfaceDeclaration(node) => { + walk_ts_interface_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ExportDefaultDeclarationKind::TSEnumDeclaration(node) => { + walk_ts_enum_declaration(traverser, (&mut **node) as *mut _, ctx) + } + ExportDefaultDeclarationKind::BooleanLiteral(_) + | ExportDefaultDeclarationKind::NullLiteral(_) + | ExportDefaultDeclarationKind::NumericLiteral(_) + | ExportDefaultDeclarationKind::BigintLiteral(_) + | ExportDefaultDeclarationKind::RegExpLiteral(_) + | ExportDefaultDeclarationKind::StringLiteral(_) + | ExportDefaultDeclarationKind::TemplateLiteral(_) + | ExportDefaultDeclarationKind::Identifier(_) + | ExportDefaultDeclarationKind::MetaProperty(_) + | ExportDefaultDeclarationKind::Super(_) + | ExportDefaultDeclarationKind::ArrayExpression(_) + | ExportDefaultDeclarationKind::ArrowFunctionExpression(_) + | ExportDefaultDeclarationKind::AssignmentExpression(_) + | ExportDefaultDeclarationKind::AwaitExpression(_) + | ExportDefaultDeclarationKind::BinaryExpression(_) + | ExportDefaultDeclarationKind::CallExpression(_) + | ExportDefaultDeclarationKind::ChainExpression(_) + | ExportDefaultDeclarationKind::ClassExpression(_) + | ExportDefaultDeclarationKind::ConditionalExpression(_) + | ExportDefaultDeclarationKind::FunctionExpression(_) + | ExportDefaultDeclarationKind::ImportExpression(_) + | ExportDefaultDeclarationKind::LogicalExpression(_) + | ExportDefaultDeclarationKind::NewExpression(_) + | ExportDefaultDeclarationKind::ObjectExpression(_) + | ExportDefaultDeclarationKind::ParenthesizedExpression(_) + | ExportDefaultDeclarationKind::SequenceExpression(_) + | ExportDefaultDeclarationKind::TaggedTemplateExpression(_) + | ExportDefaultDeclarationKind::ThisExpression(_) + | ExportDefaultDeclarationKind::UnaryExpression(_) + | ExportDefaultDeclarationKind::UpdateExpression(_) + | ExportDefaultDeclarationKind::YieldExpression(_) + | ExportDefaultDeclarationKind::PrivateInExpression(_) + | ExportDefaultDeclarationKind::JSXElement(_) + | ExportDefaultDeclarationKind::JSXFragment(_) + | ExportDefaultDeclarationKind::TSAsExpression(_) + | ExportDefaultDeclarationKind::TSSatisfiesExpression(_) + | ExportDefaultDeclarationKind::TSTypeAssertion(_) + | ExportDefaultDeclarationKind::TSNonNullExpression(_) + | ExportDefaultDeclarationKind::TSInstantiationExpression(_) + | ExportDefaultDeclarationKind::ComputedMemberExpression(_) + | ExportDefaultDeclarationKind::StaticMemberExpression(_) + | ExportDefaultDeclarationKind::PrivateFieldExpression(_) => { + walk_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_export_default_declaration_kind(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_module_export_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut ModuleExportName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_module_export_name(&mut *node, ctx); + match &mut *node { + ModuleExportName::Identifier(node) => walk_identifier_name(traverser, node as *mut _, ctx), + ModuleExportName::StringLiteral(node) => { + walk_string_literal(traverser, node as *mut _, ctx) + } + } + traverser.exit_module_export_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_element(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXElementOpeningElement(ancestor::JSXElementWithoutOpeningElement( + node, + ))); + walk_jsx_opening_element( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_JSX_ELEMENT_OPENING_ELEMENT) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_JSX_ELEMENT_CLOSING_ELEMENT) + as *mut Option>) + { + ctx.retag_stack(171); + walk_jsx_closing_element(traverser, (&mut **field) as *mut _, ctx); + } + ctx.retag_stack(172); + for item in (*((node as *mut u8).add(ancestor::OFFSET_JSX_ELEMENT_CHILDREN) + as *mut Vec)) + .iter_mut() + { + walk_jsx_child(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_jsx_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_opening_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXOpeningElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_opening_element(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXOpeningElementName(ancestor::JSXOpeningElementWithoutName(node))); + walk_jsx_element_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_OPENING_ELEMENT_NAME) as *mut JSXElementName, + ctx, + ); + ctx.retag_stack(174); + for item in (*((node as *mut u8).add(ancestor::OFFSET_JSX_OPENING_ELEMENT_ATTRIBUTES) + as *mut Vec)) + .iter_mut() + { + walk_jsx_attribute_item(traverser, item as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_JSX_OPENING_ELEMENT_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(175); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_jsx_opening_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_closing_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXClosingElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_closing_element(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXClosingElementName(ancestor::JSXClosingElementWithoutName(node))); + walk_jsx_element_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_CLOSING_ELEMENT_NAME) as *mut JSXElementName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_closing_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_fragment<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXFragment<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_fragment(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXFragmentChildren(ancestor::JSXFragmentWithoutChildren(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_JSX_FRAGMENT_CHILDREN) + as *mut Vec)) + .iter_mut() + { + walk_jsx_child(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_jsx_fragment(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_element_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXElementName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_element_name(&mut *node, ctx); + match &mut *node { + JSXElementName::Identifier(node) => { + walk_jsx_identifier(traverser, (&mut **node) as *mut _, ctx) + } + JSXElementName::NamespacedName(node) => { + walk_jsx_namespaced_name(traverser, (&mut **node) as *mut _, ctx) + } + JSXElementName::MemberExpression(node) => { + walk_jsx_member_expression(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_jsx_element_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_namespaced_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXNamespacedName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_namespaced_name(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXNamespacedNameNamespace( + ancestor::JSXNamespacedNameWithoutNamespace(node), + )); + walk_jsx_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_NAMESPACED_NAME_NAMESPACE) as *mut JSXIdentifier, + ctx, + ); + ctx.retag_stack(179); + walk_jsx_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_NAMESPACED_NAME_PROPERTY) as *mut JSXIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_namespaced_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_member_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXMemberExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_member_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXMemberExpressionObject( + ancestor::JSXMemberExpressionWithoutObject(node), + )); + walk_jsx_member_expression_object( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_MEMBER_EXPRESSION_OBJECT) + as *mut JSXMemberExpressionObject, + ctx, + ); + ctx.retag_stack(181); + walk_jsx_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_MEMBER_EXPRESSION_PROPERTY) + as *mut JSXIdentifier, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_member_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_member_expression_object<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXMemberExpressionObject<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_member_expression_object(&mut *node, ctx); + match &mut *node { + JSXMemberExpressionObject::Identifier(node) => { + walk_jsx_identifier(traverser, (&mut **node) as *mut _, ctx) + } + JSXMemberExpressionObject::MemberExpression(node) => { + walk_jsx_member_expression(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_jsx_member_expression_object(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_expression_container<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXExpressionContainer<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_expression_container(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXExpressionContainerExpression( + ancestor::JSXExpressionContainerWithoutExpression(node), + )); + walk_jsx_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_EXPRESSION_CONTAINER_EXPRESSION) + as *mut JSXExpression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_expression_container(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_expression(&mut *node, ctx); + match &mut *node { + JSXExpression::EmptyExpression(node) => { + walk_jsx_empty_expression(traverser, node as *mut _, ctx) + } + JSXExpression::BooleanLiteral(_) + | JSXExpression::NullLiteral(_) + | JSXExpression::NumericLiteral(_) + | JSXExpression::BigintLiteral(_) + | JSXExpression::RegExpLiteral(_) + | JSXExpression::StringLiteral(_) + | JSXExpression::TemplateLiteral(_) + | JSXExpression::Identifier(_) + | JSXExpression::MetaProperty(_) + | JSXExpression::Super(_) + | JSXExpression::ArrayExpression(_) + | JSXExpression::ArrowFunctionExpression(_) + | JSXExpression::AssignmentExpression(_) + | JSXExpression::AwaitExpression(_) + | JSXExpression::BinaryExpression(_) + | JSXExpression::CallExpression(_) + | JSXExpression::ChainExpression(_) + | JSXExpression::ClassExpression(_) + | JSXExpression::ConditionalExpression(_) + | JSXExpression::FunctionExpression(_) + | JSXExpression::ImportExpression(_) + | JSXExpression::LogicalExpression(_) + | JSXExpression::NewExpression(_) + | JSXExpression::ObjectExpression(_) + | JSXExpression::ParenthesizedExpression(_) + | JSXExpression::SequenceExpression(_) + | JSXExpression::TaggedTemplateExpression(_) + | JSXExpression::ThisExpression(_) + | JSXExpression::UnaryExpression(_) + | JSXExpression::UpdateExpression(_) + | JSXExpression::YieldExpression(_) + | JSXExpression::PrivateInExpression(_) + | JSXExpression::JSXElement(_) + | JSXExpression::JSXFragment(_) + | JSXExpression::TSAsExpression(_) + | JSXExpression::TSSatisfiesExpression(_) + | JSXExpression::TSTypeAssertion(_) + | JSXExpression::TSNonNullExpression(_) + | JSXExpression::TSInstantiationExpression(_) + | JSXExpression::ComputedMemberExpression(_) + | JSXExpression::StaticMemberExpression(_) + | JSXExpression::PrivateFieldExpression(_) => { + walk_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_jsx_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_empty_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXEmptyExpression, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_empty_expression(&mut *node, ctx); + traverser.exit_jsx_empty_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_attribute_item<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXAttributeItem<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_attribute_item(&mut *node, ctx); + match &mut *node { + JSXAttributeItem::Attribute(node) => { + walk_jsx_attribute(traverser, (&mut **node) as *mut _, ctx) + } + JSXAttributeItem::SpreadAttribute(node) => { + walk_jsx_spread_attribute(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_jsx_attribute_item(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_attribute<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXAttribute<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_attribute(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXAttributeName(ancestor::JSXAttributeWithoutName(node))); + walk_jsx_attribute_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_ATTRIBUTE_NAME) as *mut JSXAttributeName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_JSX_ATTRIBUTE_VALUE) + as *mut Option) + { + ctx.retag_stack(184); + walk_jsx_attribute_value(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_jsx_attribute(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_spread_attribute<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXSpreadAttribute<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_spread_attribute(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXSpreadAttributeArgument( + ancestor::JSXSpreadAttributeWithoutArgument(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_SPREAD_ATTRIBUTE_ARGUMENT) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_spread_attribute(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_attribute_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXAttributeName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_attribute_name(&mut *node, ctx); + match &mut *node { + JSXAttributeName::Identifier(node) => { + walk_jsx_identifier(traverser, (&mut **node) as *mut _, ctx) + } + JSXAttributeName::NamespacedName(node) => { + walk_jsx_namespaced_name(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_jsx_attribute_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_attribute_value<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXAttributeValue<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_attribute_value(&mut *node, ctx); + match &mut *node { + JSXAttributeValue::StringLiteral(node) => { + walk_string_literal(traverser, (&mut **node) as *mut _, ctx) + } + JSXAttributeValue::ExpressionContainer(node) => { + walk_jsx_expression_container(traverser, (&mut **node) as *mut _, ctx) + } + JSXAttributeValue::Element(node) => { + walk_jsx_element(traverser, (&mut **node) as *mut _, ctx) + } + JSXAttributeValue::Fragment(node) => { + walk_jsx_fragment(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_jsx_attribute_value(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_identifier<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXIdentifier<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_identifier(&mut *node, ctx); + traverser.exit_jsx_identifier(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_child<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXChild<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_child(&mut *node, ctx); + match &mut *node { + JSXChild::Text(node) => walk_jsx_text(traverser, (&mut **node) as *mut _, ctx), + JSXChild::Element(node) => walk_jsx_element(traverser, (&mut **node) as *mut _, ctx), + JSXChild::Fragment(node) => walk_jsx_fragment(traverser, (&mut **node) as *mut _, ctx), + JSXChild::ExpressionContainer(node) => { + walk_jsx_expression_container(traverser, (&mut **node) as *mut _, ctx) + } + JSXChild::Spread(node) => walk_jsx_spread_child(traverser, (&mut **node) as *mut _, ctx), + } + traverser.exit_jsx_child(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_spread_child<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXSpreadChild<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_spread_child(&mut *node, ctx); + ctx.push_stack(Ancestor::JSXSpreadChildExpression(ancestor::JSXSpreadChildWithoutExpression( + node, + ))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JSX_SPREAD_CHILD_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_jsx_spread_child(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_jsx_text<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSXText<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_jsx_text(&mut *node, ctx); + traverser.exit_jsx_text(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_boolean_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BooleanLiteral, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_boolean_literal(&mut *node, ctx); + traverser.exit_boolean_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_null_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut NullLiteral, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_null_literal(&mut *node, ctx); + traverser.exit_null_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_numeric_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut NumericLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_numeric_literal(&mut *node, ctx); + traverser.exit_numeric_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_big_int_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut BigIntLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_big_int_literal(&mut *node, ctx); + traverser.exit_big_int_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_reg_exp_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut RegExpLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_reg_exp_literal(&mut *node, ctx); + traverser.exit_reg_exp_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_string_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut StringLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_string_literal(&mut *node, ctx); + traverser.exit_string_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_this_parameter<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSThisParameter<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_this_parameter(&mut *node, ctx); + ctx.push_stack(Ancestor::TSThisParameterThis(ancestor::TSThisParameterWithoutThis(node))); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_THIS_PARAMETER_THIS) as *mut IdentifierName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_THIS_PARAMETER_TYPE_ANNOTATION) + as *mut Option>) + { + ctx.retag_stack(188); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_this_parameter(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_enum_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSEnumDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_enum_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSEnumDeclarationId(ancestor::TSEnumDeclarationWithoutId(node))); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_ID) as *mut BindingIdentifier, + ctx, + ); + ctx.retag_stack(190); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_MEMBERS) + as *mut Vec)) + .iter_mut() + { + walk_ts_enum_member(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_enum_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_enum_member<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSEnumMember<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_enum_member(&mut *node, ctx); + ctx.push_stack(Ancestor::TSEnumMemberId(ancestor::TSEnumMemberWithoutId(node))); + walk_ts_enum_member_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_ENUM_MEMBER_ID) as *mut TSEnumMemberName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_MEMBER_INITIALIZER) + as *mut Option) + { + ctx.retag_stack(192); + walk_expression(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_enum_member(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_enum_member_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSEnumMemberName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_enum_member_name(&mut *node, ctx); + match &mut *node { + TSEnumMemberName::StaticIdentifier(node) => { + walk_identifier_name(traverser, (&mut **node) as *mut _, ctx) + } + TSEnumMemberName::StaticStringLiteral(node) => { + walk_string_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSEnumMemberName::StaticNumericLiteral(node) => { + walk_numeric_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSEnumMemberName::BooleanLiteral(_) + | TSEnumMemberName::NullLiteral(_) + | TSEnumMemberName::NumericLiteral(_) + | TSEnumMemberName::BigintLiteral(_) + | TSEnumMemberName::RegExpLiteral(_) + | TSEnumMemberName::StringLiteral(_) + | TSEnumMemberName::TemplateLiteral(_) + | TSEnumMemberName::Identifier(_) + | TSEnumMemberName::MetaProperty(_) + | TSEnumMemberName::Super(_) + | TSEnumMemberName::ArrayExpression(_) + | TSEnumMemberName::ArrowFunctionExpression(_) + | TSEnumMemberName::AssignmentExpression(_) + | TSEnumMemberName::AwaitExpression(_) + | TSEnumMemberName::BinaryExpression(_) + | TSEnumMemberName::CallExpression(_) + | TSEnumMemberName::ChainExpression(_) + | TSEnumMemberName::ClassExpression(_) + | TSEnumMemberName::ConditionalExpression(_) + | TSEnumMemberName::FunctionExpression(_) + | TSEnumMemberName::ImportExpression(_) + | TSEnumMemberName::LogicalExpression(_) + | TSEnumMemberName::NewExpression(_) + | TSEnumMemberName::ObjectExpression(_) + | TSEnumMemberName::ParenthesizedExpression(_) + | TSEnumMemberName::SequenceExpression(_) + | TSEnumMemberName::TaggedTemplateExpression(_) + | TSEnumMemberName::ThisExpression(_) + | TSEnumMemberName::UnaryExpression(_) + | TSEnumMemberName::UpdateExpression(_) + | TSEnumMemberName::YieldExpression(_) + | TSEnumMemberName::PrivateInExpression(_) + | TSEnumMemberName::JSXElement(_) + | TSEnumMemberName::JSXFragment(_) + | TSEnumMemberName::TSAsExpression(_) + | TSEnumMemberName::TSSatisfiesExpression(_) + | TSEnumMemberName::TSTypeAssertion(_) + | TSEnumMemberName::TSNonNullExpression(_) + | TSEnumMemberName::TSInstantiationExpression(_) + | TSEnumMemberName::ComputedMemberExpression(_) + | TSEnumMemberName::StaticMemberExpression(_) + | TSEnumMemberName::PrivateFieldExpression(_) => { + walk_expression(traverser, node as *mut _, ctx) + } + } + traverser.exit_ts_enum_member_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_annotation<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeAnnotation<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_annotation(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeAnnotationTypeAnnotation( + ancestor::TSTypeAnnotationWithoutTypeAnnotation(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ANNOTATION_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_type_annotation(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_literal_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSLiteralType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_literal_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSLiteralTypeLiteral(ancestor::TSLiteralTypeWithoutLiteral(node))); + walk_ts_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_LITERAL_TYPE_LITERAL) as *mut TSLiteral, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_literal_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_literal(&mut *node, ctx); + match &mut *node { + TSLiteral::BooleanLiteral(node) => { + walk_boolean_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::NullLiteral(node) => walk_null_literal(traverser, (&mut **node) as *mut _, ctx), + TSLiteral::NumericLiteral(node) => { + walk_numeric_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::BigintLiteral(node) => { + walk_big_int_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::RegExpLiteral(node) => { + walk_reg_exp_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::StringLiteral(node) => { + walk_string_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::TemplateLiteral(node) => { + walk_template_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSLiteral::UnaryExpression(node) => { + walk_unary_expression(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_ts_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type(&mut *node, ctx); + match &mut *node { + TSType::TSAnyKeyword(node) => walk_ts_any_keyword(traverser, (&mut **node) as *mut _, ctx), + TSType::TSBigIntKeyword(node) => { + walk_ts_big_int_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSBooleanKeyword(node) => { + walk_ts_boolean_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSNeverKeyword(node) => { + walk_ts_never_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSNullKeyword(node) => { + walk_ts_null_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSNumberKeyword(node) => { + walk_ts_number_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSObjectKeyword(node) => { + walk_ts_object_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSStringKeyword(node) => { + walk_ts_string_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSSymbolKeyword(node) => { + walk_ts_symbol_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSThisType(node) => walk_ts_this_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSUndefinedKeyword(node) => { + walk_ts_undefined_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSUnknownKeyword(node) => { + walk_ts_unknown_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSVoidKeyword(node) => { + walk_ts_void_keyword(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSArrayType(node) => walk_ts_array_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSConditionalType(node) => { + walk_ts_conditional_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSConstructorType(node) => { + walk_ts_constructor_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSFunctionType(node) => { + walk_ts_function_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSImportType(node) => walk_ts_import_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSIndexedAccessType(node) => { + walk_ts_indexed_access_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSInferType(node) => walk_ts_infer_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSIntersectionType(node) => { + walk_ts_intersection_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSLiteralType(node) => { + walk_ts_literal_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSMappedType(node) => walk_ts_mapped_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSNamedTupleMember(node) => { + walk_ts_named_tuple_member(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSQualifiedName(node) => { + walk_ts_qualified_name(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSTemplateLiteralType(node) => { + walk_ts_template_literal_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSTupleType(node) => walk_ts_tuple_type(traverser, (&mut **node) as *mut _, ctx), + TSType::TSTypeLiteral(node) => { + walk_ts_type_literal(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSTypeOperatorType(node) => { + walk_ts_type_operator(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSTypePredicate(node) => { + walk_ts_type_predicate(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSTypeQuery(node) => walk_ts_type_query(traverser, (&mut **node) as *mut _, ctx), + TSType::TSTypeReference(node) => { + walk_ts_type_reference(traverser, (&mut **node) as *mut _, ctx) + } + TSType::TSUnionType(node) => walk_ts_union_type(traverser, (&mut **node) as *mut _, ctx), + TSType::JSDocNullableType(node) => { + walk_js_doc_nullable_type(traverser, (&mut **node) as *mut _, ctx) + } + TSType::JSDocUnknownType(node) => { + walk_js_doc_unknown_type(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_ts_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_conditional_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSConditionalType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_conditional_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSConditionalTypeCheckType( + ancestor::TSConditionalTypeWithoutCheckType(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_CHECK_TYPE) as *mut TSType, + ctx, + ); + ctx.retag_stack(196); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_EXTENDS_TYPE) as *mut TSType, + ctx, + ); + ctx.retag_stack(197); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_TRUE_TYPE) as *mut TSType, + ctx, + ); + ctx.retag_stack(198); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_FALSE_TYPE) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_conditional_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_union_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSUnionType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_union_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSUnionTypeTypes(ancestor::TSUnionTypeWithoutTypes(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_UNION_TYPE_TYPES) as *mut Vec)) + .iter_mut() + { + walk_ts_type(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_union_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_intersection_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSIntersectionType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_intersection_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSIntersectionTypeTypes(ancestor::TSIntersectionTypeWithoutTypes( + node, + ))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_INTERSECTION_TYPE_TYPES) + as *mut Vec)) + .iter_mut() + { + walk_ts_type(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_intersection_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_operator<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeOperator<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_operator(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeOperatorTypeAnnotation( + ancestor::TSTypeOperatorWithoutTypeAnnotation(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_OPERATOR_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_type_operator(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_array_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSArrayType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_array_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSArrayTypeElementType(ancestor::TSArrayTypeWithoutElementType(node))); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_ARRAY_TYPE_ELEMENT_TYPE) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_array_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_indexed_access_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSIndexedAccessType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_indexed_access_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSIndexedAccessTypeObjectType( + ancestor::TSIndexedAccessTypeWithoutObjectType(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_INDEXED_ACCESS_TYPE_OBJECT_TYPE) as *mut TSType, + ctx, + ); + ctx.retag_stack(204); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_INDEXED_ACCESS_TYPE_INDEX_TYPE) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_indexed_access_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_tuple_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTupleType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_tuple_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTupleTypeElementTypes(ancestor::TSTupleTypeWithoutElementTypes( + node, + ))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TUPLE_TYPE_ELEMENT_TYPES) + as *mut Vec)) + .iter_mut() + { + walk_ts_tuple_element(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_tuple_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_named_tuple_member<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNamedTupleMember<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_named_tuple_member(&mut *node, ctx); + ctx.push_stack(Ancestor::TSNamedTupleMemberElementType( + ancestor::TSNamedTupleMemberWithoutElementType(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_NAMED_TUPLE_MEMBER_ELEMENT_TYPE) as *mut TSType, + ctx, + ); + ctx.retag_stack(207); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_NAMED_TUPLE_MEMBER_LABEL) as *mut IdentifierName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_named_tuple_member(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_optional_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSOptionalType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_optional_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSOptionalTypeTypeAnnotation( + ancestor::TSOptionalTypeWithoutTypeAnnotation(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_OPTIONAL_TYPE_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_optional_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_rest_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSRestType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_rest_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSRestTypeTypeAnnotation(ancestor::TSRestTypeWithoutTypeAnnotation( + node, + ))); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_REST_TYPE_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_rest_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_tuple_element<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTupleElement<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_tuple_element(&mut *node, ctx); + match &mut *node { + TSTupleElement::TSOptionalType(node) => { + walk_ts_optional_type(traverser, (&mut **node) as *mut _, ctx) + } + TSTupleElement::TSRestType(node) => { + walk_ts_rest_type(traverser, (&mut **node) as *mut _, ctx) + } + TSTupleElement::TSAnyKeyword(_) + | TSTupleElement::TSBigIntKeyword(_) + | TSTupleElement::TSBooleanKeyword(_) + | TSTupleElement::TSNeverKeyword(_) + | TSTupleElement::TSNullKeyword(_) + | TSTupleElement::TSNumberKeyword(_) + | TSTupleElement::TSObjectKeyword(_) + | TSTupleElement::TSStringKeyword(_) + | TSTupleElement::TSSymbolKeyword(_) + | TSTupleElement::TSThisType(_) + | TSTupleElement::TSUndefinedKeyword(_) + | TSTupleElement::TSUnknownKeyword(_) + | TSTupleElement::TSVoidKeyword(_) + | TSTupleElement::TSArrayType(_) + | TSTupleElement::TSConditionalType(_) + | TSTupleElement::TSConstructorType(_) + | TSTupleElement::TSFunctionType(_) + | TSTupleElement::TSImportType(_) + | TSTupleElement::TSIndexedAccessType(_) + | TSTupleElement::TSInferType(_) + | TSTupleElement::TSIntersectionType(_) + | TSTupleElement::TSLiteralType(_) + | TSTupleElement::TSMappedType(_) + | TSTupleElement::TSNamedTupleMember(_) + | TSTupleElement::TSQualifiedName(_) + | TSTupleElement::TSTemplateLiteralType(_) + | TSTupleElement::TSTupleType(_) + | TSTupleElement::TSTypeLiteral(_) + | TSTupleElement::TSTypeOperatorType(_) + | TSTupleElement::TSTypePredicate(_) + | TSTupleElement::TSTypeQuery(_) + | TSTupleElement::TSTypeReference(_) + | TSTupleElement::TSUnionType(_) + | TSTupleElement::JSDocNullableType(_) + | TSTupleElement::JSDocUnknownType(_) => walk_ts_type(traverser, node as *mut _, ctx), + } + traverser.exit_ts_tuple_element(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_any_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSAnyKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_any_keyword(&mut *node, ctx); + traverser.exit_ts_any_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_string_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSStringKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_string_keyword(&mut *node, ctx); + traverser.exit_ts_string_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_boolean_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSBooleanKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_boolean_keyword(&mut *node, ctx); + traverser.exit_ts_boolean_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_number_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNumberKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_number_keyword(&mut *node, ctx); + traverser.exit_ts_number_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_never_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNeverKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_never_keyword(&mut *node, ctx); + traverser.exit_ts_never_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_unknown_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSUnknownKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_unknown_keyword(&mut *node, ctx); + traverser.exit_ts_unknown_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_null_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNullKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_null_keyword(&mut *node, ctx); + traverser.exit_ts_null_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_undefined_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSUndefinedKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_undefined_keyword(&mut *node, ctx); + traverser.exit_ts_undefined_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_void_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSVoidKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_void_keyword(&mut *node, ctx); + traverser.exit_ts_void_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_symbol_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSSymbolKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_symbol_keyword(&mut *node, ctx); + traverser.exit_ts_symbol_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_this_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSThisType, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_this_type(&mut *node, ctx); + traverser.exit_ts_this_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_object_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSObjectKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_object_keyword(&mut *node, ctx); + traverser.exit_ts_object_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_big_int_keyword<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSBigIntKeyword, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_big_int_keyword(&mut *node, ctx); + traverser.exit_ts_big_int_keyword(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_reference<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeReference<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_reference(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeReferenceTypeName(ancestor::TSTypeReferenceWithoutTypeName( + node, + ))); + walk_ts_type_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_REFERENCE_TYPE_NAME) as *mut TSTypeName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_TYPE_REFERENCE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(211); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_reference(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_name(&mut *node, ctx); + match &mut *node { + TSTypeName::IdentifierReference(node) => { + walk_identifier_reference(traverser, (&mut **node) as *mut _, ctx) + } + TSTypeName::QualifiedName(node) => { + walk_ts_qualified_name(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_ts_type_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_qualified_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSQualifiedName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_qualified_name(&mut *node, ctx); + ctx.push_stack(Ancestor::TSQualifiedNameLeft(ancestor::TSQualifiedNameWithoutLeft(node))); + walk_ts_type_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_QUALIFIED_NAME_LEFT) as *mut TSTypeName, + ctx, + ); + ctx.retag_stack(213); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_QUALIFIED_NAME_RIGHT) as *mut IdentifierName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_qualified_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_parameter_instantiation<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeParameterInstantiation<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_parameter_instantiation(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeParameterInstantiationParams( + ancestor::TSTypeParameterInstantiationWithoutParams(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PARAMETER_INSTANTIATION_PARAMS) + as *mut Vec)) + .iter_mut() + { + walk_ts_type(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_parameter_instantiation(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_parameter<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeParameter<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_parameter(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeParameterName(ancestor::TSTypeParameterWithoutName(node))); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PARAMETER_NAME) as *mut BindingIdentifier, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PARAMETER_CONSTRAINT) + as *mut Option) + { + ctx.retag_stack(216); + walk_ts_type(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PARAMETER_DEFAULT) + as *mut Option) + { + ctx.retag_stack(217); + walk_ts_type(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_parameter(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_parameter_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeParameterDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_parameter_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeParameterDeclarationParams( + ancestor::TSTypeParameterDeclarationWithoutParams(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PARAMETER_DECLARATION_PARAMS) + as *mut Vec)) + .iter_mut() + { + walk_ts_type_parameter(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_parameter_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_alias_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeAliasDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_alias_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeAliasDeclarationId(ancestor::TSTypeAliasDeclarationWithoutId( + node, + ))); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_ID) + as *mut BindingIdentifier, + ctx, + ); + ctx.retag_stack(220); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_ANNOTATION) + as *mut TSType, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(221); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_alias_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_class_implements<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSClassImplements<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_class_implements(&mut *node, ctx); + ctx.push_stack(Ancestor::TSClassImplementsExpression( + ancestor::TSClassImplementsWithoutExpression(node), + )); + walk_ts_type_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_CLASS_IMPLEMENTS_EXPRESSION) as *mut TSTypeName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CLASS_IMPLEMENTS_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(223); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_class_implements(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_interface_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSInterfaceDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_interface_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSInterfaceDeclarationId(ancestor::TSInterfaceDeclarationWithoutId( + node, + ))); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_ID) + as *mut BindingIdentifier, + ctx, + ); + ctx.retag_stack(225); + walk_ts_interface_body( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_BODY) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(226); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_EXTENDS) + as *mut Option>) + { + ctx.retag_stack(227); + for item in field.iter_mut() { + walk_ts_interface_heritage(traverser, item as *mut _, ctx); + } + } + ctx.pop_stack(); + traverser.exit_ts_interface_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_interface_body<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSInterfaceBody<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_interface_body(&mut *node, ctx); + ctx.push_stack(Ancestor::TSInterfaceBodyBody(ancestor::TSInterfaceBodyWithoutBody(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_BODY_BODY) + as *mut Vec)) + .iter_mut() + { + walk_ts_signature(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_interface_body(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_property_signature<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSPropertySignature<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_property_signature(&mut *node, ctx); + ctx.push_stack(Ancestor::TSPropertySignatureKey(ancestor::TSPropertySignatureWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_PROPERTY_SIGNATURE_KEY) as *mut PropertyKey, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_PROPERTY_SIGNATURE_TYPE_ANNOTATION) + as *mut Option>) + { + ctx.retag_stack(230); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_property_signature(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_signature<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSSignature<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_signature(&mut *node, ctx); + match &mut *node { + TSSignature::TSIndexSignature(node) => { + walk_ts_index_signature(traverser, (&mut **node) as *mut _, ctx) + } + TSSignature::TSPropertySignature(node) => { + walk_ts_property_signature(traverser, (&mut **node) as *mut _, ctx) + } + TSSignature::TSCallSignatureDeclaration(node) => { + walk_ts_call_signature_declaration(traverser, (&mut **node) as *mut _, ctx) + } + TSSignature::TSConstructSignatureDeclaration(node) => { + walk_ts_construct_signature_declaration(traverser, (&mut **node) as *mut _, ctx) + } + TSSignature::TSMethodSignature(node) => { + walk_ts_method_signature(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_ts_signature(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_index_signature<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSIndexSignature<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_index_signature(&mut *node, ctx); + ctx.push_stack(Ancestor::TSIndexSignatureParameters( + ancestor::TSIndexSignatureWithoutParameters(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_INDEX_SIGNATURE_PARAMETERS) + as *mut Vec)) + .iter_mut() + { + walk_ts_index_signature_name(traverser, item as *mut _, ctx); + } + ctx.retag_stack(232); + walk_ts_type_annotation( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INDEX_SIGNATURE_TYPE_ANNOTATION) + as *mut Box)) as *mut _, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_index_signature(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_call_signature_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSCallSignatureDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_call_signature_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSCallSignatureDeclarationThisParam( + ancestor::TSCallSignatureDeclarationWithoutThisParam(node), + )); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM) + as *mut Option) + { + walk_ts_this_parameter(traverser, field as *mut _, ctx); + } + ctx.retag_stack(234); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_CALL_SIGNATURE_DECLARATION_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CALL_SIGNATURE_DECLARATION_RETURN_TYPE) + as *mut Option>) + { + ctx.retag_stack(235); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CALL_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(236); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_call_signature_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_method_signature<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSMethodSignature<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_method_signature(&mut *node, ctx); + ctx.push_stack(Ancestor::TSMethodSignatureKey(ancestor::TSMethodSignatureWithoutKey(node))); + walk_property_key( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_METHOD_SIGNATURE_KEY) as *mut PropertyKey, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_METHOD_SIGNATURE_THIS_PARAM) + as *mut Option) + { + ctx.retag_stack(238); + walk_ts_this_parameter(traverser, field as *mut _, ctx); + } + ctx.retag_stack(239); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_METHOD_SIGNATURE_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_METHOD_SIGNATURE_RETURN_TYPE) + as *mut Option>) + { + ctx.retag_stack(240); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_METHOD_SIGNATURE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(241); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_method_signature(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_construct_signature_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSConstructSignatureDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_construct_signature_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSConstructSignatureDeclarationParams( + ancestor::TSConstructSignatureDeclarationWithoutParams(node), + )); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_RETURN_TYPE) + as *mut Option>) + { + ctx.retag_stack(243); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(244); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_construct_signature_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_index_signature_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSIndexSignatureName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_index_signature_name(&mut *node, ctx); + ctx.push_stack(Ancestor::TSIndexSignatureNameTypeAnnotation( + ancestor::TSIndexSignatureNameWithoutTypeAnnotation(node), + )); + walk_ts_type_annotation( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INDEX_SIGNATURE_NAME_TYPE_ANNOTATION) + as *mut Box)) as *mut _, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_index_signature_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_interface_heritage<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSInterfaceHeritage<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_interface_heritage(&mut *node, ctx); + ctx.push_stack(Ancestor::TSInterfaceHeritageExpression( + ancestor::TSInterfaceHeritageWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_HERITAGE_EXPRESSION) as *mut Expression, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_INTERFACE_HERITAGE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(247); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_interface_heritage(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_predicate<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypePredicate<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_predicate(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypePredicateParameterName( + ancestor::TSTypePredicateWithoutParameterName(node), + )); + walk_ts_type_predicate_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_PREDICATE_PARAMETER_NAME) + as *mut TSTypePredicateName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_TYPE_PREDICATE_TYPE_ANNOTATION) + as *mut Option>) + { + ctx.retag_stack(249); + walk_ts_type_annotation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_predicate(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_predicate_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypePredicateName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_predicate_name(&mut *node, ctx); + match &mut *node { + TSTypePredicateName::Identifier(node) => { + walk_identifier_name(traverser, (&mut **node) as *mut _, ctx) + } + TSTypePredicateName::This(node) => walk_ts_this_type(traverser, node as *mut _, ctx), + } + traverser.exit_ts_type_predicate_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_module_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSModuleDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_module_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSModuleDeclarationId(ancestor::TSModuleDeclarationWithoutId(node))); + walk_ts_module_declaration_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_MODULE_DECLARATION_ID) + as *mut TSModuleDeclarationName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_MODULE_DECLARATION_BODY) + as *mut Option) + { + ctx.retag_stack(251); + walk_ts_module_declaration_body(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_module_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_module_declaration_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSModuleDeclarationName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_module_declaration_name(&mut *node, ctx); + match &mut *node { + TSModuleDeclarationName::Identifier(node) => { + walk_identifier_name(traverser, node as *mut _, ctx) + } + TSModuleDeclarationName::StringLiteral(node) => { + walk_string_literal(traverser, node as *mut _, ctx) + } + } + traverser.exit_ts_module_declaration_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_module_declaration_body<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSModuleDeclarationBody<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_module_declaration_body(&mut *node, ctx); + match &mut *node { + TSModuleDeclarationBody::TSModuleDeclaration(node) => { + walk_ts_module_declaration(traverser, (&mut **node) as *mut _, ctx) + } + TSModuleDeclarationBody::TSModuleBlock(node) => { + walk_ts_module_block(traverser, (&mut **node) as *mut _, ctx) + } + } + traverser.exit_ts_module_declaration_body(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_module_block<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSModuleBlock<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_module_block(&mut *node, ctx); + ctx.push_stack(Ancestor::TSModuleBlockBody(ancestor::TSModuleBlockWithoutBody(node))); + walk_statements( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_MODULE_BLOCK_BODY) as *mut Vec, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_module_block(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_literal<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeLiteral<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_literal(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeLiteralMembers(ancestor::TSTypeLiteralWithoutMembers(node))); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_LITERAL_MEMBERS) + as *mut Vec)) + .iter_mut() + { + walk_ts_signature(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_literal(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_infer_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSInferType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_infer_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSInferTypeTypeParameter(ancestor::TSInferTypeWithoutTypeParameter( + node, + ))); + walk_ts_type_parameter( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INFER_TYPE_TYPE_PARAMETER) + as *mut Box)) as *mut _, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_infer_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_query<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeQuery<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_query(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeQueryExprName(ancestor::TSTypeQueryWithoutExprName(node))); + walk_ts_type_query_expr_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_QUERY_EXPR_NAME) as *mut TSTypeQueryExprName, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_TYPE_QUERY_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(256); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_type_query(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_query_expr_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeQueryExprName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_query_expr_name(&mut *node, ctx); + match &mut *node { + TSTypeQueryExprName::TSImportType(node) => { + walk_ts_import_type(traverser, (&mut **node) as *mut _, ctx) + } + TSTypeQueryExprName::IdentifierReference(_) | TSTypeQueryExprName::QualifiedName(_) => { + walk_ts_type_name(traverser, node as *mut _, ctx) + } + } + traverser.exit_ts_type_query_expr_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_import_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSImportType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_import_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSImportTypeArgument(ancestor::TSImportTypeWithoutArgument(node))); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_ARGUMENT) as *mut TSType, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_QUALIFIER) + as *mut Option) + { + ctx.retag_stack(258); + walk_ts_type_name(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_TYPE_ATTRIBUTES) + as *mut Option) + { + ctx.retag_stack(259); + walk_ts_import_attributes(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_IMPORT_TYPE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(260); + walk_ts_type_parameter_instantiation(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_import_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_import_attributes<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSImportAttributes<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_import_attributes(&mut *node, ctx); + ctx.push_stack(Ancestor::TSImportAttributesElements( + ancestor::TSImportAttributesWithoutElements(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_ATTRIBUTES_ELEMENTS) + as *mut Vec)) + .iter_mut() + { + walk_ts_import_attribute(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_import_attributes(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_import_attribute<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSImportAttribute<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_import_attribute(&mut *node, ctx); + ctx.push_stack(Ancestor::TSImportAttributeName(ancestor::TSImportAttributeWithoutName(node))); + walk_ts_import_attribute_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_ATTRIBUTE_NAME) + as *mut TSImportAttributeName, + ctx, + ); + ctx.retag_stack(263); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_ATTRIBUTE_VALUE) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_import_attribute(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_import_attribute_name<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSImportAttributeName<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_import_attribute_name(&mut *node, ctx); + match &mut *node { + TSImportAttributeName::Identifier(node) => { + walk_identifier_name(traverser, node as *mut _, ctx) + } + TSImportAttributeName::StringLiteral(node) => { + walk_string_literal(traverser, node as *mut _, ctx) + } + } + traverser.exit_ts_import_attribute_name(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_function_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSFunctionType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_function_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSFunctionTypeThisParam(ancestor::TSFunctionTypeWithoutThisParam( + node, + ))); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_FUNCTION_TYPE_THIS_PARAM) + as *mut Option) + { + walk_ts_this_parameter(traverser, field as *mut _, ctx); + } + ctx.retag_stack(265); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_FUNCTION_TYPE_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + ctx.retag_stack(266); + walk_ts_type_annotation( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_FUNCTION_TYPE_RETURN_TYPE) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_FUNCTION_TYPE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(267); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_function_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_constructor_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSConstructorType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_constructor_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSConstructorTypeParams(ancestor::TSConstructorTypeWithoutParams( + node, + ))); + walk_formal_parameters( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_CONSTRUCTOR_TYPE_PARAMS) + as *mut Box)) as *mut _, + ctx, + ); + ctx.retag_stack(269); + walk_ts_type_annotation( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_CONSTRUCTOR_TYPE_RETURN_TYPE) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_CONSTRUCTOR_TYPE_TYPE_PARAMETERS) + as *mut Option>) + { + ctx.retag_stack(270); + walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_constructor_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_mapped_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSMappedType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_mapped_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSMappedTypeTypeParameter( + ancestor::TSMappedTypeWithoutTypeParameter(node), + )); + walk_ts_type_parameter( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_MAPPED_TYPE_TYPE_PARAMETER) + as *mut Box)) as *mut _, + ctx, + ); + if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_MAPPED_TYPE_NAME_TYPE) + as *mut Option) + { + ctx.retag_stack(272); + walk_ts_type(traverser, field as *mut _, ctx); + } + if let Some(field) = &mut *((node as *mut u8) + .add(ancestor::OFFSET_TS_MAPPED_TYPE_TYPE_ANNOTATION) + as *mut Option) + { + ctx.retag_stack(273); + walk_ts_type(traverser, field as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_mapped_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_template_literal_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTemplateLiteralType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_template_literal_type(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTemplateLiteralTypeQuasis( + ancestor::TSTemplateLiteralTypeWithoutQuasis(node), + )); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TEMPLATE_LITERAL_TYPE_QUASIS) + as *mut Vec)) + .iter_mut() + { + walk_template_element(traverser, item as *mut _, ctx); + } + ctx.retag_stack(275); + for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_TEMPLATE_LITERAL_TYPE_TYPES) + as *mut Vec)) + .iter_mut() + { + walk_ts_type(traverser, item as *mut _, ctx); + } + ctx.pop_stack(); + traverser.exit_ts_template_literal_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_as_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSAsExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_as_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::TSAsExpressionExpression(ancestor::TSAsExpressionWithoutExpression( + node, + ))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_AS_EXPRESSION_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.retag_stack(277); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_AS_EXPRESSION_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_as_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_satisfies_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSSatisfiesExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_satisfies_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::TSSatisfiesExpressionExpression( + ancestor::TSSatisfiesExpressionWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_SATISFIES_EXPRESSION_EXPRESSION) + as *mut Expression, + ctx, + ); + ctx.retag_stack(279); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_SATISFIES_EXPRESSION_TYPE_ANNOTATION) + as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_satisfies_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_type_assertion<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSTypeAssertion<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_type_assertion(&mut *node, ctx); + ctx.push_stack(Ancestor::TSTypeAssertionExpression( + ancestor::TSTypeAssertionWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ASSERTION_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.retag_stack(281); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ASSERTION_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_type_assertion(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_import_equals_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSImportEqualsDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_import_equals_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSImportEqualsDeclarationId( + ancestor::TSImportEqualsDeclarationWithoutId(node), + )); + walk_binding_identifier( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_EQUALS_DECLARATION_ID) + as *mut BindingIdentifier, + ctx, + ); + ctx.retag_stack(283); + walk_ts_module_reference( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_IMPORT_EQUALS_DECLARATION_MODULE_REFERENCE) + as *mut TSModuleReference, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_import_equals_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_module_reference<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSModuleReference<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_module_reference(&mut *node, ctx); + match &mut *node { + TSModuleReference::ExternalModuleReference(node) => { + walk_ts_external_module_reference(traverser, (&mut **node) as *mut _, ctx) + } + TSModuleReference::IdentifierReference(_) | TSModuleReference::QualifiedName(_) => { + walk_ts_type_name(traverser, node as *mut _, ctx) + } + } + traverser.exit_ts_module_reference(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_external_module_reference<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSExternalModuleReference<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_external_module_reference(&mut *node, ctx); + ctx.push_stack(Ancestor::TSExternalModuleReferenceExpression( + ancestor::TSExternalModuleReferenceWithoutExpression(node), + )); + walk_string_literal( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_EXTERNAL_MODULE_REFERENCE_EXPRESSION) + as *mut StringLiteral, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_external_module_reference(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_non_null_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNonNullExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_non_null_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::TSNonNullExpressionExpression( + ancestor::TSNonNullExpressionWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_NON_NULL_EXPRESSION_EXPRESSION) + as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_non_null_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_decorator<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut Decorator<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_decorator(&mut *node, ctx); + ctx.push_stack(Ancestor::DecoratorExpression(ancestor::DecoratorWithoutExpression(node))); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_DECORATOR_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_decorator(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_export_assignment<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSExportAssignment<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_export_assignment(&mut *node, ctx); + ctx.push_stack(Ancestor::TSExportAssignmentExpression( + ancestor::TSExportAssignmentWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_EXPORT_ASSIGNMENT_EXPRESSION) as *mut Expression, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_export_assignment(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_namespace_export_declaration<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSNamespaceExportDeclaration<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_namespace_export_declaration(&mut *node, ctx); + ctx.push_stack(Ancestor::TSNamespaceExportDeclarationId( + ancestor::TSNamespaceExportDeclarationWithoutId(node), + )); + walk_identifier_name( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_NAMESPACE_EXPORT_DECLARATION_ID) + as *mut IdentifierName, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_namespace_export_declaration(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_ts_instantiation_expression<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut TSInstantiationExpression<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_ts_instantiation_expression(&mut *node, ctx); + ctx.push_stack(Ancestor::TSInstantiationExpressionExpression( + ancestor::TSInstantiationExpressionWithoutExpression(node), + )); + walk_expression( + traverser, + (node as *mut u8).add(ancestor::OFFSET_TS_INSTANTIATION_EXPRESSION_EXPRESSION) + as *mut Expression, + ctx, + ); + ctx.retag_stack(290); + walk_ts_type_parameter_instantiation( + traverser, + (&mut **((node as *mut u8).add(ancestor::OFFSET_TS_INSTANTIATION_EXPRESSION_TYPE_PARAMETERS) + as *mut Box)) as *mut _, + ctx, + ); + ctx.pop_stack(); + traverser.exit_ts_instantiation_expression(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_js_doc_nullable_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSDocNullableType<'a>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_js_doc_nullable_type(&mut *node, ctx); + ctx.push_stack(Ancestor::JSDocNullableTypeTypeAnnotation( + ancestor::JSDocNullableTypeWithoutTypeAnnotation(node), + )); + walk_ts_type( + traverser, + (node as *mut u8).add(ancestor::OFFSET_JS_DOC_NULLABLE_TYPE_TYPE_ANNOTATION) as *mut TSType, + ctx, + ); + ctx.pop_stack(); + traverser.exit_js_doc_nullable_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_js_doc_unknown_type<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + node: *mut JSDocUnknownType, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_js_doc_unknown_type(&mut *node, ctx); + traverser.exit_js_doc_unknown_type(&mut *node, ctx); +} + +pub(crate) unsafe fn walk_statements<'a, Tr: Traverse<'a>>( + traverser: &mut Tr, + stmts: *mut Vec<'a, Statement<'a>>, + ctx: &mut TraverseCtx<'a>, +) { + traverser.enter_statements(&mut *stmts, ctx); + for stmt in (*stmts).iter_mut() { + walk_statement(traverser, stmt, ctx); + } + traverser.exit_statements(&mut *stmts, ctx); +} diff --git a/crates/oxc_traverse/tests/compile_fail.rs b/crates/oxc_traverse/tests/compile_fail.rs new file mode 100644 index 0000000000000..95b5c273dd3c4 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail.rs @@ -0,0 +1,5 @@ +#[test] +fn compile_fail() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/compile_fail/*.rs"); +} diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.rs b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.rs new file mode 100644 index 0000000000000..d27a9cd698322 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.rs @@ -0,0 +1,18 @@ +use oxc_ast::ast::IdentifierReference; +use oxc_traverse::{Ancestor, Traverse, TraverseCtx}; + +struct Trans<'a, 'b> { + ancestor: Option<&'b Ancestor<'a>>, +} + +impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + fn enter_identifier_reference( + &mut self, + _node: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + self.ancestor = Some(ctx.parent()); + } +} + +fn main() {} diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.stderr b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.stderr new file mode 100644 index 0000000000000..7880eec4550e2 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime1.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> tests/compile_fail/ancestor_lifetime1.rs:14:9 + | +8 | impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + | -- lifetime `'b` defined here +... +12 | ctx: &TraverseCtx<'a>, + | - let's call the lifetime of this reference `'1` +13 | ) { +14 | self.ancestor = Some(ctx.parent()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'b` diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.rs b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.rs new file mode 100644 index 0000000000000..7f65af279b0d0 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.rs @@ -0,0 +1,20 @@ +use oxc_ast::ast::IdentifierReference; +use oxc_traverse::{ancestor::ProgramWithoutDirectives, Ancestor, Traverse, TraverseCtx}; + +struct Trans<'a, 'b> { + program: Option<&'b ProgramWithoutDirectives<'a>>, +} + +impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + fn enter_identifier_reference( + &mut self, + _node: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + if let Ancestor::ProgramDirectives(program) = ctx.parent() { + self.program = Some(program); + } + } +} + +fn main() {} diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.stderr b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.stderr new file mode 100644 index 0000000000000..faa2bf117ad71 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime2.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> tests/compile_fail/ancestor_lifetime2.rs:15:13 + | +8 | impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + | -- lifetime `'b` defined here +... +12 | ctx: &TraverseCtx<'a>, + | - let's call the lifetime of this reference `'1` +... +15 | self.program = Some(program); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'b` diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.rs b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.rs new file mode 100644 index 0000000000000..8eaa319c31449 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.rs @@ -0,0 +1,21 @@ +use oxc_allocator::Vec; +use oxc_ast::ast::{IdentifierReference, Statement}; +use oxc_traverse::{Ancestor, Traverse, TraverseCtx}; + +struct Trans<'a, 'b> { + program_body: Option<&'b Vec<'a, Statement<'a>>>, +} + +impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + fn enter_identifier_reference( + &mut self, + _node: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + if let Ancestor::ProgramDirectives(program) = ctx.parent() { + self.program_body = Some(program.body()); + } + } +} + +fn main() {} diff --git a/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.stderr b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.stderr new file mode 100644 index 0000000000000..0580b70d1fff8 --- /dev/null +++ b/crates/oxc_traverse/tests/compile_fail/ancestor_lifetime3.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> tests/compile_fail/ancestor_lifetime3.rs:16:13 + | +9 | impl<'a, 'b> Traverse<'a> for Trans<'a, 'b> { + | -- lifetime `'b` defined here +... +13 | ctx: &TraverseCtx<'a>, + | - let's call the lifetime of this reference `'1` +... +16 | self.program_body = Some(program.body()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'b` From 5643282840f2ce9861bbcf0306616afb235eefe8 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:13:09 +0100 Subject: [PATCH 3/7] Use `Traverse` for transformer --- Cargo.lock | 1 + crates/oxc_transformer/Cargo.toml | 1 + crates/oxc_transformer/src/lib.rs | 161 ++++++++++--------- crates/oxc_transformer/src/typescript/mod.rs | 11 +- 4 files changed, 92 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9a5727e0751b..8acfc841977e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1697,6 +1697,7 @@ dependencies = [ "oxc_parser", "oxc_span", "oxc_syntax", + "oxc_traverse", "ropey", "rustc-hash", "serde", diff --git a/crates/oxc_transformer/Cargo.toml b/crates/oxc_transformer/Cargo.toml index 56bc3e6e5e049..b49198684ce3c 100644 --- a/crates/oxc_transformer/Cargo.toml +++ b/crates/oxc_transformer/Cargo.toml @@ -24,6 +24,7 @@ oxc_span = { workspace = true } oxc_allocator = { workspace = true } oxc_diagnostics = { workspace = true } oxc_syntax = { workspace = true, features = ["to_js_string"] } +oxc_traverse = { workspace = true } rustc-hash = { workspace = true } indexmap = { workspace = true } diff --git a/crates/oxc_transformer/src/lib.rs b/crates/oxc_transformer/src/lib.rs index 678d693a6d634..c1fe0d3fcc47e 100644 --- a/crates/oxc_transformer/src/lib.rs +++ b/crates/oxc_transformer/src/lib.rs @@ -25,14 +25,11 @@ use std::{path::Path, rc::Rc}; use es2015::ES2015; use oxc_allocator::{Allocator, Vec}; -use oxc_ast::{ - ast::*, - visit::{walk_mut, VisitMut}, - Trivias, -}; +use oxc_ast::{ast::*, Trivias}; use oxc_diagnostics::Error; use oxc_span::SourceType; -use oxc_syntax::scope::ScopeFlags; +// use oxc_syntax::scope::ScopeFlags; +use oxc_traverse::{traverse_mut, Traverse, TraverseCtx}; pub use crate::{ compiler_assumptions::CompilerAssumptions, es2015::ES2015Options, options::TransformOptions, @@ -82,7 +79,9 @@ impl<'a> Transformer<'a> { /// /// Returns `Vec` if any errors were collected during the transformation. pub fn build(mut self, program: &mut Program<'a>) -> Result<(), std::vec::Vec> { - self.visit_program(program); + let allocator = self.ctx.ast.allocator; + traverse_mut(&mut self, program, allocator); + let errors = self.ctx.take_errors(); if errors.is_empty() { Ok(()) @@ -92,167 +91,169 @@ impl<'a> Transformer<'a> { } } -impl<'a> VisitMut<'a> for Transformer<'a> { - fn visit_program(&mut self, program: &mut Program<'a>) { +impl<'a> Traverse<'a> for Transformer<'a> { + fn enter_program(&mut self, program: &mut Program<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_program(program); + } - walk_mut::walk_program_mut(self, program); - + fn exit_program(&mut self, program: &mut Program<'a>, _ctx: &TraverseCtx<'a>) { self.x1_react.transform_program_on_exit(program); self.x0_typescript.transform_program_on_exit(program); } // ALPHASORT - fn visit_arrow_expression(&mut self, expr: &mut ArrowFunctionExpression<'a>) { + fn enter_arrow_function_expression( + &mut self, + expr: &mut ArrowFunctionExpression<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_arrow_expression(expr); - - walk_mut::walk_arrow_expression_mut(self, expr); } - fn visit_binding_pattern(&mut self, pat: &mut BindingPattern<'a>) { + fn enter_binding_pattern(&mut self, pat: &mut BindingPattern<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_binding_pattern(pat); - - walk_mut::walk_binding_pattern_mut(self, pat); } - fn visit_call_expression(&mut self, expr: &mut CallExpression<'a>) { + fn enter_call_expression(&mut self, expr: &mut CallExpression<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_call_expression(expr); - - walk_mut::walk_call_expression_mut(self, expr); } - fn visit_class(&mut self, class: &mut Class<'a>) { + fn enter_class(&mut self, class: &mut Class<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_class(class); self.x3_es2015.transform_class(class); + } - walk_mut::walk_class_mut(self, class); - + fn exit_class(&mut self, class: &mut Class<'a>, _ctx: &TraverseCtx<'a>) { self.x3_es2015.transform_class_on_exit(class); } - fn visit_class_body(&mut self, body: &mut ClassBody<'a>) { + fn enter_class_body(&mut self, body: &mut ClassBody<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_class_body(body); - - walk_mut::walk_class_body_mut(self, body); } - fn visit_export_default_declaration(&mut self, decl: &mut ExportDefaultDeclaration<'a>) { + fn enter_export_default_declaration( + &mut self, + decl: &mut ExportDefaultDeclaration<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x1_react.transform_export_default_declaration(decl); - - walk_mut::walk_export_default_declaration_mut(self, decl); } - fn visit_export_named_declaration(&mut self, decl: &mut ExportNamedDeclaration<'a>) { + fn enter_export_named_declaration( + &mut self, + decl: &mut ExportNamedDeclaration<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_export_named_declaration(decl); - - walk_mut::walk_export_named_declaration_mut(self, decl); } - fn visit_expression(&mut self, expr: &mut Expression<'a>) { + fn enter_expression(&mut self, expr: &mut Expression<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_expression(expr); self.x1_react.transform_expression(expr); self.x3_es2015.transform_expression(expr); + } - walk_mut::walk_expression_mut(self, expr); - + fn exit_expression(&mut self, expr: &mut Expression<'a>, _ctx: &TraverseCtx<'a>) { self.x3_es2015.transform_expression_on_exit(expr); } - fn visit_formal_parameter(&mut self, param: &mut FormalParameter<'a>) { + fn enter_formal_parameter(&mut self, param: &mut FormalParameter<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_formal_parameter(param); - - walk_mut::walk_formal_parameter_mut(self, param); } - fn visit_function(&mut self, func: &mut Function<'a>, flags: Option) { + fn enter_function(&mut self, func: &mut Function<'a>, _ctx: &TraverseCtx<'a>) { + // TODO: Scope flags + // Was a function param: flags: Option, + let flags = None; self.x0_typescript.transform_function(func, flags); - - walk_mut::walk_function_mut(self, func, flags); - } - - fn visit_import_declaration(&mut self, decl: &mut ImportDeclaration<'a>) { - walk_mut::walk_import_declaration_mut(self, decl); } - fn visit_jsx_opening_element(&mut self, elem: &mut JSXOpeningElement<'a>) { + fn enter_jsx_opening_element( + &mut self, + elem: &mut JSXOpeningElement<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_jsx_opening_element(elem); self.x1_react.transform_jsx_opening_element(elem); self.x3_es2015.transform_jsx_opening_element(elem); - walk_mut::walk_jsx_opening_element_mut(self, elem); } - fn visit_method_definition(&mut self, def: &mut MethodDefinition<'a>) { + fn enter_method_definition(&mut self, def: &mut MethodDefinition<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_method_definition(def); + } - walk_mut::walk_method_definition_mut(self, def); - + fn exit_method_definition(&mut self, def: &mut MethodDefinition<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_method_definition_on_exit(def); } - fn visit_new_expression(&mut self, expr: &mut NewExpression<'a>) { + fn enter_new_expression(&mut self, expr: &mut NewExpression<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_new_expression(expr); - - walk_mut::walk_new_expression_mut(self, expr); } - fn visit_object_property(&mut self, prop: &mut ObjectProperty<'a>) { + fn enter_object_property(&mut self, prop: &mut ObjectProperty<'a>, _ctx: &TraverseCtx<'a>) { self.x1_react.transform_object_property(prop); - - walk_mut::walk_object_property_mut(self, prop); } - fn visit_property_definition(&mut self, def: &mut PropertyDefinition<'a>) { + fn enter_property_definition( + &mut self, + def: &mut PropertyDefinition<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_property_definition(def); - - walk_mut::walk_property_definition_mut(self, def); } - fn visit_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>) { - walk_mut::walk_statements_mut(self, stmts); - + fn exit_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_statements_on_exit(stmts); self.x3_es2015.transform_statements_on_exit(stmts); } - fn visit_tagged_template_expression(&mut self, expr: &mut TaggedTemplateExpression<'a>) { + fn enter_tagged_template_expression( + &mut self, + expr: &mut TaggedTemplateExpression<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_tagged_template_expression(expr); - - walk_mut::walk_tagged_template_expression_mut(self, expr); } - fn visit_variable_declarator(&mut self, declarator: &mut VariableDeclarator<'a>) { + fn enter_variable_declarator( + &mut self, + declarator: &mut VariableDeclarator<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x1_react.transform_variable_declarator(declarator); - - walk_mut::walk_variable_declarator_mut(self, declarator); } - fn visit_identifier_reference(&mut self, ident: &mut IdentifierReference<'a>) { - self.x0_typescript.transform_identifier_reference(ident); - walk_mut::walk_identifier_reference_mut(self, ident); + fn enter_identifier_reference( + &mut self, + ident: &mut IdentifierReference<'a>, + ctx: &TraverseCtx<'a>, + ) { + self.x0_typescript.transform_identifier_reference(ident, ctx); } - fn visit_statement(&mut self, stmt: &mut Statement<'a>) { + fn enter_statement(&mut self, stmt: &mut Statement<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_statement(stmt); - walk_mut::walk_statement_mut(self, stmt); } - fn visit_declaration(&mut self, decl: &mut Declaration<'a>) { + fn enter_declaration(&mut self, decl: &mut Declaration<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_declaration(decl); self.x3_es2015.transform_declaration(decl); + } - walk_mut::walk_declaration_mut(self, decl); - + fn exit_declaration(&mut self, decl: &mut Declaration<'a>, _ctx: &TraverseCtx<'a>) { self.x3_es2015.transform_declaration_on_exit(decl); } - fn visit_if_statement(&mut self, stmt: &mut IfStatement<'a>) { + fn enter_if_statement(&mut self, stmt: &mut IfStatement<'a>, _ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_if_statement(stmt); - walk_mut::walk_if_statement_mut(self, stmt); } - fn visit_module_declaration(&mut self, decl: &mut ModuleDeclaration<'a>) { + fn enter_module_declaration( + &mut self, + decl: &mut ModuleDeclaration<'a>, + _ctx: &TraverseCtx<'a>, + ) { self.x0_typescript.transform_module_declaration(decl); - walk_mut::walk_module_declaration_mut(self, decl); } } diff --git a/crates/oxc_transformer/src/typescript/mod.rs b/crates/oxc_transformer/src/typescript/mod.rs index b0076bf80e756..f5666611fe008 100644 --- a/crates/oxc_transformer/src/typescript/mod.rs +++ b/crates/oxc_transformer/src/typescript/mod.rs @@ -12,6 +12,7 @@ use serde::Deserialize; use oxc_allocator::Vec; use oxc_ast::ast::*; use oxc_syntax::scope::ScopeFlags; +use oxc_traverse::TraverseCtx; use crate::context::Ctx; @@ -184,8 +185,14 @@ impl<'a> TypeScript<'a> { self.annotations.transform_tagged_template_expression(expr); } - pub fn transform_identifier_reference(&mut self, ident: &mut IdentifierReference<'a>) { - self.reference_collector.visit_identifier_reference(ident); + pub fn transform_identifier_reference( + &mut self, + ident: &mut IdentifierReference<'a>, + ctx: &TraverseCtx, + ) { + if !ctx.parent().is_ts_interface_heritage() && !ctx.parent().is_ts_type_reference() { + self.reference_collector.visit_identifier_reference(ident); + } } pub fn transform_declaration(&mut self, decl: &mut Declaration<'a>) { From 773e9279109a9631a463262cc7725d02d11ea52e Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:19:57 +0100 Subject: [PATCH 4/7] Implement `transform-react-display-name` with bottom-up lookup --- crates/oxc_transformer/src/lib.rs | 23 +--- .../src/react/display_name/mod.rs | 101 +++++++++--------- crates/oxc_transformer/src/react/mod.rs | 26 ++--- tasks/transform_conformance/babel.snap.md | 6 +- 4 files changed, 63 insertions(+), 93 deletions(-) diff --git a/crates/oxc_transformer/src/lib.rs b/crates/oxc_transformer/src/lib.rs index c1fe0d3fcc47e..22080fc12ffe0 100644 --- a/crates/oxc_transformer/src/lib.rs +++ b/crates/oxc_transformer/src/lib.rs @@ -115,8 +115,9 @@ impl<'a> Traverse<'a> for Transformer<'a> { self.x0_typescript.transform_binding_pattern(pat); } - fn enter_call_expression(&mut self, expr: &mut CallExpression<'a>, _ctx: &TraverseCtx<'a>) { + fn enter_call_expression(&mut self, expr: &mut CallExpression<'a>, ctx: &TraverseCtx<'a>) { self.x0_typescript.transform_call_expression(expr); + self.x1_react.transform_call_expression(expr, ctx); } fn enter_class(&mut self, class: &mut Class<'a>, _ctx: &TraverseCtx<'a>) { @@ -132,14 +133,6 @@ impl<'a> Traverse<'a> for Transformer<'a> { self.x0_typescript.transform_class_body(body); } - fn enter_export_default_declaration( - &mut self, - decl: &mut ExportDefaultDeclaration<'a>, - _ctx: &TraverseCtx<'a>, - ) { - self.x1_react.transform_export_default_declaration(decl); - } - fn enter_export_named_declaration( &mut self, decl: &mut ExportNamedDeclaration<'a>, @@ -191,10 +184,6 @@ impl<'a> Traverse<'a> for Transformer<'a> { self.x0_typescript.transform_new_expression(expr); } - fn enter_object_property(&mut self, prop: &mut ObjectProperty<'a>, _ctx: &TraverseCtx<'a>) { - self.x1_react.transform_object_property(prop); - } - fn enter_property_definition( &mut self, def: &mut PropertyDefinition<'a>, @@ -216,14 +205,6 @@ impl<'a> Traverse<'a> for Transformer<'a> { self.x0_typescript.transform_tagged_template_expression(expr); } - fn enter_variable_declarator( - &mut self, - declarator: &mut VariableDeclarator<'a>, - _ctx: &TraverseCtx<'a>, - ) { - self.x1_react.transform_variable_declarator(declarator); - } - fn enter_identifier_reference( &mut self, ident: &mut IdentifierReference<'a>, diff --git a/crates/oxc_transformer/src/react/display_name/mod.rs b/crates/oxc_transformer/src/react/display_name/mod.rs index b922a74e8e7af..7f52c0aaf21c5 100644 --- a/crates/oxc_transformer/src/react/display_name/mod.rs +++ b/crates/oxc_transformer/src/react/display_name/mod.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use oxc_allocator::Box; use oxc_ast::ast::*; use oxc_span::{Atom, SPAN}; +use oxc_traverse::{Ancestor, FinderRet, TraverseCtx}; use crate::context::Ctx; @@ -14,10 +15,6 @@ use crate::context::Ctx; /// /// In: `var bar = createReactClass({});` /// Out: `var bar = createReactClass({ displayName: "bar" });` -/// -/// NOTE: The current implementation uses the top-down approach on `AssignmentExpression`, `VariableDeclaration`, -/// but can be rewritten with a bottom-up approach. -/// See pub struct ReactDisplayName<'a> { ctx: Ctx<'a>, } @@ -30,65 +27,71 @@ impl<'a> ReactDisplayName<'a> { // Transforms impl<'a> ReactDisplayName<'a> { - /// `foo = React.createClass({})` - pub fn transform_assignment_expression(&self, assign_expr: &mut AssignmentExpression<'a>) { - let Some(obj_expr) = Self::get_object_from_create_class(&mut assign_expr.right) else { + pub fn transform_call_expression( + &self, + call_expr: &mut CallExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { + let Some(obj_expr) = Self::get_object_from_create_class(call_expr) else { return; }; - let name = match &assign_expr.left { - AssignmentTarget::AssignmentTargetIdentifier(ident) => ident.name.clone(), - target => { - if let Some(target) = target.as_member_expression() { - if let Some(name) = target.static_property_name() { - self.ctx.ast.new_atom(name) + + let name = ctx.find_ancestor(|ancestor| { + match ancestor { + // `foo = React.createClass({})` + Ancestor::AssignmentExpressionRight(assign_expr) => match &assign_expr.left() { + AssignmentTarget::AssignmentTargetIdentifier(ident) => { + FinderRet::Found(ident.name.clone()) + } + target => { + if let Some(target) = target.as_member_expression() { + if let Some(name) = target.static_property_name() { + FinderRet::Found(ctx.ast.new_atom(name)) + } else { + FinderRet::Stop + } + } else { + FinderRet::Stop + } + } + }, + // `let foo = React.createClass({})` + Ancestor::VariableDeclaratorInit(declarator) => match &declarator.id().kind { + BindingPatternKind::BindingIdentifier(ident) => { + FinderRet::Found(ident.name.clone()) + } + _ => FinderRet::Stop, + }, + // `{foo: React.createClass({})}` + Ancestor::ObjectPropertyValue(prop) => { + if let Some(name) = prop.key().static_name() { + FinderRet::Found(ctx.ast.new_atom(&name)) } else { - return; + FinderRet::Stop } - } else { - return; } + // `export default React.createClass({})` + // Uses the current file name as the display name. + Ancestor::ExportDefaultDeclarationDeclaration(_) => { + FinderRet::Found(ctx.ast.new_atom(&self.ctx.filename)) + } + // Stop crawling up when hit a statement + _ if ancestor.is_via_statement() => FinderRet::Stop, + _ => FinderRet::Continue, } - }; - self.add_display_name(obj_expr, name); - } - - /// `let foo = React.createClass({})` - pub fn transform_variable_declarator(&self, declarator: &mut VariableDeclarator<'a>) { - let Some(init_expr) = declarator.init.as_mut() else { return }; - let Some(obj_expr) = Self::get_object_from_create_class(init_expr) else { - return; - }; - let name = match &declarator.id.kind { - BindingPatternKind::BindingIdentifier(ident) => ident.name.clone(), - _ => return, - }; - self.add_display_name(obj_expr, name); - } - - /// `{foo: React.createClass({})}` - pub fn transform_object_property(&self, prop: &mut ObjectProperty<'a>) { - let Some(obj_expr) = Self::get_object_from_create_class(&mut prop.value) else { return }; - let Some(name) = prop.key.static_name() else { return }; - let name = self.ctx.ast.new_atom(&name); - self.add_display_name(obj_expr, name); - } + }); - /// `export default React.createClass({})` - /// Uses the current file name as the display name. - pub fn transform_export_default_declaration(&self, decl: &mut ExportDefaultDeclaration<'a>) { - let Some(expr) = decl.declaration.as_expression_mut() else { return }; - let Some(obj_expr) = Self::get_object_from_create_class(expr) else { return }; - let name = self.ctx.ast.new_atom(&self.ctx.filename); - self.add_display_name(obj_expr, name); + if let Some(name) = name { + self.add_display_name(obj_expr, name); + } } } impl<'a> ReactDisplayName<'a> { /// Get the object from `React.createClass({})` or `createReactClass({})` fn get_object_from_create_class<'b>( - e: &'b mut Expression<'a>, + call_expr: &'b mut CallExpression<'a>, ) -> Option<&'b mut Box<'a, ObjectExpression<'a>>> { - let Expression::CallExpression(call_expr) = e else { return None }; if match &call_expr.callee { callee @ match_member_expression!(Expression) => { !callee.to_member_expression().is_specific_member_access("React", "createClass") diff --git a/crates/oxc_transformer/src/react/mod.rs b/crates/oxc_transformer/src/react/mod.rs index d46515098e9e8..16859a2af8cd9 100644 --- a/crates/oxc_transformer/src/react/mod.rs +++ b/crates/oxc_transformer/src/react/mod.rs @@ -8,6 +8,7 @@ mod utils; use std::rc::Rc; use oxc_ast::ast::*; +use oxc_traverse::TraverseCtx; use crate::context::Ctx; @@ -58,11 +59,6 @@ impl<'a> React<'a> { pub fn transform_expression(&mut self, expr: &mut Expression<'a>) { match expr { - Expression::AssignmentExpression(e) => { - if self.options.display_name_plugin { - self.display_name.transform_assignment_expression(e); - } - } Expression::JSXElement(e) => { if self.options.is_jsx_plugin_enabled() { *expr = self.jsx.transform_jsx_element(e); @@ -77,21 +73,13 @@ impl<'a> React<'a> { } } - pub fn transform_variable_declarator(&self, declarator: &mut VariableDeclarator<'a>) { - if self.options.display_name_plugin { - self.display_name.transform_variable_declarator(declarator); - } - } - - pub fn transform_object_property(&self, prop: &mut ObjectProperty<'a>) { - if self.options.display_name_plugin { - self.display_name.transform_object_property(prop); - } - } - - pub fn transform_export_default_declaration(&self, decl: &mut ExportDefaultDeclaration<'a>) { + pub fn transform_call_expression( + &self, + call_expr: &mut CallExpression<'a>, + ctx: &TraverseCtx<'a>, + ) { if self.options.display_name_plugin { - self.display_name.transform_export_default_declaration(decl); + self.display_name.transform_call_expression(call_expr, ctx); } } diff --git a/tasks/transform_conformance/babel.snap.md b/tasks/transform_conformance/babel.snap.md index ee724f74be6f2..f3df2707d46ed 100644 --- a/tasks/transform_conformance/babel.snap.md +++ b/tasks/transform_conformance/babel.snap.md @@ -1,6 +1,7 @@ -Passed: 294/363 +Passed: 295/363 # All Passed: +* babel-plugin-transform-react-display-name * babel-plugin-transform-react-jsx-source @@ -68,9 +69,6 @@ Passed: 294/363 * autoImport/complicated-scope-module/input.js * react-automatic/should-throw-when-filter-is-specified/input.js -# babel-plugin-transform-react-display-name (15/16) -* display-name/nested/input.js - # babel-plugin-transform-react-jsx-self (1/3) * react-source/arrow-function/input.js * react-source/disable-with-super/input.js From 71b5ba5677cc88285489a2e97a825ab7b6b44356 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:23:58 +0100 Subject: [PATCH 5/7] Temp: Test for Miri --- Cargo.lock | 11 +++++++ tasks/test_transform/Cargo.toml | 25 ++++++++++++++++ tasks/test_transform/src/main.rs | 51 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 tasks/test_transform/Cargo.toml create mode 100644 tasks/test_transform/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 8acfc841977e8..ab000a655e5ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1667,6 +1667,17 @@ dependencies = [ "url", ] +[[package]] +name = "oxc_test_transform" +version = "0.0.0" +dependencies = [ + "oxc_allocator", + "oxc_codegen", + "oxc_parser", + "oxc_span", + "oxc_transformer", +] + [[package]] name = "oxc_transform_conformance" version = "0.0.0" diff --git a/tasks/test_transform/Cargo.toml b/tasks/test_transform/Cargo.toml new file mode 100644 index 0000000000000..706dba51f9340 --- /dev/null +++ b/tasks/test_transform/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "oxc_test_transform" +version = "0.0.0" +publish = false +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true + +[lints] +workspace = true + +[[bin]] +name = "oxc_test_transform" +test = false + +[dependencies] +oxc_allocator = { workspace = true } +oxc_codegen = { workspace = true } +oxc_parser = { workspace = true } +oxc_span = { workspace = true } +oxc_transformer = { workspace = true } diff --git a/tasks/test_transform/src/main.rs b/tasks/test_transform/src/main.rs new file mode 100644 index 0000000000000..5692657c8a951 --- /dev/null +++ b/tasks/test_transform/src/main.rs @@ -0,0 +1,51 @@ +use std::path::Path; + +use oxc_allocator::Allocator; +use oxc_codegen::{Codegen, CodegenOptions}; +use oxc_parser::{Parser, ParserReturn}; +use oxc_span::SourceType; +use oxc_transformer::{TransformOptions, Transformer}; + +fn main() { + // display-name/nested + transform( + "foo.js", + "var foo = qux(createReactClass({}));\nvar bar = qux(React.createClass({}));\n", + ); + + // imports/elision-locations + transform( + "foo.ts", + "import { A, B, C, D, E, F, G, H } from \"m\"; +class Class extends A implements C {} +interface Iface extends E {} +const x: G = 0; +const y: H.T = 0; +", + ); +} + +fn transform(filename: &str, source_text: &str) { + let allocator = Allocator::default(); + let source_type = SourceType::from_path(filename).unwrap(); + let ParserReturn { trivias, program, .. } = + Parser::new(&allocator, source_text, source_type).parse(); + + let transform_options = TransformOptions::default(); + let program = allocator.alloc(program); + Transformer::new( + &allocator, + Path::new(filename), + source_type, + source_text, + &trivias, + transform_options, + ) + .build(program) + .unwrap(); + + let codegen_options = CodegenOptions::default(); + let transformed_code = + Codegen::::new("", source_text, codegen_options.clone()).build(program).source_text; + println!("{transformed_code}"); +} From 2f14e2ac132556097aa852c6b0129eb0577af09c Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 5 May 2024 22:29:08 +0100 Subject: [PATCH 6/7] TODO list --- TODO.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000000000..ab474747bcd0f --- /dev/null +++ b/TODO.md @@ -0,0 +1,14 @@ +# TODO + +* Implement `Debug` for `Ancestor` and `AncestorWithout*` types + * Implement intermediate `as_ref` method which creates an object of references, which debug can use. +* Improve API for `Ancestor::is_via_*` +* API to read siblings in a Vec. +* API to get which index current node is in a Vec. +* API to allow mutating other branches of AST + * I think all that's required is to: + * Pass `&mut TraverseCtx` to `enter_*` and `exit_*` + * Add `parent_mut`, `ancestor_mut` methods to `TraveseCtx` + * Add `span_mut`, `directives_mut` etc to all `*Without*` types + * Mutable borrow on `TraverseCtx` and `Ancestor` would prevent creating more than 1 mut ref at a time +* Move `Span` to constant position in all structs, for fast lookup? From 2a5cd8c5ad17e68ffd27fa31a01343d2bc3f34f2 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Mon, 6 May 2024 19:09:06 +0100 Subject: [PATCH 7/7] Update TODO list --- TODO.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index ab474747bcd0f..f48fe783e925f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,10 @@ # TODO +* Set enum discriminants for `Ancestor` so that `is_*` can use bitwise ops + `retag_stack` can write 1 byte only. + * Compiler does not auto-optimize `matches!()` in `is_*` functions. Need to do it manually. + * See `ancestor_type2` branch. + * Need to handle big endian systems where bytes are in reverse order. + * That's easy, but how to run tests on big endian? Miri? * Implement `Debug` for `Ancestor` and `AncestorWithout*` types * Implement intermediate `as_ref` method which creates an object of references, which debug can use. * Improve API for `Ancestor::is_via_*` @@ -8,7 +13,10 @@ * API to allow mutating other branches of AST * I think all that's required is to: * Pass `&mut TraverseCtx` to `enter_*` and `exit_*` - * Add `parent_mut`, `ancestor_mut` methods to `TraveseCtx` + * Add `parent_mut`, `ancestor_mut` methods to `TraverseCtx` * Add `span_mut`, `directives_mut` etc to all `*Without*` types - * Mutable borrow on `TraverseCtx` and `Ancestor` would prevent creating more than 1 mut ref at a time + * Mutable borrow on `TraverseCtx` and `Ancestor` prevents creating more than 1 mut ref at a time + * Mutable borrow on `TraverseCtx` unfortunately also blocks calling `ctx.alloc()`. + * Can solve that with e.g. `ctx.ancestry.parent_mut()` + `ctx.ast.alloc()` - separate properties + can be mut borrowed at same time. * Move `Span` to constant position in all structs, for fast lookup?