Skip to content

Commit 1c50c58

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

File tree

5 files changed

+2796
-10
lines changed

5 files changed

+2796
-10
lines changed

.github/generated/ast_changes_watch_list.yml

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

0 commit comments

Comments
 (0)