Skip to main content

tsz_parser/parser/
node_access.rs

1//! `NodeArena` access methods, `NodeView`, and `NodeAccess` trait.
2//!
3//! This module contains all node access/query methods, the `NodeView` ergonomic wrapper,
4//! `Node` kind utility methods, and the `NodeAccess` trait.
5use super::base::{NodeIndex, NodeList};
6use super::node::{
7    AccessExprData, AccessorData, ArrayTypeData, BinaryExprData, BindingElementData,
8    BindingPatternData, BlockData, CallExprData, CaseClauseData, CatchClauseData, ClassData,
9    CompositeTypeData, ComputedPropertyData, ConditionalExprData, ConditionalTypeData,
10    ConstructorData, DecoratorData, EnumData, EnumMemberData, ExportAssignmentData, ExportDeclData,
11    ExprStatementData, ExprWithTypeArgsData, ExtendedNodeInfo, ForInOfData, FunctionData,
12    FunctionTypeData, HeritageData, IdentifierData, IfStatementData, ImportClauseData,
13    ImportDeclData, IndexSignatureData, IndexedAccessTypeData, InferTypeData, InterfaceData,
14    JsxAttributeData, JsxAttributesData, JsxClosingData, JsxElementData, JsxExpressionData,
15    JsxFragmentData, JsxNamespacedNameData, JsxOpeningData, JsxSpreadAttributeData, JsxTextData,
16    JumpData, LabeledData, LiteralData, LiteralExprData, LiteralTypeData, LoopData, MappedTypeData,
17    MethodDeclData, ModuleBlockData, ModuleData, NamedImportsData, NamedTupleMemberData, Node,
18    NodeArena, ParameterData, ParenthesizedData, PropertyAssignmentData, PropertyDeclData,
19    QualifiedNameData, ReturnData, ShorthandPropertyData, SignatureData, SourceFileData,
20    SpecifierData, SpreadData, SwitchData, TaggedTemplateData, TemplateExprData,
21    TemplateLiteralTypeData, TemplateSpanData, TryData, TupleTypeData, TypeAliasData,
22    TypeAssertionData, TypeLiteralData, TypeOperatorData, TypeParameterData, TypePredicateData,
23    TypeQueryData, TypeRefData, UnaryExprData, UnaryExprDataEx, VariableData,
24    VariableDeclarationData, WrappedTypeData,
25};
26use super::syntax_kind_ext::{
27    ARRAY_BINDING_PATTERN, ARRAY_LITERAL_EXPRESSION, ARRAY_TYPE, ARROW_FUNCTION, AS_EXPRESSION,
28    AWAIT_EXPRESSION, BINARY_EXPRESSION, BINDING_ELEMENT, BLOCK, BREAK_STATEMENT, CALL_EXPRESSION,
29    CALL_SIGNATURE, CASE_BLOCK, CASE_CLAUSE, CATCH_CLAUSE, CLASS_DECLARATION, CLASS_EXPRESSION,
30    CLASS_STATIC_BLOCK_DECLARATION, COMPUTED_PROPERTY_NAME, CONDITIONAL_EXPRESSION,
31    CONDITIONAL_TYPE, CONSTRUCT_SIGNATURE, CONSTRUCTOR, CONSTRUCTOR_TYPE, CONTINUE_STATEMENT,
32    DEBUGGER_STATEMENT, DECORATOR, DEFAULT_CLAUSE, DO_STATEMENT, ELEMENT_ACCESS_EXPRESSION,
33    ENUM_DECLARATION, ENUM_MEMBER, EXPORT_ASSIGNMENT, EXPORT_DECLARATION, EXPORT_SPECIFIER,
34    EXPRESSION_STATEMENT, EXPRESSION_WITH_TYPE_ARGUMENTS, FOR_IN_STATEMENT, FOR_OF_STATEMENT,
35    FOR_STATEMENT, FUNCTION_DECLARATION, FUNCTION_EXPRESSION, FUNCTION_TYPE, GET_ACCESSOR,
36    HERITAGE_CLAUSE, IF_STATEMENT, IMPORT_CLAUSE, IMPORT_DECLARATION, IMPORT_EQUALS_DECLARATION,
37    IMPORT_SPECIFIER, IMPORT_TYPE, INDEX_SIGNATURE, INDEXED_ACCESS_TYPE, INFER_TYPE,
38    INTERFACE_DECLARATION, INTERSECTION_TYPE, JSX_ATTRIBUTE, JSX_ATTRIBUTES, JSX_CLOSING_ELEMENT,
39    JSX_ELEMENT, JSX_EXPRESSION, JSX_FRAGMENT, JSX_NAMESPACED_NAME, JSX_OPENING_ELEMENT,
40    JSX_SELF_CLOSING_ELEMENT, JSX_SPREAD_ATTRIBUTE, LABELED_STATEMENT, LITERAL_TYPE, MAPPED_TYPE,
41    METHOD_DECLARATION, METHOD_SIGNATURE, MODULE_BLOCK, MODULE_DECLARATION, NAMED_EXPORTS,
42    NAMED_IMPORTS, NAMED_TUPLE_MEMBER, NAMESPACE_EXPORT, NAMESPACE_IMPORT, NEW_EXPRESSION,
43    NON_NULL_EXPRESSION, OBJECT_BINDING_PATTERN, OBJECT_LITERAL_EXPRESSION, OPTIONAL_TYPE,
44    PARAMETER, PARENTHESIZED_EXPRESSION, PARENTHESIZED_TYPE, POSTFIX_UNARY_EXPRESSION,
45    PREFIX_UNARY_EXPRESSION, PROPERTY_ACCESS_EXPRESSION, PROPERTY_ASSIGNMENT, PROPERTY_DECLARATION,
46    PROPERTY_SIGNATURE, QUALIFIED_NAME, REST_TYPE, RETURN_STATEMENT, SATISFIES_EXPRESSION,
47    SET_ACCESSOR, SHORTHAND_PROPERTY_ASSIGNMENT, SOURCE_FILE, SPREAD_ASSIGNMENT, SPREAD_ELEMENT,
48    SWITCH_STATEMENT, TAGGED_TEMPLATE_EXPRESSION, TEMPLATE_EXPRESSION, TEMPLATE_LITERAL_TYPE,
49    TEMPLATE_SPAN, THROW_STATEMENT, TRY_STATEMENT, TUPLE_TYPE, TYPE_ALIAS_DECLARATION,
50    TYPE_ASSERTION, TYPE_LITERAL, TYPE_OPERATOR, TYPE_PARAMETER, TYPE_PREDICATE, TYPE_QUERY,
51    TYPE_REFERENCE, UNION_TYPE, VARIABLE_DECLARATION, VARIABLE_DECLARATION_LIST,
52    VARIABLE_STATEMENT, WHILE_STATEMENT, WITH_STATEMENT, YIELD_EXPRESSION,
53};
54
55impl NodeArena {
56    /// Get a thin node by index
57    #[inline]
58    #[must_use]
59    pub fn get(&self, index: NodeIndex) -> Option<&Node> {
60        if index.is_none() {
61            None
62        } else {
63            self.nodes.get(index.0 as usize)
64        }
65    }
66
67    /// Get a mutable thin node by index
68    #[inline]
69    #[must_use]
70    pub fn get_mut(&mut self, index: NodeIndex) -> Option<&mut Node> {
71        if index.is_none() {
72            None
73        } else {
74            self.nodes.get_mut(index.0 as usize)
75        }
76    }
77
78    /// Get extended info for a node
79    #[inline]
80    #[must_use]
81    pub fn get_extended(&self, index: NodeIndex) -> Option<&ExtendedNodeInfo> {
82        if index.is_none() {
83            None
84        } else {
85            self.extended_info.get(index.0 as usize)
86        }
87    }
88
89    /// Get mutable extended info for a node
90    #[inline]
91    #[must_use]
92    pub fn get_extended_mut(&mut self, index: NodeIndex) -> Option<&mut ExtendedNodeInfo> {
93        if index.is_none() {
94            None
95        } else {
96            self.extended_info.get_mut(index.0 as usize)
97        }
98    }
99
100    /// Get identifier data for a node.
101    /// Returns None if node is not an identifier or has no data.
102    #[inline]
103    #[must_use]
104    pub fn get_identifier(&self, node: &Node) -> Option<&IdentifierData> {
105        use tsz_scanner::SyntaxKind;
106        if node.has_data()
107            && (node.kind == SyntaxKind::Identifier as u16
108                || node.kind == SyntaxKind::PrivateIdentifier as u16)
109        {
110            self.identifiers.get(node.data_index as usize)
111        } else {
112            None
113        }
114    }
115
116    /// Get literal data for a node.
117    /// Returns None if node is not a literal or has no data.
118    #[inline]
119    #[must_use]
120    pub fn get_literal(&self, node: &Node) -> Option<&LiteralData> {
121        use tsz_scanner::SyntaxKind;
122        if node.has_data()
123            && matches!(node.kind,
124                k if k == SyntaxKind::StringLiteral as u16 ||
125                     k == SyntaxKind::NumericLiteral as u16 ||
126                     k == SyntaxKind::BigIntLiteral as u16 ||
127                     k == SyntaxKind::RegularExpressionLiteral as u16 ||
128                     k == SyntaxKind::NoSubstitutionTemplateLiteral as u16 ||
129                     k == SyntaxKind::TemplateHead as u16 ||
130                     k == SyntaxKind::TemplateMiddle as u16 ||
131                     k == SyntaxKind::TemplateTail as u16
132            )
133        {
134            self.literals.get(node.data_index as usize)
135        } else {
136            None
137        }
138    }
139
140    /// Get binary expression data.
141    /// Returns None if node is not a binary expression or has no data.
142    #[inline]
143    #[must_use]
144    pub fn get_binary_expr(&self, node: &Node) -> Option<&BinaryExprData> {
145        use super::syntax_kind_ext::BINARY_EXPRESSION;
146        if node.has_data() && node.kind == BINARY_EXPRESSION {
147            self.binary_exprs.get(node.data_index as usize)
148        } else {
149            None
150        }
151    }
152
153    /// Get call expression data.
154    /// Returns None if node is not a call/new expression or has no data.
155    #[inline]
156    #[must_use]
157    pub fn get_call_expr(&self, node: &Node) -> Option<&CallExprData> {
158        use super::syntax_kind_ext::{CALL_EXPRESSION, NEW_EXPRESSION};
159        if node.has_data() && (node.kind == CALL_EXPRESSION || node.kind == NEW_EXPRESSION) {
160            self.call_exprs.get(node.data_index as usize)
161        } else {
162            None
163        }
164    }
165
166    /// Get access expression data (property access or element access).
167    /// Returns None if node is not an access expression or has no data.
168    #[inline]
169    #[must_use]
170    pub fn get_access_expr(&self, node: &Node) -> Option<&AccessExprData> {
171        use super::syntax_kind_ext::{ELEMENT_ACCESS_EXPRESSION, PROPERTY_ACCESS_EXPRESSION};
172        if node.has_data()
173            && (node.kind == PROPERTY_ACCESS_EXPRESSION || node.kind == ELEMENT_ACCESS_EXPRESSION)
174        {
175            self.access_exprs.get(node.data_index as usize)
176        } else {
177            None
178        }
179    }
180
181    /// Get conditional expression data (ternary: a ? b : c).
182    /// Returns None if node is not a conditional expression or has no data.
183    #[inline]
184    #[must_use]
185    pub fn get_conditional_expr(&self, node: &Node) -> Option<&ConditionalExprData> {
186        use super::syntax_kind_ext::CONDITIONAL_EXPRESSION;
187        if node.has_data() && node.kind == CONDITIONAL_EXPRESSION {
188            self.conditional_exprs.get(node.data_index as usize)
189        } else {
190            None
191        }
192    }
193
194    /// Get qualified name data (A.B syntax).
195    /// Returns None if node is not a qualified name or has no data.
196    #[inline]
197    #[must_use]
198    pub fn get_qualified_name(&self, node: &Node) -> Option<&QualifiedNameData> {
199        use super::syntax_kind_ext::QUALIFIED_NAME;
200        if node.has_data() && node.kind == QUALIFIED_NAME {
201            self.qualified_names.get(node.data_index as usize)
202        } else {
203            None
204        }
205    }
206
207    /// Get literal expression data (array or object literal).
208    /// Returns None if node is not a literal expression or has no data.
209    #[inline]
210    #[must_use]
211    pub fn get_literal_expr(&self, node: &Node) -> Option<&LiteralExprData> {
212        use super::syntax_kind_ext::{ARRAY_LITERAL_EXPRESSION, OBJECT_LITERAL_EXPRESSION};
213        if node.has_data()
214            && (node.kind == ARRAY_LITERAL_EXPRESSION || node.kind == OBJECT_LITERAL_EXPRESSION)
215        {
216            self.literal_exprs.get(node.data_index as usize)
217        } else {
218            None
219        }
220    }
221
222    /// Get property assignment data.
223    /// Returns None if node is not a property assignment or has no data.
224    #[inline]
225    #[must_use]
226    pub fn get_property_assignment(&self, node: &Node) -> Option<&PropertyAssignmentData> {
227        use super::syntax_kind_ext::PROPERTY_ASSIGNMENT;
228        if node.has_data() && node.kind == PROPERTY_ASSIGNMENT {
229            self.property_assignments.get(node.data_index as usize)
230        } else {
231            None
232        }
233    }
234
235    /// Get type assertion data (as/satisfies/type assertion).
236    /// Returns None if node is not a type assertion or has no data.
237    #[inline]
238    #[must_use]
239    pub fn get_type_assertion(&self, node: &Node) -> Option<&TypeAssertionData> {
240        use super::syntax_kind_ext::{AS_EXPRESSION, SATISFIES_EXPRESSION, TYPE_ASSERTION};
241        if node.has_data()
242            && (node.kind == TYPE_ASSERTION
243                || node.kind == AS_EXPRESSION
244                || node.kind == SATISFIES_EXPRESSION)
245        {
246            self.type_assertions.get(node.data_index as usize)
247        } else {
248            None
249        }
250    }
251
252    /// Get unary expression data (prefix or postfix).
253    /// Returns None if node is not a unary expression or has no data.
254    #[inline]
255    #[must_use]
256    pub fn get_unary_expr(&self, node: &Node) -> Option<&UnaryExprData> {
257        use super::syntax_kind_ext::{POSTFIX_UNARY_EXPRESSION, PREFIX_UNARY_EXPRESSION};
258        if node.has_data()
259            && (node.kind == PREFIX_UNARY_EXPRESSION || node.kind == POSTFIX_UNARY_EXPRESSION)
260        {
261            self.unary_exprs.get(node.data_index as usize)
262        } else {
263            None
264        }
265    }
266
267    /// Get extended unary expression data (await/yield/non-null/spread).
268    /// Returns None if node is not an await/yield/non-null/spread expression or has no data.
269    #[inline]
270    #[must_use]
271    pub fn get_unary_expr_ex(&self, node: &Node) -> Option<&UnaryExprDataEx> {
272        use super::syntax_kind_ext::{
273            AWAIT_EXPRESSION, NON_NULL_EXPRESSION, SPREAD_ELEMENT, YIELD_EXPRESSION,
274        };
275        if node.has_data()
276            && (node.kind == AWAIT_EXPRESSION
277                || node.kind == YIELD_EXPRESSION
278                || node.kind == NON_NULL_EXPRESSION
279                || node.kind == SPREAD_ELEMENT)
280        {
281            self.unary_exprs_ex.get(node.data_index as usize)
282        } else {
283            None
284        }
285    }
286
287    /// Get function data.
288    /// Returns None if node is not a function-like node or has no data.
289    #[inline]
290    #[must_use]
291    pub fn get_function(&self, node: &Node) -> Option<&FunctionData> {
292        if node.has_data()
293            && matches!(
294                node.kind,
295                FUNCTION_DECLARATION | FUNCTION_EXPRESSION | ARROW_FUNCTION
296            )
297        {
298            self.functions.get(node.data_index as usize)
299        } else {
300            None
301        }
302    }
303
304    /// Get class data.
305    /// Returns None if node is not a class declaration/expression or has no data.
306    #[inline]
307    #[must_use]
308    pub fn get_class(&self, node: &Node) -> Option<&ClassData> {
309        use super::syntax_kind_ext::{CLASS_DECLARATION, CLASS_EXPRESSION};
310        if node.has_data() && (node.kind == CLASS_DECLARATION || node.kind == CLASS_EXPRESSION) {
311            self.classes.get(node.data_index as usize)
312        } else {
313            None
314        }
315    }
316
317    /// Get block data.
318    /// Returns None if node is not a block or has no data.
319    #[inline]
320    #[must_use]
321    pub fn get_block(&self, node: &Node) -> Option<&BlockData> {
322        use super::syntax_kind_ext::{BLOCK, CASE_BLOCK, CLASS_STATIC_BLOCK_DECLARATION};
323        if node.has_data()
324            && (node.kind == BLOCK
325                || node.kind == CLASS_STATIC_BLOCK_DECLARATION
326                || node.kind == CASE_BLOCK)
327        {
328            self.blocks.get(node.data_index as usize)
329        } else {
330            None
331        }
332    }
333
334    /// Get source file data.
335    /// Returns None if node is not a source file or has no data.
336    #[inline]
337    #[must_use]
338    pub fn get_source_file(&self, node: &Node) -> Option<&SourceFileData> {
339        use super::syntax_kind_ext::SOURCE_FILE;
340        if node.has_data() && node.kind == SOURCE_FILE {
341            self.source_files.get(node.data_index as usize)
342        } else {
343            None
344        }
345    }
346
347    /// Get variable data (`VariableStatement` or `VariableDeclarationList`).
348    #[inline]
349    #[must_use]
350    pub fn get_variable(&self, node: &Node) -> Option<&VariableData> {
351        use super::syntax_kind_ext::{VARIABLE_DECLARATION_LIST, VARIABLE_STATEMENT};
352        if node.has_data()
353            && (node.kind == VARIABLE_STATEMENT || node.kind == VARIABLE_DECLARATION_LIST)
354        {
355            self.variables.get(node.data_index as usize)
356        } else {
357            None
358        }
359    }
360
361    /// Get variable declaration data.
362    #[inline]
363    #[must_use]
364    pub fn get_variable_declaration(&self, node: &Node) -> Option<&VariableDeclarationData> {
365        use super::syntax_kind_ext::VARIABLE_DECLARATION;
366        if node.has_data() && node.kind == VARIABLE_DECLARATION {
367            self.variable_declarations.get(node.data_index as usize)
368        } else {
369            None
370        }
371    }
372
373    /// Get interface data.
374    #[inline]
375    #[must_use]
376    pub fn get_interface(&self, node: &Node) -> Option<&InterfaceData> {
377        use super::syntax_kind_ext::INTERFACE_DECLARATION;
378        if node.has_data() && node.kind == INTERFACE_DECLARATION {
379            self.interfaces.get(node.data_index as usize)
380        } else {
381            None
382        }
383    }
384
385    /// Get type alias data.
386    #[inline]
387    #[must_use]
388    pub fn get_type_alias(&self, node: &Node) -> Option<&TypeAliasData> {
389        use super::syntax_kind_ext::TYPE_ALIAS_DECLARATION;
390        if node.has_data() && node.kind == TYPE_ALIAS_DECLARATION {
391            self.type_aliases.get(node.data_index as usize)
392        } else {
393            None
394        }
395    }
396
397    /// Get enum data.
398    #[inline]
399    #[must_use]
400    pub fn get_enum(&self, node: &Node) -> Option<&EnumData> {
401        use super::syntax_kind_ext::ENUM_DECLARATION;
402        if node.has_data() && node.kind == ENUM_DECLARATION {
403            self.enums.get(node.data_index as usize)
404        } else {
405            None
406        }
407    }
408
409    /// Get enum member data.
410    #[inline]
411    #[must_use]
412    pub fn get_enum_member(&self, node: &Node) -> Option<&EnumMemberData> {
413        use super::syntax_kind_ext::ENUM_MEMBER;
414        if node.has_data() && node.kind == ENUM_MEMBER {
415            self.enum_members.get(node.data_index as usize)
416        } else {
417            None
418        }
419    }
420
421    /// Get module data.
422    #[inline]
423    #[must_use]
424    pub fn get_module(&self, node: &Node) -> Option<&ModuleData> {
425        use super::syntax_kind_ext::MODULE_DECLARATION;
426        if node.has_data() && node.kind == MODULE_DECLARATION {
427            self.modules.get(node.data_index as usize)
428        } else {
429            None
430        }
431    }
432
433    /// Get module block data.
434    #[inline]
435    #[must_use]
436    pub fn get_module_block(&self, node: &Node) -> Option<&ModuleBlockData> {
437        use super::syntax_kind_ext::MODULE_BLOCK;
438        if node.has_data() && node.kind == MODULE_BLOCK {
439            self.module_blocks.get(node.data_index as usize)
440        } else {
441            None
442        }
443    }
444
445    /// Get if statement data.
446    #[inline]
447    #[must_use]
448    pub fn get_if_statement(&self, node: &Node) -> Option<&IfStatementData> {
449        use super::syntax_kind_ext::IF_STATEMENT;
450        if node.has_data() && node.kind == IF_STATEMENT {
451            self.if_statements.get(node.data_index as usize)
452        } else {
453            None
454        }
455    }
456
457    /// Get loop data (while, for, do-while).
458    #[inline]
459    #[must_use]
460    pub fn get_loop(&self, node: &Node) -> Option<&LoopData> {
461        use super::syntax_kind_ext::{DO_STATEMENT, FOR_STATEMENT, WHILE_STATEMENT};
462        if node.has_data()
463            && (node.kind == WHILE_STATEMENT
464                || node.kind == DO_STATEMENT
465                || node.kind == FOR_STATEMENT)
466        {
467            self.loops.get(node.data_index as usize)
468        } else {
469            None
470        }
471    }
472
473    /// Get for-in/for-of data.
474    #[inline]
475    #[must_use]
476    pub fn get_for_in_of(&self, node: &Node) -> Option<&ForInOfData> {
477        use super::syntax_kind_ext::{FOR_IN_STATEMENT, FOR_OF_STATEMENT};
478        if node.has_data() && (node.kind == FOR_IN_STATEMENT || node.kind == FOR_OF_STATEMENT) {
479            self.for_in_of.get(node.data_index as usize)
480        } else {
481            None
482        }
483    }
484
485    /// Get switch data.
486    #[inline]
487    #[must_use]
488    pub fn get_switch(&self, node: &Node) -> Option<&SwitchData> {
489        use super::syntax_kind_ext::SWITCH_STATEMENT;
490        if node.has_data() && node.kind == SWITCH_STATEMENT {
491            self.switch_data.get(node.data_index as usize)
492        } else {
493            None
494        }
495    }
496
497    /// Get case clause data.
498    #[inline]
499    #[must_use]
500    pub fn get_case_clause(&self, node: &Node) -> Option<&CaseClauseData> {
501        use super::syntax_kind_ext::{CASE_CLAUSE, DEFAULT_CLAUSE};
502        if node.has_data() && (node.kind == CASE_CLAUSE || node.kind == DEFAULT_CLAUSE) {
503            self.case_clauses.get(node.data_index as usize)
504        } else {
505            None
506        }
507    }
508
509    /// Get try data.
510    #[inline]
511    #[must_use]
512    pub fn get_try(&self, node: &Node) -> Option<&TryData> {
513        use super::syntax_kind_ext::TRY_STATEMENT;
514        if node.has_data() && node.kind == TRY_STATEMENT {
515            self.try_data.get(node.data_index as usize)
516        } else {
517            None
518        }
519    }
520
521    /// Get catch clause data.
522    #[inline]
523    #[must_use]
524    pub fn get_catch_clause(&self, node: &Node) -> Option<&CatchClauseData> {
525        use super::syntax_kind_ext::CATCH_CLAUSE;
526        if node.has_data() && node.kind == CATCH_CLAUSE {
527            self.catch_clauses.get(node.data_index as usize)
528        } else {
529            None
530        }
531    }
532
533    /// Get labeled statement data.
534    #[inline]
535    #[must_use]
536    pub fn get_labeled_statement(&self, node: &Node) -> Option<&LabeledData> {
537        use super::syntax_kind_ext::LABELED_STATEMENT;
538        if node.has_data() && node.kind == LABELED_STATEMENT {
539            self.labeled_data.get(node.data_index as usize)
540        } else {
541            None
542        }
543    }
544
545    /// Get jump data (break/continue statements).
546    #[inline]
547    #[must_use]
548    pub fn get_jump_data(&self, node: &Node) -> Option<&JumpData> {
549        use super::syntax_kind_ext::{BREAK_STATEMENT, CONTINUE_STATEMENT};
550        if node.has_data() && (node.kind == BREAK_STATEMENT || node.kind == CONTINUE_STATEMENT) {
551            self.jump_data.get(node.data_index as usize)
552        } else {
553            None
554        }
555    }
556
557    /// Get with statement data (stored in if statement pool).
558    #[inline]
559    #[must_use]
560    pub fn get_with_statement(&self, node: &Node) -> Option<&IfStatementData> {
561        use super::syntax_kind_ext::WITH_STATEMENT;
562        if node.has_data() && node.kind == WITH_STATEMENT {
563            self.if_statements.get(node.data_index as usize)
564        } else {
565            None
566        }
567    }
568
569    /// Get import declaration data (handles both `IMPORT_DECLARATION` and `IMPORT_EQUALS_DECLARATION`).
570    #[inline]
571    #[must_use]
572    pub fn get_import_decl(&self, node: &Node) -> Option<&ImportDeclData> {
573        use super::syntax_kind_ext::{IMPORT_DECLARATION, IMPORT_EQUALS_DECLARATION};
574        if node.has_data()
575            && (node.kind == IMPORT_DECLARATION || node.kind == IMPORT_EQUALS_DECLARATION)
576        {
577            self.import_decls.get(node.data_index as usize)
578        } else {
579            None
580        }
581    }
582
583    /// Get import clause data.
584    #[inline]
585    #[must_use]
586    pub fn get_import_clause(&self, node: &Node) -> Option<&ImportClauseData> {
587        use super::syntax_kind_ext::IMPORT_CLAUSE;
588        if node.has_data() && node.kind == IMPORT_CLAUSE {
589            self.import_clauses.get(node.data_index as usize)
590        } else {
591            None
592        }
593    }
594
595    /// Get named imports/exports data.
596    /// Works for `NAMED_IMPORTS`, `NAMESPACE_IMPORT`, and `NAMED_EXPORTS` (they share the same data structure).
597    #[inline]
598    #[must_use]
599    pub fn get_named_imports(&self, node: &Node) -> Option<&NamedImportsData> {
600        use super::syntax_kind_ext::{NAMED_EXPORTS, NAMED_IMPORTS, NAMESPACE_IMPORT};
601        if node.has_data()
602            && (node.kind == NAMED_IMPORTS
603                || node.kind == NAMED_EXPORTS
604                || node.kind == NAMESPACE_IMPORT)
605        {
606            self.named_imports.get(node.data_index as usize)
607        } else {
608            None
609        }
610    }
611
612    /// Get import/export specifier data.
613    #[inline]
614    #[must_use]
615    pub fn get_specifier(&self, node: &Node) -> Option<&SpecifierData> {
616        use super::syntax_kind_ext::{EXPORT_SPECIFIER, IMPORT_SPECIFIER};
617        if node.has_data() && (node.kind == IMPORT_SPECIFIER || node.kind == EXPORT_SPECIFIER) {
618            self.specifiers.get(node.data_index as usize)
619        } else {
620            None
621        }
622    }
623
624    /// Get export declaration data.
625    #[inline]
626    #[must_use]
627    pub fn get_export_decl(&self, node: &Node) -> Option<&ExportDeclData> {
628        use super::syntax_kind_ext::{EXPORT_DECLARATION, NAMESPACE_EXPORT_DECLARATION};
629        if node.has_data()
630            && (node.kind == EXPORT_DECLARATION || node.kind == NAMESPACE_EXPORT_DECLARATION)
631        {
632            self.export_decls.get(node.data_index as usize)
633        } else {
634            None
635        }
636    }
637
638    /// Get export assignment data (export = expr).
639    #[inline]
640    #[must_use]
641    pub fn get_export_assignment(&self, node: &Node) -> Option<&ExportAssignmentData> {
642        use super::syntax_kind_ext::EXPORT_ASSIGNMENT;
643        if node.has_data() && node.kind == EXPORT_ASSIGNMENT {
644            self.export_assignments.get(node.data_index as usize)
645        } else {
646            None
647        }
648    }
649
650    /// Get parameter data.
651    #[inline]
652    #[must_use]
653    pub fn get_parameter(&self, node: &Node) -> Option<&ParameterData> {
654        use super::syntax_kind_ext::PARAMETER;
655        if node.has_data() && node.kind == PARAMETER {
656            self.parameters.get(node.data_index as usize)
657        } else {
658            None
659        }
660    }
661
662    /// Get property declaration data.
663    #[inline]
664    #[must_use]
665    pub fn get_property_decl(&self, node: &Node) -> Option<&PropertyDeclData> {
666        use super::syntax_kind_ext::PROPERTY_DECLARATION;
667        if node.has_data() && node.kind == PROPERTY_DECLARATION {
668            self.property_decls.get(node.data_index as usize)
669        } else {
670            None
671        }
672    }
673
674    /// Get method declaration data.
675    #[inline]
676    #[must_use]
677    pub fn get_method_decl(&self, node: &Node) -> Option<&MethodDeclData> {
678        use super::syntax_kind_ext::METHOD_DECLARATION;
679        if node.has_data() && node.kind == METHOD_DECLARATION {
680            self.method_decls.get(node.data_index as usize)
681        } else {
682            None
683        }
684    }
685
686    /// Get constructor data.
687    #[inline]
688    #[must_use]
689    pub fn get_constructor(&self, node: &Node) -> Option<&ConstructorData> {
690        use super::syntax_kind_ext::CONSTRUCTOR;
691        if node.has_data() && node.kind == CONSTRUCTOR {
692            self.constructors.get(node.data_index as usize)
693        } else {
694            None
695        }
696    }
697
698    /// Get accessor data (get/set accessor).
699    #[inline]
700    #[must_use]
701    pub fn get_accessor(&self, node: &Node) -> Option<&AccessorData> {
702        use super::syntax_kind_ext::{GET_ACCESSOR, SET_ACCESSOR};
703        if node.has_data() && (node.kind == GET_ACCESSOR || node.kind == SET_ACCESSOR) {
704            self.accessors.get(node.data_index as usize)
705        } else {
706            None
707        }
708    }
709
710    /// Get decorator data.
711    #[inline]
712    #[must_use]
713    pub fn get_decorator(&self, node: &Node) -> Option<&DecoratorData> {
714        use super::syntax_kind_ext::DECORATOR;
715        if node.has_data() && node.kind == DECORATOR {
716            self.decorators.get(node.data_index as usize)
717        } else {
718            None
719        }
720    }
721
722    /// Get type reference data.
723    #[inline]
724    #[must_use]
725    pub fn get_type_ref(&self, node: &Node) -> Option<&TypeRefData> {
726        use super::syntax_kind_ext::TYPE_REFERENCE;
727        if node.has_data() && node.kind == TYPE_REFERENCE {
728            self.type_refs.get(node.data_index as usize)
729        } else {
730            None
731        }
732    }
733
734    /// Get expression statement data (returns the expression node index).
735    #[inline]
736    #[must_use]
737    pub fn get_expression_statement(&self, node: &Node) -> Option<&ExprStatementData> {
738        use super::syntax_kind_ext::EXPRESSION_STATEMENT;
739        if node.has_data() && node.kind == EXPRESSION_STATEMENT {
740            self.expr_statements.get(node.data_index as usize)
741        } else {
742            None
743        }
744    }
745
746    /// Get return statement data (returns the expression node index).
747    #[inline]
748    #[must_use]
749    pub fn get_return_statement(&self, node: &Node) -> Option<&ReturnData> {
750        use super::syntax_kind_ext::{RETURN_STATEMENT, THROW_STATEMENT};
751        if node.has_data() && (node.kind == RETURN_STATEMENT || node.kind == THROW_STATEMENT) {
752            self.return_data.get(node.data_index as usize)
753        } else {
754            None
755        }
756    }
757
758    /// Get JSX element data.
759    #[inline]
760    #[must_use]
761    pub fn get_jsx_element(&self, node: &Node) -> Option<&JsxElementData> {
762        use super::syntax_kind_ext::JSX_ELEMENT;
763        if node.has_data() && node.kind == JSX_ELEMENT {
764            self.jsx_elements.get(node.data_index as usize)
765        } else {
766            None
767        }
768    }
769
770    /// Get JSX opening/self-closing element data.
771    #[inline]
772    #[must_use]
773    pub fn get_jsx_opening(&self, node: &Node) -> Option<&JsxOpeningData> {
774        use super::syntax_kind_ext::{JSX_OPENING_ELEMENT, JSX_SELF_CLOSING_ELEMENT};
775        if node.has_data()
776            && (node.kind == JSX_OPENING_ELEMENT || node.kind == JSX_SELF_CLOSING_ELEMENT)
777        {
778            self.jsx_opening.get(node.data_index as usize)
779        } else {
780            None
781        }
782    }
783
784    /// Get JSX closing element data.
785    #[inline]
786    #[must_use]
787    pub fn get_jsx_closing(&self, node: &Node) -> Option<&JsxClosingData> {
788        use super::syntax_kind_ext::JSX_CLOSING_ELEMENT;
789        if node.has_data() && node.kind == JSX_CLOSING_ELEMENT {
790            self.jsx_closing.get(node.data_index as usize)
791        } else {
792            None
793        }
794    }
795
796    /// Get JSX fragment data.
797    #[inline]
798    #[must_use]
799    pub fn get_jsx_fragment(&self, node: &Node) -> Option<&JsxFragmentData> {
800        use super::syntax_kind_ext::JSX_FRAGMENT;
801        if node.has_data() && node.kind == JSX_FRAGMENT {
802            self.jsx_fragments.get(node.data_index as usize)
803        } else {
804            None
805        }
806    }
807
808    /// Get JSX attributes data.
809    #[inline]
810    #[must_use]
811    pub fn get_jsx_attributes(&self, node: &Node) -> Option<&JsxAttributesData> {
812        use super::syntax_kind_ext::JSX_ATTRIBUTES;
813        if node.has_data() && node.kind == JSX_ATTRIBUTES {
814            self.jsx_attributes.get(node.data_index as usize)
815        } else {
816            None
817        }
818    }
819
820    /// Get JSX attribute data.
821    #[inline]
822    #[must_use]
823    pub fn get_jsx_attribute(&self, node: &Node) -> Option<&JsxAttributeData> {
824        use super::syntax_kind_ext::JSX_ATTRIBUTE;
825        if node.has_data() && node.kind == JSX_ATTRIBUTE {
826            self.jsx_attribute.get(node.data_index as usize)
827        } else {
828            None
829        }
830    }
831
832    /// Get JSX spread attribute data.
833    #[inline]
834    #[must_use]
835    pub fn get_jsx_spread_attribute(&self, node: &Node) -> Option<&JsxSpreadAttributeData> {
836        use super::syntax_kind_ext::JSX_SPREAD_ATTRIBUTE;
837        if node.has_data() && node.kind == JSX_SPREAD_ATTRIBUTE {
838            self.jsx_spread_attributes.get(node.data_index as usize)
839        } else {
840            None
841        }
842    }
843
844    /// Get JSX expression data.
845    #[inline]
846    #[must_use]
847    pub fn get_jsx_expression(&self, node: &Node) -> Option<&JsxExpressionData> {
848        use super::syntax_kind_ext::JSX_EXPRESSION;
849        if node.has_data() && node.kind == JSX_EXPRESSION {
850            self.jsx_expressions.get(node.data_index as usize)
851        } else {
852            None
853        }
854    }
855
856    /// Get JSX text data.
857    #[inline]
858    #[must_use]
859    pub fn get_jsx_text(&self, node: &Node) -> Option<&JsxTextData> {
860        use tsz_scanner::SyntaxKind;
861        if node.has_data() && node.kind == SyntaxKind::JsxText as u16 {
862            self.jsx_text.get(node.data_index as usize)
863        } else {
864            None
865        }
866    }
867
868    /// Get JSX namespaced name data.
869    #[inline]
870    #[must_use]
871    pub fn get_jsx_namespaced_name(&self, node: &Node) -> Option<&JsxNamespacedNameData> {
872        use super::syntax_kind_ext::JSX_NAMESPACED_NAME;
873        if node.has_data() && node.kind == JSX_NAMESPACED_NAME {
874            self.jsx_namespaced_names.get(node.data_index as usize)
875        } else {
876            None
877        }
878    }
879
880    /// Get signature data (call, construct, method, property signatures).
881    #[inline]
882    #[must_use]
883    pub fn get_signature(&self, node: &Node) -> Option<&SignatureData> {
884        use super::syntax_kind_ext::{
885            CALL_SIGNATURE, CONSTRUCT_SIGNATURE, METHOD_SIGNATURE, PROPERTY_SIGNATURE,
886        };
887        if node.has_data()
888            && (node.kind == CALL_SIGNATURE
889                || node.kind == CONSTRUCT_SIGNATURE
890                || node.kind == METHOD_SIGNATURE
891                || node.kind == PROPERTY_SIGNATURE)
892        {
893            self.signatures.get(node.data_index as usize)
894        } else {
895            None
896        }
897    }
898
899    /// Get index signature data.
900    #[inline]
901    #[must_use]
902    pub fn get_index_signature(&self, node: &Node) -> Option<&IndexSignatureData> {
903        use super::syntax_kind_ext::INDEX_SIGNATURE;
904        if node.has_data() && node.kind == INDEX_SIGNATURE {
905            self.index_signatures.get(node.data_index as usize)
906        } else {
907            None
908        }
909    }
910
911    /// Get heritage clause data.
912    #[inline]
913    #[must_use]
914    pub fn get_heritage_clause(&self, node: &Node) -> Option<&HeritageData> {
915        use super::syntax_kind_ext::HERITAGE_CLAUSE;
916        if node.has_data() && node.kind == HERITAGE_CLAUSE {
917            self.heritage_clauses.get(node.data_index as usize)
918        } else {
919            None
920        }
921    }
922
923    /// Get composite type data (union or intersection).
924    #[inline]
925    #[must_use]
926    pub fn get_composite_type(&self, node: &Node) -> Option<&CompositeTypeData> {
927        use super::syntax_kind_ext::{INTERSECTION_TYPE, UNION_TYPE};
928        if node.has_data() && (node.kind == UNION_TYPE || node.kind == INTERSECTION_TYPE) {
929            self.composite_types.get(node.data_index as usize)
930        } else {
931            None
932        }
933    }
934
935    /// Get array type data.
936    #[inline]
937    #[must_use]
938    pub fn get_array_type(&self, node: &Node) -> Option<&ArrayTypeData> {
939        use super::syntax_kind_ext::ARRAY_TYPE;
940        if node.has_data() && node.kind == ARRAY_TYPE {
941            self.array_types.get(node.data_index as usize)
942        } else {
943            None
944        }
945    }
946
947    /// Get tuple type data.
948    #[inline]
949    #[must_use]
950    pub fn get_tuple_type(&self, node: &Node) -> Option<&TupleTypeData> {
951        use super::syntax_kind_ext::TUPLE_TYPE;
952        if node.has_data() && node.kind == TUPLE_TYPE {
953            self.tuple_types.get(node.data_index as usize)
954        } else {
955            None
956        }
957    }
958
959    /// Get function type data.
960    #[inline]
961    #[must_use]
962    pub fn get_function_type(&self, node: &Node) -> Option<&FunctionTypeData> {
963        use super::syntax_kind_ext::{CONSTRUCTOR_TYPE, FUNCTION_TYPE};
964        if node.has_data() && (node.kind == FUNCTION_TYPE || node.kind == CONSTRUCTOR_TYPE) {
965            self.function_types.get(node.data_index as usize)
966        } else {
967            None
968        }
969    }
970
971    /// Get type literal data.
972    #[inline]
973    #[must_use]
974    pub fn get_type_literal(&self, node: &Node) -> Option<&TypeLiteralData> {
975        use super::syntax_kind_ext::TYPE_LITERAL;
976        if node.has_data() && node.kind == TYPE_LITERAL {
977            self.type_literals.get(node.data_index as usize)
978        } else {
979            None
980        }
981    }
982
983    /// Get conditional type data.
984    #[inline]
985    #[must_use]
986    pub fn get_conditional_type(&self, node: &Node) -> Option<&ConditionalTypeData> {
987        use super::syntax_kind_ext::CONDITIONAL_TYPE;
988        if node.has_data() && node.kind == CONDITIONAL_TYPE {
989            self.conditional_types.get(node.data_index as usize)
990        } else {
991            None
992        }
993    }
994
995    /// Get mapped type data.
996    #[inline]
997    #[must_use]
998    pub fn get_mapped_type(&self, node: &Node) -> Option<&MappedTypeData> {
999        use super::syntax_kind_ext::MAPPED_TYPE;
1000        if node.has_data() && node.kind == MAPPED_TYPE {
1001            self.mapped_types.get(node.data_index as usize)
1002        } else {
1003            None
1004        }
1005    }
1006
1007    /// Get indexed access type data.
1008    #[inline]
1009    #[must_use]
1010    pub fn get_indexed_access_type(&self, node: &Node) -> Option<&IndexedAccessTypeData> {
1011        use super::syntax_kind_ext::INDEXED_ACCESS_TYPE;
1012        if node.has_data() && node.kind == INDEXED_ACCESS_TYPE {
1013            self.indexed_access_types.get(node.data_index as usize)
1014        } else {
1015            None
1016        }
1017    }
1018
1019    /// Get literal type data.
1020    #[inline]
1021    #[must_use]
1022    pub fn get_literal_type(&self, node: &Node) -> Option<&LiteralTypeData> {
1023        use super::syntax_kind_ext::LITERAL_TYPE;
1024        if node.has_data() && node.kind == LITERAL_TYPE {
1025            self.literal_types.get(node.data_index as usize)
1026        } else {
1027            None
1028        }
1029    }
1030
1031    /// Get wrapped type data (parenthesized, optional, rest types).
1032    #[inline]
1033    #[must_use]
1034    pub fn get_wrapped_type(&self, node: &Node) -> Option<&WrappedTypeData> {
1035        use super::syntax_kind_ext::{OPTIONAL_TYPE, PARENTHESIZED_TYPE, REST_TYPE};
1036        if node.has_data()
1037            && (node.kind == PARENTHESIZED_TYPE
1038                || node.kind == OPTIONAL_TYPE
1039                || node.kind == REST_TYPE)
1040        {
1041            self.wrapped_types.get(node.data_index as usize)
1042        } else {
1043            None
1044        }
1045    }
1046
1047    /// Get heritage clause data.
1048    #[inline]
1049    #[must_use]
1050    pub fn get_heritage(&self, node: &Node) -> Option<&HeritageData> {
1051        use super::syntax_kind_ext::HERITAGE_CLAUSE;
1052        if node.has_data() && node.kind == HERITAGE_CLAUSE {
1053            self.heritage_clauses.get(node.data_index as usize)
1054        } else {
1055            None
1056        }
1057    }
1058
1059    /// Get expression with type arguments data (e.g., `extends Base<T>`).
1060    #[inline]
1061    #[must_use]
1062    pub fn get_expr_type_args(&self, node: &Node) -> Option<&ExprWithTypeArgsData> {
1063        use super::syntax_kind_ext::EXPRESSION_WITH_TYPE_ARGUMENTS;
1064        if node.has_data() && node.kind == EXPRESSION_WITH_TYPE_ARGUMENTS {
1065            self.expr_with_type_args.get(node.data_index as usize)
1066        } else {
1067            None
1068        }
1069    }
1070
1071    /// Get type query data (typeof in type position).
1072    #[inline]
1073    #[must_use]
1074    pub fn get_type_query(&self, node: &Node) -> Option<&TypeQueryData> {
1075        use super::syntax_kind_ext::TYPE_QUERY;
1076        if node.has_data() && node.kind == TYPE_QUERY {
1077            self.type_queries.get(node.data_index as usize)
1078        } else {
1079            None
1080        }
1081    }
1082
1083    /// Get type operator data (keyof, unique, readonly).
1084    #[inline]
1085    #[must_use]
1086    pub fn get_type_operator(&self, node: &Node) -> Option<&TypeOperatorData> {
1087        use super::syntax_kind_ext::TYPE_OPERATOR;
1088        if node.has_data() && node.kind == TYPE_OPERATOR {
1089            self.type_operators.get(node.data_index as usize)
1090        } else {
1091            None
1092        }
1093    }
1094
1095    /// Get infer type data.
1096    #[inline]
1097    #[must_use]
1098    pub fn get_infer_type(&self, node: &Node) -> Option<&InferTypeData> {
1099        use super::syntax_kind_ext::INFER_TYPE;
1100        if node.has_data() && node.kind == INFER_TYPE {
1101            self.infer_types.get(node.data_index as usize)
1102        } else {
1103            None
1104        }
1105    }
1106
1107    /// Get template literal type data.
1108    #[inline]
1109    #[must_use]
1110    pub fn get_template_literal_type(&self, node: &Node) -> Option<&TemplateLiteralTypeData> {
1111        use super::syntax_kind_ext::TEMPLATE_LITERAL_TYPE;
1112        if node.has_data() && node.kind == TEMPLATE_LITERAL_TYPE {
1113            self.template_literal_types.get(node.data_index as usize)
1114        } else {
1115            None
1116        }
1117    }
1118
1119    /// Get named tuple member data.
1120    #[inline]
1121    #[must_use]
1122    pub fn get_named_tuple_member(&self, node: &Node) -> Option<&NamedTupleMemberData> {
1123        use super::syntax_kind_ext::NAMED_TUPLE_MEMBER;
1124        if node.has_data() && node.kind == NAMED_TUPLE_MEMBER {
1125            self.named_tuple_members.get(node.data_index as usize)
1126        } else {
1127            None
1128        }
1129    }
1130
1131    /// Get type predicate data.
1132    #[inline]
1133    #[must_use]
1134    pub fn get_type_predicate(&self, node: &Node) -> Option<&TypePredicateData> {
1135        use super::syntax_kind_ext::TYPE_PREDICATE;
1136        if node.has_data() && node.kind == TYPE_PREDICATE {
1137            self.type_predicates.get(node.data_index as usize)
1138        } else {
1139            None
1140        }
1141    }
1142
1143    /// Get type parameter data.
1144    #[inline]
1145    #[must_use]
1146    pub fn get_type_parameter(&self, node: &Node) -> Option<&TypeParameterData> {
1147        use super::syntax_kind_ext::TYPE_PARAMETER;
1148        if node.has_data() && node.kind == TYPE_PARAMETER {
1149            self.type_parameters.get(node.data_index as usize)
1150        } else {
1151            None
1152        }
1153    }
1154
1155    /// Get parenthesized expression data.
1156    /// Returns None if node is not a parenthesized expression or has no data.
1157    #[inline]
1158    #[must_use]
1159    pub fn get_parenthesized(&self, node: &Node) -> Option<&ParenthesizedData> {
1160        use super::syntax_kind_ext::PARENTHESIZED_EXPRESSION;
1161        if node.has_data() && node.kind == PARENTHESIZED_EXPRESSION {
1162            self.parenthesized.get(node.data_index as usize)
1163        } else {
1164            None
1165        }
1166    }
1167
1168    /// Get template expression data.
1169    #[inline]
1170    #[must_use]
1171    pub fn get_template_expr(&self, node: &Node) -> Option<&TemplateExprData> {
1172        use super::syntax_kind_ext::TEMPLATE_EXPRESSION;
1173        if node.has_data() && node.kind == TEMPLATE_EXPRESSION {
1174            self.template_exprs.get(node.data_index as usize)
1175        } else {
1176            None
1177        }
1178    }
1179
1180    /// Get template span data. Accepts both `TEMPLATE_SPAN` (expression-level)
1181    /// and `TEMPLATE_LITERAL_TYPE_SPAN` (type-level) since both store data in
1182    /// the same `template_spans` array.
1183    #[inline]
1184    #[must_use]
1185    pub fn get_template_span(&self, node: &Node) -> Option<&TemplateSpanData> {
1186        use super::syntax_kind_ext::{TEMPLATE_LITERAL_TYPE_SPAN, TEMPLATE_SPAN};
1187        if node.has_data()
1188            && (node.kind == TEMPLATE_SPAN || node.kind == TEMPLATE_LITERAL_TYPE_SPAN)
1189        {
1190            self.template_spans.get(node.data_index as usize)
1191        } else {
1192            None
1193        }
1194    }
1195
1196    /// Get tagged template expression data.
1197    #[inline]
1198    #[must_use]
1199    pub fn get_tagged_template(&self, node: &Node) -> Option<&TaggedTemplateData> {
1200        use super::syntax_kind_ext::TAGGED_TEMPLATE_EXPRESSION;
1201        if node.has_data() && node.kind == TAGGED_TEMPLATE_EXPRESSION {
1202            self.tagged_templates.get(node.data_index as usize)
1203        } else {
1204            None
1205        }
1206    }
1207
1208    /// Get spread element/assignment data.
1209    #[inline]
1210    #[must_use]
1211    pub fn get_spread(&self, node: &Node) -> Option<&SpreadData> {
1212        use super::syntax_kind_ext::{SPREAD_ASSIGNMENT, SPREAD_ELEMENT};
1213        if node.has_data() && (node.kind == SPREAD_ELEMENT || node.kind == SPREAD_ASSIGNMENT) {
1214            self.spread_data.get(node.data_index as usize)
1215        } else {
1216            None
1217        }
1218    }
1219
1220    /// Get shorthand property assignment data.
1221    #[inline]
1222    #[must_use]
1223    pub fn get_shorthand_property(&self, node: &Node) -> Option<&ShorthandPropertyData> {
1224        use super::syntax_kind_ext::SHORTHAND_PROPERTY_ASSIGNMENT;
1225        if node.has_data() && node.kind == SHORTHAND_PROPERTY_ASSIGNMENT {
1226            self.shorthand_properties.get(node.data_index as usize)
1227        } else {
1228            None
1229        }
1230    }
1231
1232    /// Get binding pattern data (`ObjectBindingPattern` or `ArrayBindingPattern`).
1233    #[inline]
1234    #[must_use]
1235    pub fn get_binding_pattern(&self, node: &Node) -> Option<&BindingPatternData> {
1236        use super::syntax_kind_ext::{ARRAY_BINDING_PATTERN, OBJECT_BINDING_PATTERN};
1237        if node.has_data()
1238            && (node.kind == OBJECT_BINDING_PATTERN || node.kind == ARRAY_BINDING_PATTERN)
1239        {
1240            self.binding_patterns.get(node.data_index as usize)
1241        } else {
1242            None
1243        }
1244    }
1245
1246    /// Get binding element data.
1247    #[inline]
1248    #[must_use]
1249    pub fn get_binding_element(&self, node: &Node) -> Option<&BindingElementData> {
1250        use super::syntax_kind_ext::BINDING_ELEMENT;
1251        if node.has_data() && node.kind == BINDING_ELEMENT {
1252            self.binding_elements.get(node.data_index as usize)
1253        } else {
1254            None
1255        }
1256    }
1257
1258    /// Get computed property name data
1259    #[inline]
1260    #[must_use]
1261    pub fn get_computed_property(&self, node: &Node) -> Option<&ComputedPropertyData> {
1262        use super::syntax_kind_ext::COMPUTED_PROPERTY_NAME;
1263        if node.has_data() && node.kind == COMPUTED_PROPERTY_NAME {
1264            self.computed_properties.get(node.data_index as usize)
1265        } else {
1266            None
1267        }
1268    }
1269
1270    /// Number of nodes in the arena
1271    #[must_use]
1272    pub const fn len(&self) -> usize {
1273        self.nodes.len()
1274    }
1275
1276    /// Check if arena is empty
1277    #[must_use]
1278    pub const fn is_empty(&self) -> bool {
1279        self.nodes.is_empty()
1280    }
1281}
1282
1283// =============================================================================
1284// Index-based convenience accessors: get(index) + get_TYPE(node) in one call
1285// =============================================================================
1286
1287/// Generate `get_*_at(index: NodeIndex) -> Option<&T>` convenience methods
1288/// that combine `arena.get(index)` with a typed getter in a single call.
1289macro_rules! define_at_accessors {
1290    ($($at_name:ident => $getter:ident -> $ret:ty);* $(;)?) => {
1291        impl NodeArena {
1292            $(
1293                #[inline]
1294#[must_use]
1295                pub fn $at_name(&self, index: NodeIndex) -> Option<&$ret> {
1296                    self.$getter(self.get(index)?)
1297                }
1298            )*
1299        }
1300    };
1301}
1302
1303define_at_accessors! {
1304    get_identifier_at => get_identifier -> IdentifierData;
1305    get_literal_at => get_literal -> LiteralData;
1306    get_binary_expr_at => get_binary_expr -> BinaryExprData;
1307    get_call_expr_at => get_call_expr -> CallExprData;
1308    get_access_expr_at => get_access_expr -> AccessExprData;
1309    get_conditional_expr_at => get_conditional_expr -> ConditionalExprData;
1310    get_qualified_name_at => get_qualified_name -> QualifiedNameData;
1311    get_literal_expr_at => get_literal_expr -> LiteralExprData;
1312    get_property_assignment_at => get_property_assignment -> PropertyAssignmentData;
1313    get_type_assertion_at => get_type_assertion -> TypeAssertionData;
1314    get_unary_expr_at => get_unary_expr -> UnaryExprData;
1315    get_unary_expr_ex_at => get_unary_expr_ex -> UnaryExprDataEx;
1316    get_function_at => get_function -> FunctionData;
1317    get_class_at => get_class -> ClassData;
1318    get_block_at => get_block -> BlockData;
1319    get_source_file_at => get_source_file -> SourceFileData;
1320    get_variable_at => get_variable -> VariableData;
1321    get_variable_declaration_at => get_variable_declaration -> VariableDeclarationData;
1322    get_interface_at => get_interface -> InterfaceData;
1323    get_type_alias_at => get_type_alias -> TypeAliasData;
1324    get_enum_at => get_enum -> EnumData;
1325    get_enum_member_at => get_enum_member -> EnumMemberData;
1326    get_module_at => get_module -> ModuleData;
1327    get_module_block_at => get_module_block -> ModuleBlockData;
1328    get_if_statement_at => get_if_statement -> IfStatementData;
1329    get_loop_at => get_loop -> LoopData;
1330    get_for_in_of_at => get_for_in_of -> ForInOfData;
1331    get_switch_at => get_switch -> SwitchData;
1332    get_case_clause_at => get_case_clause -> CaseClauseData;
1333    get_try_at => get_try -> TryData;
1334    get_catch_clause_at => get_catch_clause -> CatchClauseData;
1335    get_labeled_statement_at => get_labeled_statement -> LabeledData;
1336    get_jump_data_at => get_jump_data -> JumpData;
1337    get_with_statement_at => get_with_statement -> IfStatementData;
1338    get_import_decl_at => get_import_decl -> ImportDeclData;
1339    get_import_clause_at => get_import_clause -> ImportClauseData;
1340    get_named_imports_at => get_named_imports -> NamedImportsData;
1341    get_specifier_at => get_specifier -> SpecifierData;
1342    get_export_decl_at => get_export_decl -> ExportDeclData;
1343    get_export_assignment_at => get_export_assignment -> ExportAssignmentData;
1344    get_parameter_at => get_parameter -> ParameterData;
1345    get_property_decl_at => get_property_decl -> PropertyDeclData;
1346    get_method_decl_at => get_method_decl -> MethodDeclData;
1347    get_constructor_at => get_constructor -> ConstructorData;
1348    get_accessor_at => get_accessor -> AccessorData;
1349    get_decorator_at => get_decorator -> DecoratorData;
1350    get_type_ref_at => get_type_ref -> TypeRefData;
1351    get_expression_statement_at => get_expression_statement -> ExprStatementData;
1352    get_return_statement_at => get_return_statement -> ReturnData;
1353    get_jsx_element_at => get_jsx_element -> JsxElementData;
1354    get_jsx_opening_at => get_jsx_opening -> JsxOpeningData;
1355    get_jsx_closing_at => get_jsx_closing -> JsxClosingData;
1356    get_jsx_fragment_at => get_jsx_fragment -> JsxFragmentData;
1357    get_jsx_attributes_at => get_jsx_attributes -> JsxAttributesData;
1358    get_jsx_attribute_at => get_jsx_attribute -> JsxAttributeData;
1359    get_jsx_spread_attribute_at => get_jsx_spread_attribute -> JsxSpreadAttributeData;
1360    get_jsx_expression_at => get_jsx_expression -> JsxExpressionData;
1361    get_jsx_text_at => get_jsx_text -> JsxTextData;
1362    get_jsx_namespaced_name_at => get_jsx_namespaced_name -> JsxNamespacedNameData;
1363    get_signature_at => get_signature -> SignatureData;
1364    get_index_signature_at => get_index_signature -> IndexSignatureData;
1365    get_heritage_clause_at => get_heritage_clause -> HeritageData;
1366    get_composite_type_at => get_composite_type -> CompositeTypeData;
1367    get_array_type_at => get_array_type -> ArrayTypeData;
1368    get_tuple_type_at => get_tuple_type -> TupleTypeData;
1369    get_function_type_at => get_function_type -> FunctionTypeData;
1370    get_type_literal_at => get_type_literal -> TypeLiteralData;
1371    get_conditional_type_at => get_conditional_type -> ConditionalTypeData;
1372    get_mapped_type_at => get_mapped_type -> MappedTypeData;
1373    get_indexed_access_type_at => get_indexed_access_type -> IndexedAccessTypeData;
1374    get_literal_type_at => get_literal_type -> LiteralTypeData;
1375    get_wrapped_type_at => get_wrapped_type -> WrappedTypeData;
1376    get_expr_type_args_at => get_expr_type_args -> ExprWithTypeArgsData;
1377    get_type_query_at => get_type_query -> TypeQueryData;
1378    get_type_operator_at => get_type_operator -> TypeOperatorData;
1379    get_infer_type_at => get_infer_type -> InferTypeData;
1380    get_template_literal_type_at => get_template_literal_type -> TemplateLiteralTypeData;
1381    get_named_tuple_member_at => get_named_tuple_member -> NamedTupleMemberData;
1382    get_type_predicate_at => get_type_predicate -> TypePredicateData;
1383    get_type_parameter_at => get_type_parameter -> TypeParameterData;
1384    get_parenthesized_at => get_parenthesized -> ParenthesizedData;
1385    get_template_expr_at => get_template_expr -> TemplateExprData;
1386    get_template_span_at => get_template_span -> TemplateSpanData;
1387    get_tagged_template_at => get_tagged_template -> TaggedTemplateData;
1388    get_spread_at => get_spread -> SpreadData;
1389    get_shorthand_property_at => get_shorthand_property -> ShorthandPropertyData;
1390    get_binding_pattern_at => get_binding_pattern -> BindingPatternData;
1391    get_binding_element_at => get_binding_element -> BindingElementData;
1392    get_computed_property_at => get_computed_property -> ComputedPropertyData
1393}
1394
1395// =============================================================================
1396// Node View - Ergonomic wrapper for reading Nodes
1397// =============================================================================
1398
1399/// A view into a node that provides convenient access to both the Node
1400/// header and its type-specific data. This avoids the need to pass the arena
1401/// around when working with node data.
1402#[derive(Clone, Copy)]
1403pub struct NodeView<'a> {
1404    pub node: &'a Node,
1405    pub arena: &'a NodeArena,
1406    pub index: NodeIndex,
1407}
1408
1409impl<'a> NodeView<'a> {
1410    /// Create a new `NodeView`.
1411    #[inline]
1412    #[must_use]
1413    pub fn new(arena: &'a NodeArena, index: NodeIndex) -> Option<Self> {
1414        arena.get(index).map(|node| NodeView { node, arena, index })
1415    }
1416
1417    /// Get the `SyntaxKind`.
1418    #[inline]
1419    #[must_use]
1420    pub const fn kind(&self) -> u16 {
1421        self.node.kind
1422    }
1423
1424    /// Get the start position.
1425    #[inline]
1426    #[must_use]
1427    pub const fn pos(&self) -> u32 {
1428        self.node.pos
1429    }
1430
1431    /// Get the end position.
1432    #[inline]
1433    #[must_use]
1434    pub const fn end(&self) -> u32 {
1435        self.node.end
1436    }
1437
1438    /// Get the flags.
1439    #[inline]
1440    #[must_use]
1441    pub const fn flags(&self) -> u16 {
1442        self.node.flags
1443    }
1444
1445    /// Check if this node has associated data.
1446    #[inline]
1447    #[must_use]
1448    pub const fn has_data(&self) -> bool {
1449        self.node.has_data()
1450    }
1451
1452    /// Get extended node info (`parent`, `id`, modifier/transform flags).
1453    #[inline]
1454    #[must_use]
1455    pub fn extended(&self) -> Option<&'a ExtendedNodeInfo> {
1456        self.arena.get_extended(self.index)
1457    }
1458
1459    /// Get parent node index.
1460    #[inline]
1461    #[must_use]
1462    pub fn parent(&self) -> NodeIndex {
1463        self.extended().map_or(NodeIndex::NONE, |e| e.parent)
1464    }
1465
1466    /// Get node id.
1467    #[inline]
1468    #[must_use]
1469    pub fn id(&self) -> u32 {
1470        self.extended().map_or(0, |e| e.id)
1471    }
1472
1473    /// Get a child node as a `NodeView`.
1474    #[inline]
1475    #[must_use]
1476    pub fn child(&self, index: NodeIndex) -> Option<Self> {
1477        NodeView::new(self.arena, index)
1478    }
1479
1480    // Typed data accessors - return Option<&T> based on node kind
1481
1482    /// Get identifier data (for `Identifier`, `PrivateIdentifier` nodes).
1483    #[inline]
1484    #[must_use]
1485    pub fn as_identifier(&self) -> Option<&'a IdentifierData> {
1486        self.arena.get_identifier(self.node)
1487    }
1488
1489    /// Get literal data (for `StringLiteral`, `NumericLiteral`, etc.).
1490    #[inline]
1491    #[must_use]
1492    pub fn as_literal(&self) -> Option<&'a LiteralData> {
1493        self.arena.get_literal(self.node)
1494    }
1495
1496    /// Get binary expression data
1497    #[inline]
1498    #[must_use]
1499    pub fn as_binary_expr(&self) -> Option<&'a BinaryExprData> {
1500        self.arena.get_binary_expr(self.node)
1501    }
1502
1503    /// Get call expression data
1504    #[inline]
1505    #[must_use]
1506    pub fn as_call_expr(&self) -> Option<&'a CallExprData> {
1507        self.arena.get_call_expr(self.node)
1508    }
1509
1510    /// Get function data
1511    #[inline]
1512    #[must_use]
1513    pub fn as_function(&self) -> Option<&'a FunctionData> {
1514        self.arena.get_function(self.node)
1515    }
1516
1517    /// Get class data
1518    #[inline]
1519    #[must_use]
1520    pub fn as_class(&self) -> Option<&'a ClassData> {
1521        self.arena.get_class(self.node)
1522    }
1523
1524    /// Get block data
1525    #[inline]
1526    #[must_use]
1527    pub fn as_block(&self) -> Option<&'a BlockData> {
1528        self.arena.get_block(self.node)
1529    }
1530
1531    /// Get source file data
1532    #[inline]
1533    #[must_use]
1534    pub fn as_source_file(&self) -> Option<&'a SourceFileData> {
1535        self.arena.get_source_file(self.node)
1536    }
1537}
1538
1539// =============================================================================
1540// Node Kind Utilities
1541// =============================================================================
1542
1543impl Node {
1544    /// Check if this is an identifier node
1545    #[inline]
1546    #[must_use]
1547    pub const fn is_identifier(&self) -> bool {
1548        use tsz_scanner::SyntaxKind;
1549        self.kind == SyntaxKind::Identifier as u16
1550    }
1551
1552    /// Check if this is a string literal
1553    #[inline]
1554    #[must_use]
1555    pub const fn is_string_literal(&self) -> bool {
1556        use tsz_scanner::SyntaxKind;
1557        self.kind == SyntaxKind::StringLiteral as u16
1558    }
1559
1560    /// Check if this is a numeric literal
1561    #[inline]
1562    #[must_use]
1563    pub const fn is_numeric_literal(&self) -> bool {
1564        use tsz_scanner::SyntaxKind;
1565        self.kind == SyntaxKind::NumericLiteral as u16
1566    }
1567
1568    /// Check if this is a function declaration
1569    #[inline]
1570    #[must_use]
1571    pub const fn is_function_declaration(&self) -> bool {
1572        use super::syntax_kind_ext::FUNCTION_DECLARATION;
1573        self.kind == FUNCTION_DECLARATION
1574    }
1575
1576    /// Check if this is a class declaration
1577    #[inline]
1578    #[must_use]
1579    pub const fn is_class_declaration(&self) -> bool {
1580        use super::syntax_kind_ext::CLASS_DECLARATION;
1581        self.kind == CLASS_DECLARATION
1582    }
1583
1584    /// Check if this is any kind of function-like node
1585    #[inline]
1586    #[must_use]
1587    pub const fn is_function_like(&self) -> bool {
1588        matches!(
1589            self.kind,
1590            FUNCTION_DECLARATION
1591                | FUNCTION_EXPRESSION
1592                | ARROW_FUNCTION
1593                | METHOD_DECLARATION
1594                | CONSTRUCTOR
1595                | GET_ACCESSOR
1596                | SET_ACCESSOR
1597        )
1598    }
1599
1600    /// Check if this is a statement
1601    #[inline]
1602    #[must_use]
1603    pub fn is_statement(&self) -> bool {
1604        (BLOCK..=DEBUGGER_STATEMENT).contains(&self.kind) || self.kind == VARIABLE_STATEMENT
1605    }
1606
1607    /// Check if this is a declaration
1608    #[inline]
1609    #[must_use]
1610    pub fn is_declaration(&self) -> bool {
1611        (VARIABLE_DECLARATION..=EXPORT_SPECIFIER).contains(&self.kind)
1612    }
1613
1614    /// Check if this is a type node
1615    #[inline]
1616    #[must_use]
1617    pub fn is_type_node(&self) -> bool {
1618        (TYPE_PREDICATE..=IMPORT_TYPE).contains(&self.kind)
1619    }
1620}
1621
1622impl NodeArena {
1623    #[inline]
1624    fn add_opt_child(children: &mut Vec<NodeIndex>, idx: NodeIndex) {
1625        if idx.is_some() {
1626            children.push(idx);
1627        }
1628    }
1629
1630    #[inline]
1631    fn add_list(children: &mut Vec<NodeIndex>, list: &NodeList) {
1632        children.extend(list.nodes.iter().copied());
1633    }
1634
1635    #[inline]
1636    fn add_opt_list(children: &mut Vec<NodeIndex>, list: Option<&NodeList>) {
1637        if let Some(l) = list {
1638            children.extend(l.nodes.iter().copied());
1639        }
1640    }
1641
1642    fn collect_name_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
1643        match node.kind {
1644            QUALIFIED_NAME => {
1645                if let Some(data) = self.get_qualified_name(node) {
1646                    children.push(data.left);
1647                    children.push(data.right);
1648                    return true;
1649                }
1650            }
1651            COMPUTED_PROPERTY_NAME => {
1652                if let Some(data) = self.get_computed_property(node) {
1653                    children.push(data.expression);
1654                    return true;
1655                }
1656            }
1657            _ => {}
1658        }
1659        false
1660    }
1661
1662    fn collect_expression_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
1663        match node.kind {
1664            BINARY_EXPRESSION => {
1665                if let Some(data) = self.get_binary_expr(node) {
1666                    children.push(data.left);
1667                    children.push(data.right);
1668                    return true;
1669                }
1670            }
1671            PREFIX_UNARY_EXPRESSION | POSTFIX_UNARY_EXPRESSION => {
1672                if let Some(data) = self.get_unary_expr(node) {
1673                    children.push(data.operand);
1674                    return true;
1675                }
1676            }
1677            CALL_EXPRESSION | NEW_EXPRESSION => {
1678                if let Some(data) = self.get_call_expr(node) {
1679                    children.push(data.expression);
1680                    Self::add_opt_list(children, data.type_arguments.as_ref());
1681                    Self::add_opt_list(children, data.arguments.as_ref());
1682                    return true;
1683                }
1684            }
1685            TAGGED_TEMPLATE_EXPRESSION => {
1686                if let Some(data) = self.get_tagged_template(node) {
1687                    children.push(data.tag);
1688                    Self::add_opt_list(children, data.type_arguments.as_ref());
1689                    children.push(data.template);
1690                    return true;
1691                }
1692            }
1693            TEMPLATE_EXPRESSION => {
1694                if let Some(data) = self.get_template_expr(node) {
1695                    children.push(data.head);
1696                    Self::add_list(children, &data.template_spans);
1697                    return true;
1698                }
1699            }
1700            TEMPLATE_SPAN => {
1701                if let Some(data) = self.get_template_span(node) {
1702                    children.push(data.expression);
1703                    children.push(data.literal);
1704                    return true;
1705                }
1706            }
1707            PROPERTY_ACCESS_EXPRESSION | ELEMENT_ACCESS_EXPRESSION => {
1708                if let Some(data) = self.get_access_expr(node) {
1709                    children.push(data.expression);
1710                    children.push(data.name_or_argument);
1711                    return true;
1712                }
1713            }
1714            CONDITIONAL_EXPRESSION => {
1715                if let Some(data) = self.get_conditional_expr(node) {
1716                    children.push(data.condition);
1717                    children.push(data.when_true);
1718                    children.push(data.when_false);
1719                    return true;
1720                }
1721            }
1722            ARROW_FUNCTION | FUNCTION_EXPRESSION => {
1723                if let Some(data) = self.get_function(node) {
1724                    Self::add_opt_list(children, data.modifiers.as_ref());
1725                    Self::add_opt_list(children, data.type_parameters.as_ref());
1726                    Self::add_list(children, &data.parameters);
1727                    Self::add_opt_child(children, data.type_annotation);
1728                    children.push(data.body);
1729                    return true;
1730                }
1731            }
1732            ARRAY_LITERAL_EXPRESSION | OBJECT_LITERAL_EXPRESSION => {
1733                if let Some(data) = self.get_literal_expr(node) {
1734                    Self::add_list(children, &data.elements);
1735                    return true;
1736                }
1737            }
1738            PARENTHESIZED_EXPRESSION => {
1739                if let Some(data) = self.get_parenthesized(node) {
1740                    children.push(data.expression);
1741                    return true;
1742                }
1743            }
1744            YIELD_EXPRESSION | AWAIT_EXPRESSION | NON_NULL_EXPRESSION => {
1745                if let Some(data) = self.get_unary_expr_ex(node) {
1746                    children.push(data.expression);
1747                    return true;
1748                }
1749            }
1750            SPREAD_ASSIGNMENT | SPREAD_ELEMENT => {
1751                if let Some(data) = self.get_spread(node) {
1752                    children.push(data.expression);
1753                    return true;
1754                }
1755            }
1756            AS_EXPRESSION | SATISFIES_EXPRESSION => {
1757                if let Some(data) = self.get_type_assertion(node) {
1758                    children.push(data.expression);
1759                    children.push(data.type_node);
1760                    return true;
1761                }
1762            }
1763            TYPE_ASSERTION => {
1764                if let Some(data) = self.get_type_assertion(node) {
1765                    children.push(data.type_node);
1766                    children.push(data.expression);
1767                    return true;
1768                }
1769            }
1770            _ => {}
1771        }
1772        false
1773    }
1774
1775    fn collect_statement_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
1776        match node.kind {
1777            VARIABLE_STATEMENT => {
1778                if let Some(data) = self.get_variable(node) {
1779                    Self::add_opt_list(children, data.modifiers.as_ref());
1780                    Self::add_list(children, &data.declarations);
1781                    return true;
1782                }
1783            }
1784            VARIABLE_DECLARATION_LIST => {
1785                if let Some(data) = self.get_variable(node) {
1786                    Self::add_list(children, &data.declarations);
1787                    return true;
1788                }
1789            }
1790            VARIABLE_DECLARATION => {
1791                if let Some(data) = self.get_variable_declaration(node) {
1792                    children.push(data.name);
1793                    Self::add_opt_child(children, data.type_annotation);
1794                    Self::add_opt_child(children, data.initializer);
1795                    return true;
1796                }
1797            }
1798            EXPRESSION_STATEMENT => {
1799                if let Some(data) = self.get_expression_statement(node) {
1800                    children.push(data.expression);
1801                    return true;
1802                }
1803            }
1804            IF_STATEMENT => {
1805                if let Some(data) = self.get_if_statement(node) {
1806                    children.push(data.expression);
1807                    children.push(data.then_statement);
1808                    Self::add_opt_child(children, data.else_statement);
1809                    return true;
1810                }
1811            }
1812            WHILE_STATEMENT | DO_STATEMENT | FOR_STATEMENT => {
1813                if let Some(data) = self.get_loop(node) {
1814                    Self::add_opt_child(children, data.initializer);
1815                    Self::add_opt_child(children, data.condition);
1816                    Self::add_opt_child(children, data.incrementor);
1817                    children.push(data.statement);
1818                    return true;
1819                }
1820            }
1821            FOR_IN_STATEMENT | FOR_OF_STATEMENT => {
1822                if let Some(data) = self.get_for_in_of(node) {
1823                    children.push(data.initializer);
1824                    children.push(data.expression);
1825                    children.push(data.statement);
1826                    return true;
1827                }
1828            }
1829            SWITCH_STATEMENT => {
1830                if let Some(data) = self.get_switch(node) {
1831                    children.push(data.expression);
1832                    children.push(data.case_block);
1833                    return true;
1834                }
1835            }
1836            CASE_BLOCK | BLOCK | CLASS_STATIC_BLOCK_DECLARATION => {
1837                if let Some(data) = self.get_block(node) {
1838                    Self::add_list(children, &data.statements);
1839                    return true;
1840                }
1841            }
1842            CASE_CLAUSE | DEFAULT_CLAUSE => {
1843                if let Some(data) = self.get_case_clause(node) {
1844                    Self::add_opt_child(children, data.expression);
1845                    Self::add_list(children, &data.statements);
1846                    return true;
1847                }
1848            }
1849            RETURN_STATEMENT => {
1850                if let Some(data) = self.get_return_statement(node) {
1851                    Self::add_opt_child(children, data.expression);
1852                    return true;
1853                }
1854            }
1855            THROW_STATEMENT => {
1856                if let Some(data) = self.get_return_statement(node) {
1857                    children.push(data.expression);
1858                    return true;
1859                }
1860            }
1861            TRY_STATEMENT => {
1862                if let Some(data) = self.get_try(node) {
1863                    children.push(data.try_block);
1864                    Self::add_opt_child(children, data.catch_clause);
1865                    Self::add_opt_child(children, data.finally_block);
1866                    return true;
1867                }
1868            }
1869            CATCH_CLAUSE => {
1870                if let Some(data) = self.get_catch_clause(node) {
1871                    Self::add_opt_child(children, data.variable_declaration);
1872                    children.push(data.block);
1873                    return true;
1874                }
1875            }
1876            LABELED_STATEMENT => {
1877                if let Some(data) = self.get_labeled_statement(node) {
1878                    children.push(data.label);
1879                    children.push(data.statement);
1880                    return true;
1881                }
1882            }
1883            BREAK_STATEMENT | CONTINUE_STATEMENT => {
1884                if let Some(data) = self.get_jump_data(node) {
1885                    Self::add_opt_child(children, data.label);
1886                    return true;
1887                }
1888            }
1889            WITH_STATEMENT => {
1890                if let Some(data) = self.get_with_statement(node) {
1891                    children.push(data.expression);
1892                    children.push(data.then_statement);
1893                    return true;
1894                }
1895            }
1896            _ => {}
1897        }
1898        false
1899    }
1900
1901    fn collect_declaration_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
1902        match node.kind {
1903            FUNCTION_DECLARATION => {
1904                if let Some(data) = self.get_function(node) {
1905                    Self::add_opt_list(children, data.modifiers.as_ref());
1906                    Self::add_opt_child(children, data.name);
1907                    Self::add_opt_list(children, data.type_parameters.as_ref());
1908                    Self::add_list(children, &data.parameters);
1909                    Self::add_opt_child(children, data.type_annotation);
1910                    children.push(data.body);
1911                    return true;
1912                }
1913            }
1914            CLASS_DECLARATION | CLASS_EXPRESSION => {
1915                if let Some(data) = self.get_class(node) {
1916                    Self::add_opt_list(children, data.modifiers.as_ref());
1917                    Self::add_opt_child(children, data.name);
1918                    Self::add_opt_list(children, data.type_parameters.as_ref());
1919                    Self::add_opt_list(children, data.heritage_clauses.as_ref());
1920                    Self::add_list(children, &data.members);
1921                    return true;
1922                }
1923            }
1924            INTERFACE_DECLARATION => {
1925                if let Some(data) = self.get_interface(node) {
1926                    Self::add_opt_list(children, data.modifiers.as_ref());
1927                    Self::add_opt_child(children, data.name);
1928                    Self::add_opt_list(children, data.type_parameters.as_ref());
1929                    Self::add_opt_list(children, data.heritage_clauses.as_ref());
1930                    Self::add_list(children, &data.members);
1931                    return true;
1932                }
1933            }
1934            TYPE_ALIAS_DECLARATION => {
1935                if let Some(data) = self.get_type_alias(node) {
1936                    Self::add_opt_list(children, data.modifiers.as_ref());
1937                    Self::add_opt_child(children, data.name);
1938                    Self::add_opt_list(children, data.type_parameters.as_ref());
1939                    children.push(data.type_node);
1940                    return true;
1941                }
1942            }
1943            ENUM_DECLARATION => {
1944                if let Some(data) = self.get_enum(node) {
1945                    Self::add_opt_list(children, data.modifiers.as_ref());
1946                    Self::add_opt_child(children, data.name);
1947                    Self::add_list(children, &data.members);
1948                    return true;
1949                }
1950            }
1951            ENUM_MEMBER => {
1952                if let Some(data) = self.get_enum_member(node) {
1953                    Self::add_opt_child(children, data.name);
1954                    Self::add_opt_child(children, data.initializer);
1955                    return true;
1956                }
1957            }
1958            MODULE_DECLARATION => {
1959                if let Some(data) = self.get_module(node) {
1960                    Self::add_opt_list(children, data.modifiers.as_ref());
1961                    Self::add_opt_child(children, data.name);
1962                    Self::add_opt_child(children, data.body);
1963                    return true;
1964                }
1965            }
1966            MODULE_BLOCK => {
1967                if let Some(data) = self.get_module_block(node) {
1968                    Self::add_opt_list(children, data.statements.as_ref());
1969                    return true;
1970                }
1971            }
1972            _ => {}
1973        }
1974        false
1975    }
1976
1977    fn collect_import_export_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
1978        match node.kind {
1979            IMPORT_DECLARATION | IMPORT_EQUALS_DECLARATION => {
1980                if let Some(data) = self.get_import_decl(node) {
1981                    Self::add_opt_list(children, data.modifiers.as_ref());
1982                    Self::add_opt_child(children, data.import_clause);
1983                    children.push(data.module_specifier);
1984                    Self::add_opt_child(children, data.attributes);
1985                    return true;
1986                }
1987            }
1988            IMPORT_CLAUSE => {
1989                if let Some(data) = self.get_import_clause(node) {
1990                    Self::add_opt_child(children, data.name);
1991                    Self::add_opt_child(children, data.named_bindings);
1992                    return true;
1993                }
1994            }
1995            NAMESPACE_IMPORT | NAMESPACE_EXPORT => {
1996                if let Some(data) = self.get_named_imports(node) {
1997                    children.push(data.name);
1998                    return true;
1999                }
2000            }
2001            NAMED_IMPORTS | NAMED_EXPORTS => {
2002                if let Some(data) = self.get_named_imports(node) {
2003                    Self::add_list(children, &data.elements);
2004                    return true;
2005                }
2006            }
2007            IMPORT_SPECIFIER | EXPORT_SPECIFIER => {
2008                if let Some(data) = self.get_specifier(node) {
2009                    Self::add_opt_child(children, data.property_name);
2010                    children.push(data.name);
2011                    return true;
2012                }
2013            }
2014            EXPORT_DECLARATION => {
2015                if let Some(data) = self.get_export_decl(node) {
2016                    Self::add_opt_list(children, data.modifiers.as_ref());
2017                    Self::add_opt_child(children, data.export_clause);
2018                    Self::add_opt_child(children, data.module_specifier);
2019                    Self::add_opt_child(children, data.attributes);
2020                    return true;
2021                }
2022            }
2023            EXPORT_ASSIGNMENT => {
2024                if let Some(data) = self.get_export_assignment(node) {
2025                    Self::add_opt_list(children, data.modifiers.as_ref());
2026                    children.push(data.expression);
2027                    return true;
2028                }
2029            }
2030            _ => {}
2031        }
2032        false
2033    }
2034
2035    fn collect_type_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2036        match node.kind {
2037            TYPE_REFERENCE => {
2038                if let Some(data) = self.get_type_ref(node) {
2039                    children.push(data.type_name);
2040                    Self::add_opt_list(children, data.type_arguments.as_ref());
2041                    return true;
2042                }
2043            }
2044            FUNCTION_TYPE | CONSTRUCTOR_TYPE => {
2045                if let Some(data) = self.get_function_type(node) {
2046                    Self::add_opt_list(children, data.type_parameters.as_ref());
2047                    Self::add_list(children, &data.parameters);
2048                    children.push(data.type_annotation);
2049                    return true;
2050                }
2051            }
2052            TYPE_QUERY => {
2053                if let Some(data) = self.get_type_query(node) {
2054                    children.push(data.expr_name);
2055                    Self::add_opt_list(children, data.type_arguments.as_ref());
2056                    return true;
2057                }
2058            }
2059            TYPE_LITERAL => {
2060                if let Some(data) = self.get_type_literal(node) {
2061                    Self::add_list(children, &data.members);
2062                    return true;
2063                }
2064            }
2065            ARRAY_TYPE => {
2066                if let Some(data) = self.get_array_type(node) {
2067                    children.push(data.element_type);
2068                    return true;
2069                }
2070            }
2071            TUPLE_TYPE => {
2072                if let Some(data) = self.get_tuple_type(node) {
2073                    Self::add_list(children, &data.elements);
2074                    return true;
2075                }
2076            }
2077            OPTIONAL_TYPE | REST_TYPE | PARENTHESIZED_TYPE => {
2078                if let Some(data) = self.get_wrapped_type(node) {
2079                    children.push(data.type_node);
2080                    return true;
2081                }
2082            }
2083            UNION_TYPE | INTERSECTION_TYPE => {
2084                if let Some(data) = self.get_composite_type(node) {
2085                    Self::add_list(children, &data.types);
2086                    return true;
2087                }
2088            }
2089            CONDITIONAL_TYPE => {
2090                if let Some(data) = self.get_conditional_type(node) {
2091                    children.push(data.check_type);
2092                    children.push(data.extends_type);
2093                    children.push(data.true_type);
2094                    children.push(data.false_type);
2095                    return true;
2096                }
2097            }
2098            INFER_TYPE => {
2099                if let Some(data) = self.get_infer_type(node) {
2100                    children.push(data.type_parameter);
2101                    return true;
2102                }
2103            }
2104            TYPE_OPERATOR => {
2105                if let Some(data) = self.get_type_operator(node) {
2106                    children.push(data.type_node);
2107                    return true;
2108                }
2109            }
2110            INDEXED_ACCESS_TYPE => {
2111                if let Some(data) = self.get_indexed_access_type(node) {
2112                    children.push(data.object_type);
2113                    children.push(data.index_type);
2114                    return true;
2115                }
2116            }
2117            MAPPED_TYPE => {
2118                if let Some(data) = self.get_mapped_type(node) {
2119                    Self::add_opt_child(children, data.type_parameter);
2120                    Self::add_opt_child(children, data.name_type);
2121                    Self::add_opt_child(children, data.type_node);
2122                    Self::add_opt_list(children, data.members.as_ref());
2123                    return true;
2124                }
2125            }
2126            LITERAL_TYPE => {
2127                if let Some(data) = self.get_literal_type(node) {
2128                    Self::add_opt_child(children, data.literal);
2129                    return true;
2130                }
2131            }
2132            TEMPLATE_LITERAL_TYPE => {
2133                if let Some(data) = self.get_template_literal_type(node) {
2134                    children.push(data.head);
2135                    Self::add_list(children, &data.template_spans);
2136                    return true;
2137                }
2138            }
2139            NAMED_TUPLE_MEMBER => {
2140                if let Some(data) = self.get_named_tuple_member(node) {
2141                    children.push(data.name);
2142                    children.push(data.type_node);
2143                    return true;
2144                }
2145            }
2146            TYPE_PREDICATE => {
2147                if let Some(data) = self.get_type_predicate(node) {
2148                    children.push(data.parameter_name);
2149                    Self::add_opt_child(children, data.type_node);
2150                    return true;
2151                }
2152            }
2153            _ => {}
2154        }
2155        false
2156    }
2157
2158    fn collect_member_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2159        match node.kind {
2160            PROPERTY_DECLARATION => {
2161                if let Some(data) = self.get_property_decl(node) {
2162                    Self::add_opt_list(children, data.modifiers.as_ref());
2163                    Self::add_opt_child(children, data.name);
2164                    Self::add_opt_child(children, data.type_annotation);
2165                    Self::add_opt_child(children, data.initializer);
2166                    return true;
2167                }
2168            }
2169            METHOD_DECLARATION => {
2170                if let Some(data) = self.get_method_decl(node) {
2171                    Self::add_opt_list(children, data.modifiers.as_ref());
2172                    Self::add_opt_child(children, data.name);
2173                    Self::add_opt_list(children, data.type_parameters.as_ref());
2174                    Self::add_list(children, &data.parameters);
2175                    Self::add_opt_child(children, data.type_annotation);
2176                    children.push(data.body);
2177                    return true;
2178                }
2179            }
2180            CONSTRUCTOR => {
2181                if let Some(data) = self.get_constructor(node) {
2182                    Self::add_opt_list(children, data.modifiers.as_ref());
2183                    Self::add_opt_list(children, data.type_parameters.as_ref());
2184                    Self::add_list(children, &data.parameters);
2185                    children.push(data.body);
2186                    return true;
2187                }
2188            }
2189            GET_ACCESSOR | SET_ACCESSOR => {
2190                if let Some(data) = self.get_accessor(node) {
2191                    Self::add_opt_list(children, data.modifiers.as_ref());
2192                    Self::add_opt_child(children, data.name);
2193                    Self::add_opt_list(children, data.type_parameters.as_ref());
2194                    Self::add_list(children, &data.parameters);
2195                    Self::add_opt_child(children, data.type_annotation);
2196                    children.push(data.body);
2197                    children.push(data.body);
2198                    return true;
2199                }
2200            }
2201            PARAMETER => {
2202                if let Some(data) = self.get_parameter(node) {
2203                    Self::add_opt_list(children, data.modifiers.as_ref());
2204                    Self::add_opt_child(children, data.name);
2205                    Self::add_opt_child(children, data.type_annotation);
2206                    Self::add_opt_child(children, data.initializer);
2207                    return true;
2208                }
2209            }
2210            TYPE_PARAMETER => {
2211                if let Some(data) = self.get_type_parameter(node) {
2212                    Self::add_opt_list(children, data.modifiers.as_ref());
2213                    children.push(data.name);
2214                    Self::add_opt_child(children, data.constraint);
2215                    Self::add_opt_child(children, data.default);
2216                    return true;
2217                }
2218            }
2219            DECORATOR => {
2220                if let Some(data) = self.get_decorator(node) {
2221                    children.push(data.expression);
2222                    return true;
2223                }
2224            }
2225            HERITAGE_CLAUSE => {
2226                if let Some(data) = self.get_heritage_clause(node) {
2227                    Self::add_list(children, &data.types);
2228                    return true;
2229                }
2230            }
2231            EXPRESSION_WITH_TYPE_ARGUMENTS => {
2232                if let Some(data) = self.get_expr_type_args(node) {
2233                    children.push(data.expression);
2234                    Self::add_opt_list(children, data.type_arguments.as_ref());
2235                    return true;
2236                }
2237            }
2238            _ => {}
2239        }
2240        false
2241    }
2242
2243    fn collect_pattern_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2244        match node.kind {
2245            OBJECT_BINDING_PATTERN | ARRAY_BINDING_PATTERN => {
2246                if let Some(data) = self.get_binding_pattern(node) {
2247                    Self::add_list(children, &data.elements);
2248                    return true;
2249                }
2250            }
2251            BINDING_ELEMENT => {
2252                if let Some(data) = self.get_binding_element(node) {
2253                    Self::add_opt_child(children, data.property_name);
2254                    children.push(data.name);
2255                    Self::add_opt_child(children, data.initializer);
2256                    return true;
2257                }
2258            }
2259            PROPERTY_ASSIGNMENT => {
2260                if let Some(data) = self.get_property_assignment(node) {
2261                    Self::add_opt_list(children, data.modifiers.as_ref());
2262                    Self::add_opt_child(children, data.name);
2263                    children.push(data.initializer);
2264                    return true;
2265                }
2266            }
2267            SHORTHAND_PROPERTY_ASSIGNMENT => {
2268                if let Some(data) = self.get_shorthand_property(node) {
2269                    Self::add_opt_list(children, data.modifiers.as_ref());
2270                    children.push(data.name);
2271                    Self::add_opt_child(children, data.object_assignment_initializer);
2272                    return true;
2273                }
2274            }
2275            _ => {}
2276        }
2277        false
2278    }
2279
2280    fn collect_jsx_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2281        match node.kind {
2282            JSX_ELEMENT => {
2283                if let Some(data) = self.get_jsx_element(node) {
2284                    children.push(data.opening_element);
2285                    Self::add_list(children, &data.children);
2286                    Self::add_opt_child(children, data.closing_element);
2287                    return true;
2288                }
2289            }
2290            JSX_SELF_CLOSING_ELEMENT | JSX_OPENING_ELEMENT => {
2291                if let Some(data) = self.get_jsx_opening(node) {
2292                    children.push(data.tag_name);
2293                    Self::add_opt_list(children, data.type_arguments.as_ref());
2294                    Self::add_opt_child(children, data.attributes);
2295                    return true;
2296                }
2297            }
2298            JSX_CLOSING_ELEMENT => {
2299                if let Some(data) = self.get_jsx_closing(node) {
2300                    children.push(data.tag_name);
2301                    return true;
2302                }
2303            }
2304            JSX_FRAGMENT => {
2305                if let Some(data) = self.get_jsx_fragment(node) {
2306                    children.push(data.opening_fragment);
2307                    Self::add_list(children, &data.children);
2308                    children.push(data.closing_fragment);
2309                    return true;
2310                }
2311            }
2312            JSX_ATTRIBUTES => {
2313                if let Some(data) = self.get_jsx_attributes(node) {
2314                    Self::add_list(children, &data.properties);
2315                    return true;
2316                }
2317            }
2318            JSX_ATTRIBUTE => {
2319                if let Some(data) = self.get_jsx_attribute(node) {
2320                    children.push(data.name);
2321                    Self::add_opt_child(children, data.initializer);
2322                    return true;
2323                }
2324            }
2325            JSX_SPREAD_ATTRIBUTE => {
2326                if let Some(data) = self.get_jsx_spread_attribute(node) {
2327                    children.push(data.expression);
2328                    return true;
2329                }
2330            }
2331            JSX_EXPRESSION => {
2332                if let Some(data) = self.get_jsx_expression(node) {
2333                    Self::add_opt_child(children, data.expression);
2334                    return true;
2335                }
2336            }
2337            JSX_NAMESPACED_NAME => {
2338                if let Some(data) = self.get_jsx_namespaced_name(node) {
2339                    children.push(data.namespace);
2340                    children.push(data.name);
2341                    return true;
2342                }
2343            }
2344            _ => {}
2345        }
2346        false
2347    }
2348
2349    fn collect_signature_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2350        match node.kind {
2351            CALL_SIGNATURE | CONSTRUCT_SIGNATURE => {
2352                if let Some(data) = self.get_signature(node) {
2353                    Self::add_opt_list(children, data.type_parameters.as_ref());
2354                    Self::add_opt_list(children, data.parameters.as_ref());
2355                    Self::add_opt_child(children, data.type_annotation);
2356                    return true;
2357                }
2358            }
2359            INDEX_SIGNATURE => {
2360                if let Some(data) = self.get_index_signature(node) {
2361                    Self::add_opt_list(children, data.modifiers.as_ref());
2362                    Self::add_list(children, &data.parameters);
2363                    Self::add_opt_child(children, data.type_annotation);
2364                    return true;
2365                }
2366            }
2367            PROPERTY_SIGNATURE => {
2368                if let Some(data) = self.get_signature(node) {
2369                    Self::add_opt_list(children, data.modifiers.as_ref());
2370                    Self::add_opt_child(children, data.name);
2371                    Self::add_opt_child(children, data.type_annotation);
2372                    return true;
2373                }
2374            }
2375            METHOD_SIGNATURE => {
2376                if let Some(data) = self.get_signature(node) {
2377                    Self::add_opt_list(children, data.modifiers.as_ref());
2378                    Self::add_opt_child(children, data.name);
2379                    Self::add_opt_list(children, data.type_parameters.as_ref());
2380                    Self::add_opt_list(children, data.parameters.as_ref());
2381                    Self::add_opt_child(children, data.type_annotation);
2382                    return true;
2383                }
2384            }
2385            _ => {}
2386        }
2387        false
2388    }
2389
2390    fn collect_source_children(&self, node: &Node, children: &mut Vec<NodeIndex>) -> bool {
2391        if node.kind == SOURCE_FILE
2392            && let Some(data) = self.get_source_file(node)
2393        {
2394            Self::add_list(children, &data.statements);
2395            children.push(data.end_of_file_token);
2396            return true;
2397        }
2398        false
2399    }
2400}
2401
2402// =============================================================================
2403// Node Access Trait - Unified Interface for Arena Types
2404// =============================================================================
2405
2406/// Common node information that both arena types can provide.
2407/// This struct contains the essential fields needed by most consumers.
2408#[derive(Clone, Debug)]
2409pub struct NodeInfo {
2410    pub kind: u16,
2411    pub flags: u32,
2412    pub modifier_flags: u32,
2413    pub pos: u32,
2414    pub end: u32,
2415    pub parent: NodeIndex,
2416    pub id: u32,
2417}
2418
2419impl NodeInfo {
2420    /// Create from a Node and its extended info
2421    #[must_use]
2422    pub fn from_thin(node: &Node, ext: &ExtendedNodeInfo) -> Self {
2423        Self {
2424            kind: node.kind,
2425            flags: u32::from(node.flags),
2426            modifier_flags: ext.modifier_flags,
2427            pos: node.pos,
2428            end: node.end,
2429            parent: ext.parent,
2430            id: ext.id,
2431        }
2432    }
2433}
2434
2435/// Trait for unified access to AST nodes across different arena implementations.
2436/// This allows consumers (binder, checker, emitter) to work with either
2437/// different arena implementations without code changes.
2438pub trait NodeAccess {
2439    /// Get basic node information by index
2440    fn node_info(&self, index: NodeIndex) -> Option<NodeInfo>;
2441
2442    /// Get the syntax kind of a node
2443    fn kind(&self, index: NodeIndex) -> Option<u16>;
2444
2445    /// Get the source position range
2446    fn pos_end(&self, index: NodeIndex) -> Option<(u32, u32)>;
2447
2448    /// Check if a node exists
2449    fn exists(&self, index: NodeIndex) -> bool {
2450        index.is_some() && self.kind(index).is_some()
2451    }
2452
2453    /// Get identifier text (if this is an identifier node)
2454    fn get_identifier_text(&self, index: NodeIndex) -> Option<&str>;
2455
2456    /// Get literal value text (if this is a literal node)
2457    fn get_literal_text(&self, index: NodeIndex) -> Option<&str>;
2458
2459    /// Get children of a node (for traversal)
2460    fn get_children(&self, index: NodeIndex) -> Vec<NodeIndex>;
2461}
2462
2463/// Implementation of `NodeAccess` for `NodeArena`
2464impl NodeAccess for NodeArena {
2465    fn node_info(&self, index: NodeIndex) -> Option<NodeInfo> {
2466        if index.is_none() {
2467            return None;
2468        }
2469        let node = self.nodes.get(index.0 as usize)?;
2470        let ext = self.extended_info.get(index.0 as usize)?;
2471        Some(NodeInfo::from_thin(node, ext))
2472    }
2473
2474    fn kind(&self, index: NodeIndex) -> Option<u16> {
2475        if index.is_none() {
2476            return None;
2477        }
2478        self.nodes.get(index.0 as usize).map(|n| n.kind)
2479    }
2480
2481    fn pos_end(&self, index: NodeIndex) -> Option<(u32, u32)> {
2482        if index.is_none() {
2483            return None;
2484        }
2485        self.nodes.get(index.0 as usize).map(|n| (n.pos, n.end))
2486    }
2487
2488    fn get_identifier_text(&self, index: NodeIndex) -> Option<&str> {
2489        let node = self.get(index)?;
2490        let data = self.get_identifier(node)?;
2491        // Use atom for O(1) lookup if available, otherwise fall back to escaped_text
2492        Some(self.resolve_identifier_text(data))
2493    }
2494
2495    fn get_literal_text(&self, index: NodeIndex) -> Option<&str> {
2496        let node = self.get(index)?;
2497        let data = self.get_literal(node)?;
2498        Some(&data.text)
2499    }
2500
2501    fn get_children(&self, index: NodeIndex) -> Vec<NodeIndex> {
2502        if index.is_none() {
2503            return Vec::new();
2504        }
2505
2506        let Some(node) = self.nodes.get(index.0 as usize) else {
2507            return Vec::new();
2508        };
2509
2510        let mut children = Vec::new();
2511
2512        if self.collect_name_children(node, &mut children)
2513            || self.collect_expression_children(node, &mut children)
2514            || self.collect_statement_children(node, &mut children)
2515            || self.collect_declaration_children(node, &mut children)
2516            || self.collect_import_export_children(node, &mut children)
2517            || self.collect_type_children(node, &mut children)
2518            || self.collect_member_children(node, &mut children)
2519            || self.collect_pattern_children(node, &mut children)
2520            || self.collect_jsx_children(node, &mut children)
2521            || self.collect_signature_children(node, &mut children)
2522            || self.collect_source_children(node, &mut children)
2523        {
2524            return children;
2525        }
2526
2527        children
2528    }
2529}