Skip to content

Commit d07fa71

Browse files
committed
feat(napi/parser): add AST walker
1 parent f694cda commit d07fa71

File tree

4 files changed

+2773
-10
lines changed

4 files changed

+2773
-10
lines changed

.github/generated/ast_changes_watch_list.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ src:
7373
- 'napi/parser/generated/lazy/types.mjs'
7474
- 'napi/parser/generated/lazy/walk.mjs'
7575
- 'napi/parser/generated/visit/keys.mjs'
76+
- 'napi/parser/generated/visit/types.mjs'
77+
- 'napi/parser/generated/visit/walk.mjs'
7678
- 'napi/parser/src/generated/assert_layouts.rs'
7779
- 'napi/parser/src/generated/derive_estree.rs'
7880
- 'napi/parser/src/generated/raw_transfer_constants.rs'
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// Auto-generated code, DO NOT EDIT DIRECTLY!
2+
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/estree_visit.rs`.
3+
4+
// Mapping from node type name to node type ID
5+
export const NODE_TYPE_IDS_MAP = new Map([
6+
// Leaf nodes
7+
['DebuggerStatement', 0],
8+
['EmptyStatement', 1],
9+
['Literal', 2],
10+
['PrivateIdentifier', 3],
11+
['Super', 4],
12+
['TemplateElement', 5],
13+
['ThisExpression', 6],
14+
['JSXClosingFragment', 7],
15+
['JSXEmptyExpression', 8],
16+
['JSXIdentifier', 9],
17+
['JSXOpeningFragment', 10],
18+
['JSXText', 11],
19+
['TSAnyKeyword', 12],
20+
['TSBigIntKeyword', 13],
21+
['TSBooleanKeyword', 14],
22+
['TSIntrinsicKeyword', 15],
23+
['TSNeverKeyword', 16],
24+
['TSNullKeyword', 17],
25+
['TSNumberKeyword', 18],
26+
['TSObjectKeyword', 19],
27+
['TSStringKeyword', 20],
28+
['TSSymbolKeyword', 21],
29+
['TSThisType', 22],
30+
['TSUndefinedKeyword', 23],
31+
['TSUnknownKeyword', 24],
32+
['TSVoidKeyword', 25],
33+
// Non-leaf nodes
34+
['AccessorProperty', 26],
35+
['ArrayExpression', 27],
36+
['ArrayPattern', 28],
37+
['ArrowFunctionExpression', 29],
38+
['AssignmentExpression', 30],
39+
['AssignmentPattern', 31],
40+
['AwaitExpression', 32],
41+
['BinaryExpression', 33],
42+
['BlockStatement', 34],
43+
['BreakStatement', 35],
44+
['CallExpression', 36],
45+
['CatchClause', 37],
46+
['ChainExpression', 38],
47+
['ClassBody', 39],
48+
['ClassDeclaration', 40],
49+
['ClassExpression', 41],
50+
['ConditionalExpression', 42],
51+
['ContinueStatement', 43],
52+
['Decorator', 44],
53+
['DoWhileStatement', 45],
54+
['ExperimentalRestProperty', 46],
55+
['ExperimentalSpreadProperty', 47],
56+
['ExportAllDeclaration', 48],
57+
['ExportDefaultDeclaration', 49],
58+
['ExportNamedDeclaration', 50],
59+
['ExportSpecifier', 51],
60+
['ExpressionStatement', 52],
61+
['ForInStatement', 53],
62+
['ForOfStatement', 54],
63+
['ForStatement', 55],
64+
['FunctionDeclaration', 56],
65+
['FunctionExpression', 57],
66+
['Identifier', 58],
67+
['IfStatement', 59],
68+
['ImportAttribute', 60],
69+
['ImportDeclaration', 61],
70+
['ImportDefaultSpecifier', 62],
71+
['ImportExpression', 63],
72+
['ImportNamespaceSpecifier', 64],
73+
['ImportSpecifier', 65],
74+
['LabeledStatement', 66],
75+
['LogicalExpression', 67],
76+
['MemberExpression', 68],
77+
['MetaProperty', 69],
78+
['MethodDefinition', 70],
79+
['NewExpression', 71],
80+
['ObjectExpression', 72],
81+
['ObjectPattern', 73],
82+
['ParenthesizedExpression', 74],
83+
['Program', 75],
84+
['Property', 76],
85+
['PropertyDefinition', 77],
86+
['RestElement', 78],
87+
['ReturnStatement', 79],
88+
['SequenceExpression', 80],
89+
['SpreadElement', 81],
90+
['StaticBlock', 82],
91+
['SwitchCase', 83],
92+
['SwitchStatement', 84],
93+
['TaggedTemplateExpression', 85],
94+
['TemplateLiteral', 86],
95+
['ThrowStatement', 87],
96+
['TryStatement', 88],
97+
['UnaryExpression', 89],
98+
['UpdateExpression', 90],
99+
['V8IntrinsicExpression', 91],
100+
['VariableDeclaration', 92],
101+
['VariableDeclarator', 93],
102+
['WhileStatement', 94],
103+
['WithStatement', 95],
104+
['YieldExpression', 96],
105+
['JSXAttribute', 97],
106+
['JSXClosingElement', 98],
107+
['JSXElement', 99],
108+
['JSXExpressionContainer', 100],
109+
['JSXFragment', 101],
110+
['JSXMemberExpression', 102],
111+
['JSXNamespacedName', 103],
112+
['JSXOpeningElement', 104],
113+
['JSXSpreadAttribute', 105],
114+
['JSXSpreadChild', 106],
115+
['TSAbstractAccessorProperty', 107],
116+
['TSAbstractMethodDefinition', 108],
117+
['TSAbstractPropertyDefinition', 109],
118+
['TSArrayType', 110],
119+
['TSAsExpression', 111],
120+
['TSCallSignatureDeclaration', 112],
121+
['TSClassImplements', 113],
122+
['TSConditionalType', 114],
123+
['TSConstructSignatureDeclaration', 115],
124+
['TSConstructorType', 116],
125+
['TSDeclareFunction', 117],
126+
['TSEmptyBodyFunctionExpression', 118],
127+
['TSEnumBody', 119],
128+
['TSEnumDeclaration', 120],
129+
['TSEnumMember', 121],
130+
['TSExportAssignment', 122],
131+
['TSExternalModuleReference', 123],
132+
['TSFunctionType', 124],
133+
['TSImportEqualsDeclaration', 125],
134+
['TSImportType', 126],
135+
['TSIndexSignature', 127],
136+
['TSIndexedAccessType', 128],
137+
['TSInferType', 129],
138+
['TSInstantiationExpression', 130],
139+
['TSInterfaceBody', 131],
140+
['TSInterfaceDeclaration', 132],
141+
['TSInterfaceHeritage', 133],
142+
['TSIntersectionType', 134],
143+
['TSJSDocNonNullableType', 135],
144+
['TSJSDocNullableType', 136],
145+
['TSLiteralType', 137],
146+
['TSMappedType', 138],
147+
['TSMethodSignature', 139],
148+
['TSModuleBlock', 140],
149+
['TSModuleDeclaration', 141],
150+
['TSNamedTupleMember', 142],
151+
['TSNamespaceExportDeclaration', 143],
152+
['TSNonNullExpression', 144],
153+
['TSOptionalType', 145],
154+
['TSParameterProperty', 146],
155+
['TSParenthesizedType', 147],
156+
['TSPropertySignature', 148],
157+
['TSQualifiedName', 149],
158+
['TSRestType', 150],
159+
['TSSatisfiesExpression', 151],
160+
['TSTemplateLiteralType', 152],
161+
['TSTupleType', 153],
162+
['TSTypeAliasDeclaration', 154],
163+
['TSTypeAnnotation', 155],
164+
['TSTypeAssertion', 156],
165+
['TSTypeLiteral', 157],
166+
['TSTypeOperator', 158],
167+
['TSTypeParameter', 159],
168+
['TSTypeParameterDeclaration', 160],
169+
['TSTypeParameterInstantiation', 161],
170+
['TSTypePredicate', 162],
171+
['TSTypeQuery', 163],
172+
['TSTypeReference', 164],
173+
['TSUnionType', 165],
174+
]);
175+
176+
export const NODE_TYPES_COUNT = 166;
177+
export const LEAF_NODE_TYPES_COUNT = 26;

0 commit comments

Comments
 (0)