@ohos-ports/swc-core 1.3.14-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Visitor.js ADDED
@@ -0,0 +1,1395 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Visitor = void 0;
4
+ class Visitor {
5
+ visitProgram(n) {
6
+ switch (n.type) {
7
+ case "Module":
8
+ return this.visitModule(n);
9
+ case "Script":
10
+ return this.visitScript(n);
11
+ }
12
+ }
13
+ visitModule(m) {
14
+ m.body = this.visitModuleItems(m.body);
15
+ return m;
16
+ }
17
+ visitScript(m) {
18
+ m.body = this.visitStatements(m.body);
19
+ return m;
20
+ }
21
+ visitModuleItems(items) {
22
+ return items.map(this.visitModuleItem.bind(this));
23
+ }
24
+ visitModuleItem(n) {
25
+ switch (n.type) {
26
+ case "ExportDeclaration":
27
+ case "ExportDefaultDeclaration":
28
+ case "ExportNamedDeclaration":
29
+ case "ExportDefaultExpression":
30
+ case "ImportDeclaration":
31
+ case "ExportAllDeclaration":
32
+ case "TsImportEqualsDeclaration":
33
+ case "TsExportAssignment":
34
+ case "TsNamespaceExportDeclaration":
35
+ return this.visitModuleDeclaration(n);
36
+ default:
37
+ return this.visitStatement(n);
38
+ }
39
+ }
40
+ visitModuleDeclaration(n) {
41
+ switch (n.type) {
42
+ case "ExportDeclaration":
43
+ return this.visitExportDeclaration(n);
44
+ case "ExportDefaultDeclaration":
45
+ return this.visitExportDefaultDeclaration(n);
46
+ case "ExportNamedDeclaration":
47
+ return this.visitExportNamedDeclaration(n);
48
+ case "ExportDefaultExpression":
49
+ return this.visitExportDefaultExpression(n);
50
+ case "ImportDeclaration":
51
+ return this.visitImportDeclaration(n);
52
+ case "ExportAllDeclaration":
53
+ return this.visitExportAllDeclaration(n);
54
+ case "TsImportEqualsDeclaration":
55
+ return this.visitTsImportEqualsDeclaration(n);
56
+ case "TsExportAssignment":
57
+ return this.visitTsExportAssignment(n);
58
+ case "TsNamespaceExportDeclaration":
59
+ return this.visitTsNamespaceExportDeclaration(n);
60
+ }
61
+ }
62
+ visitTsNamespaceExportDeclaration(n) {
63
+ n.id = this.visitBindingIdentifier(n.id);
64
+ return n;
65
+ }
66
+ visitTsExportAssignment(n) {
67
+ n.expression = this.visitExpression(n.expression);
68
+ return n;
69
+ }
70
+ visitTsImportEqualsDeclaration(n) {
71
+ n.id = this.visitBindingIdentifier(n.id);
72
+ n.moduleRef = this.visitTsModuleReference(n.moduleRef);
73
+ return n;
74
+ }
75
+ visitTsModuleReference(n) {
76
+ switch (n.type) {
77
+ case "Identifier":
78
+ return this.visitIdentifierReference(n);
79
+ case "TsExternalModuleReference":
80
+ return this.visitTsExternalModuleReference(n);
81
+ case "TsQualifiedName":
82
+ return this.visitTsQualifiedName(n);
83
+ }
84
+ }
85
+ visitTsExternalModuleReference(n) {
86
+ n.expression = this.visitStringLiteral(n.expression);
87
+ return n;
88
+ }
89
+ visitExportAllDeclaration(n) {
90
+ n.source = this.visitStringLiteral(n.source);
91
+ return n;
92
+ }
93
+ visitExportDefaultExpression(n) {
94
+ n.expression = this.visitExpression(n.expression);
95
+ return n;
96
+ }
97
+ visitExportNamedDeclaration(n) {
98
+ n.specifiers = this.visitExportSpecifiers(n.specifiers);
99
+ n.source = this.visitOptionalStringLiteral(n.source);
100
+ return n;
101
+ }
102
+ visitExportSpecifiers(nodes) {
103
+ return nodes.map(this.visitExportSpecifier.bind(this));
104
+ }
105
+ visitExportSpecifier(n) {
106
+ switch (n.type) {
107
+ case "ExportDefaultSpecifier":
108
+ return this.visitExportDefaultSpecifier(n);
109
+ case "ExportNamespaceSpecifier":
110
+ return this.visitExportNamespaceSpecifier(n);
111
+ case "ExportSpecifier":
112
+ return this.visitNamedExportSpecifier(n);
113
+ }
114
+ }
115
+ visitNamedExportSpecifier(n) {
116
+ if (n.exported) {
117
+ n.exported = this.visitModuleExportName(n.exported);
118
+ }
119
+ n.orig = this.visitModuleExportName(n.orig);
120
+ return n;
121
+ }
122
+ visitModuleExportName(n) {
123
+ switch (n.type) {
124
+ case "Identifier":
125
+ return this.visitIdentifier(n);
126
+ case "StringLiteral":
127
+ return this.visitStringLiteral(n);
128
+ }
129
+ }
130
+ visitExportNamespaceSpecifier(n) {
131
+ n.name = this.visitModuleExportName(n.name);
132
+ return n;
133
+ }
134
+ visitExportDefaultSpecifier(n) {
135
+ n.exported = this.visitBindingIdentifier(n.exported);
136
+ return n;
137
+ }
138
+ visitOptionalStringLiteral(n) {
139
+ if (n) {
140
+ return this.visitStringLiteral(n);
141
+ }
142
+ }
143
+ visitExportDefaultDeclaration(n) {
144
+ n.decl = this.visitDefaultDeclaration(n.decl);
145
+ return n;
146
+ }
147
+ visitDefaultDeclaration(n) {
148
+ switch (n.type) {
149
+ case "ClassExpression":
150
+ return this.visitClassExpression(n);
151
+ case "FunctionExpression":
152
+ return this.visitFunctionExpression(n);
153
+ case "TsInterfaceDeclaration":
154
+ return this.visitTsInterfaceDeclaration(n);
155
+ }
156
+ }
157
+ visitFunctionExpression(n) {
158
+ n = this.visitFunction(n);
159
+ if (n.identifier) {
160
+ n.identifier = this.visitBindingIdentifier(n.identifier);
161
+ }
162
+ return n;
163
+ }
164
+ visitClassExpression(n) {
165
+ n = this.visitClass(n);
166
+ if (n.identifier) {
167
+ n.identifier = this.visitBindingIdentifier(n.identifier);
168
+ }
169
+ return n;
170
+ }
171
+ visitExportDeclaration(n) {
172
+ n.declaration = this.visitDeclaration(n.declaration);
173
+ return n;
174
+ }
175
+ visitArrayExpression(e) {
176
+ if (e.elements) {
177
+ e.elements = e.elements.map(this.visitArrayElement.bind(this));
178
+ }
179
+ return e;
180
+ }
181
+ visitArrayElement(e) {
182
+ if (e) {
183
+ return this.visitExprOrSpread(e);
184
+ }
185
+ }
186
+ visitExprOrSpread(e) {
187
+ return Object.assign(Object.assign({}, e), { expression: this.visitExpression(e.expression) });
188
+ }
189
+ visitExprOrSpreads(nodes) {
190
+ return nodes.map(this.visitExprOrSpread.bind(this));
191
+ }
192
+ visitSpreadElement(e) {
193
+ e.arguments = this.visitExpression(e.arguments);
194
+ return e;
195
+ }
196
+ visitOptionalExpression(e) {
197
+ if (e) {
198
+ return this.visitExpression(e);
199
+ }
200
+ }
201
+ visitArrowFunctionExpression(e) {
202
+ e.body = this.visitArrowBody(e.body);
203
+ e.params = this.visitPatterns(e.params);
204
+ e.returnType = this.visitTsTypeAnnotation(e.returnType);
205
+ e.typeParameters = this.visitTsTypeParameterDeclaration(e.typeParameters);
206
+ return e;
207
+ }
208
+ visitArrowBody(body) {
209
+ switch (body.type) {
210
+ case "BlockStatement":
211
+ return this.visitBlockStatement(body);
212
+ default:
213
+ return this.visitExpression(body);
214
+ }
215
+ }
216
+ visitBlockStatement(block) {
217
+ block.stmts = this.visitStatements(block.stmts);
218
+ return block;
219
+ }
220
+ visitStatements(stmts) {
221
+ return stmts.map(this.visitStatement.bind(this));
222
+ }
223
+ visitStatement(stmt) {
224
+ switch (stmt.type) {
225
+ case "ClassDeclaration":
226
+ case "FunctionDeclaration":
227
+ case "TsEnumDeclaration":
228
+ case "TsInterfaceDeclaration":
229
+ case "TsModuleDeclaration":
230
+ case "TsTypeAliasDeclaration":
231
+ case "VariableDeclaration":
232
+ return this.visitDeclaration(stmt);
233
+ case "BreakStatement":
234
+ return this.visitBreakStatement(stmt);
235
+ case "BlockStatement":
236
+ return this.visitBlockStatement(stmt);
237
+ case "ContinueStatement":
238
+ return this.visitContinueStatement(stmt);
239
+ case "DebuggerStatement":
240
+ return this.visitDebuggerStatement(stmt);
241
+ case "DoWhileStatement":
242
+ return this.visitDoWhileStatement(stmt);
243
+ case "EmptyStatement":
244
+ return this.visitEmptyStatement(stmt);
245
+ case "ForInStatement":
246
+ return this.visitForInStatement(stmt);
247
+ case "ForOfStatement":
248
+ return this.visitForOfStatement(stmt);
249
+ case "ForStatement":
250
+ return this.visitForStatement(stmt);
251
+ case "IfStatement":
252
+ return this.visitIfStatement(stmt);
253
+ case "LabeledStatement":
254
+ return this.visitLabeledStatement(stmt);
255
+ case "ReturnStatement":
256
+ return this.visitReturnStatement(stmt);
257
+ case "SwitchStatement":
258
+ return this.visitSwitchStatement(stmt);
259
+ case "ThrowStatement":
260
+ return this.visitThrowStatement(stmt);
261
+ case "TryStatement":
262
+ return this.visitTryStatement(stmt);
263
+ case "WhileStatement":
264
+ return this.visitWhileStatement(stmt);
265
+ case "WithStatement":
266
+ return this.visitWithStatement(stmt);
267
+ case "ExpressionStatement":
268
+ return this.visitExpressionStatement(stmt);
269
+ default:
270
+ throw new Error(`Unknown statement type: ` + stmt.type);
271
+ }
272
+ }
273
+ visitSwitchStatement(stmt) {
274
+ stmt.discriminant = this.visitExpression(stmt.discriminant);
275
+ stmt.cases = this.visitSwitchCases(stmt.cases);
276
+ return stmt;
277
+ }
278
+ visitSwitchCases(cases) {
279
+ return cases.map(this.visitSwitchCase.bind(this));
280
+ }
281
+ visitSwitchCase(c) {
282
+ c.test = this.visitOptionalExpression(c.test);
283
+ c.consequent = this.visitStatements(c.consequent);
284
+ return c;
285
+ }
286
+ visitIfStatement(stmt) {
287
+ stmt.test = this.visitExpression(stmt.test);
288
+ stmt.consequent = this.visitStatement(stmt.consequent);
289
+ stmt.alternate = this.visitOptionalStatement(stmt.alternate);
290
+ return stmt;
291
+ }
292
+ visitOptionalStatement(stmt) {
293
+ if (stmt) {
294
+ return this.visitStatement(stmt);
295
+ }
296
+ }
297
+ visitBreakStatement(stmt) {
298
+ if (stmt.label) {
299
+ stmt.label = this.visitLabelIdentifier(stmt.label);
300
+ }
301
+ return stmt;
302
+ }
303
+ visitWhileStatement(stmt) {
304
+ stmt.test = this.visitExpression(stmt.test);
305
+ stmt.body = this.visitStatement(stmt.body);
306
+ return stmt;
307
+ }
308
+ visitTryStatement(stmt) {
309
+ stmt.block = this.visitBlockStatement(stmt.block);
310
+ stmt.handler = this.visitCatchClause(stmt.handler);
311
+ if (stmt.finalizer) {
312
+ stmt.finalizer = this.visitBlockStatement(stmt.finalizer);
313
+ }
314
+ return stmt;
315
+ }
316
+ visitCatchClause(handler) {
317
+ if (handler) {
318
+ if (handler.param) {
319
+ handler.param = this.visitPattern(handler.param);
320
+ }
321
+ handler.body = this.visitBlockStatement(handler.body);
322
+ }
323
+ return handler;
324
+ }
325
+ visitThrowStatement(stmt) {
326
+ stmt.argument = this.visitExpression(stmt.argument);
327
+ return stmt;
328
+ }
329
+ visitReturnStatement(stmt) {
330
+ if (stmt.argument) {
331
+ stmt.argument = this.visitExpression(stmt.argument);
332
+ }
333
+ return stmt;
334
+ }
335
+ visitLabeledStatement(stmt) {
336
+ stmt.label = this.visitLabelIdentifier(stmt.label);
337
+ stmt.body = this.visitStatement(stmt.body);
338
+ return stmt;
339
+ }
340
+ visitForStatement(stmt) {
341
+ if (stmt.init) {
342
+ if (stmt.init.type === "VariableDeclaration") {
343
+ stmt.init = this.visitVariableDeclaration(stmt.init);
344
+ }
345
+ else {
346
+ stmt.init = this.visitOptionalExpression(stmt.init);
347
+ }
348
+ }
349
+ stmt.test = this.visitOptionalExpression(stmt.test);
350
+ stmt.update = this.visitOptionalExpression(stmt.update);
351
+ stmt.body = this.visitStatement(stmt.body);
352
+ return stmt;
353
+ }
354
+ visitForOfStatement(stmt) {
355
+ if (stmt.left.type === "VariableDeclaration") {
356
+ stmt.left = this.visitVariableDeclaration(stmt.left);
357
+ }
358
+ else {
359
+ stmt.left = this.visitPattern(stmt.left);
360
+ }
361
+ stmt.right = this.visitExpression(stmt.right);
362
+ stmt.body = this.visitStatement(stmt.body);
363
+ return stmt;
364
+ }
365
+ visitForInStatement(stmt) {
366
+ if (stmt.left.type === "VariableDeclaration") {
367
+ stmt.left = this.visitVariableDeclaration(stmt.left);
368
+ }
369
+ else {
370
+ stmt.left = this.visitPattern(stmt.left);
371
+ }
372
+ stmt.right = this.visitExpression(stmt.right);
373
+ stmt.body = this.visitStatement(stmt.body);
374
+ return stmt;
375
+ }
376
+ visitEmptyStatement(stmt) {
377
+ return stmt;
378
+ }
379
+ visitDoWhileStatement(stmt) {
380
+ stmt.body = this.visitStatement(stmt.body);
381
+ stmt.test = this.visitExpression(stmt.test);
382
+ return stmt;
383
+ }
384
+ visitDebuggerStatement(stmt) {
385
+ return stmt;
386
+ }
387
+ visitWithStatement(stmt) {
388
+ stmt.object = this.visitExpression(stmt.object);
389
+ stmt.body = this.visitStatement(stmt.body);
390
+ return stmt;
391
+ }
392
+ visitDeclaration(decl) {
393
+ switch (decl.type) {
394
+ case "ClassDeclaration":
395
+ return this.visitClassDeclaration(decl);
396
+ case "FunctionDeclaration":
397
+ return this.visitFunctionDeclaration(decl);
398
+ case "TsEnumDeclaration":
399
+ return this.visitTsEnumDeclaration(decl);
400
+ case "TsInterfaceDeclaration":
401
+ return this.visitTsInterfaceDeclaration(decl);
402
+ case "TsModuleDeclaration":
403
+ return this.visitTsModuleDeclaration(decl);
404
+ case "TsTypeAliasDeclaration":
405
+ return this.visitTsTypeAliasDeclaration(decl);
406
+ case "VariableDeclaration":
407
+ return this.visitVariableDeclaration(decl);
408
+ }
409
+ }
410
+ visitVariableDeclaration(n) {
411
+ n.declarations = this.visitVariableDeclarators(n.declarations);
412
+ return n;
413
+ }
414
+ visitVariableDeclarators(nodes) {
415
+ return nodes.map(this.visitVariableDeclarator.bind(this));
416
+ }
417
+ visitVariableDeclarator(n) {
418
+ n.id = this.visitPattern(n.id);
419
+ n.init = this.visitOptionalExpression(n.init);
420
+ return n;
421
+ }
422
+ visitTsTypeAliasDeclaration(n) {
423
+ n.id = this.visitBindingIdentifier(n.id);
424
+ n.typeAnnotation = this.visitTsType(n.typeAnnotation);
425
+ n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams);
426
+ return n;
427
+ }
428
+ visitTsModuleDeclaration(n) {
429
+ n.id = this.visitTsModuleName(n.id);
430
+ if (n.body) {
431
+ n.body = this.visitTsNamespaceBody(n.body);
432
+ }
433
+ return n;
434
+ }
435
+ visitTsModuleName(n) {
436
+ switch (n.type) {
437
+ case "Identifier":
438
+ return this.visitBindingIdentifier(n);
439
+ case "StringLiteral":
440
+ return this.visitStringLiteral(n);
441
+ }
442
+ }
443
+ visitTsNamespaceBody(n) {
444
+ if (n) {
445
+ switch (n.type) {
446
+ case "TsModuleBlock":
447
+ return this.visitTsModuleBlock(n);
448
+ case "TsNamespaceDeclaration":
449
+ return this.visitTsNamespaceDeclaration(n);
450
+ }
451
+ }
452
+ }
453
+ visitTsNamespaceDeclaration(n) {
454
+ const body = this.visitTsNamespaceBody(n.body);
455
+ if (body) {
456
+ n.body = body;
457
+ }
458
+ n.id = this.visitBindingIdentifier(n.id);
459
+ return n;
460
+ }
461
+ visitTsModuleBlock(n) {
462
+ n.body = this.visitModuleItems(n.body);
463
+ return n;
464
+ }
465
+ visitTsInterfaceDeclaration(n) {
466
+ n.id = this.visitBindingIdentifier(n.id);
467
+ n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams);
468
+ n.extends = this.visitTsExpressionsWithTypeArguments(n.extends);
469
+ n.body = this.visitTsInterfaceBody(n.body);
470
+ return n;
471
+ }
472
+ visitTsInterfaceBody(n) {
473
+ n.body = this.visitTsTypeElements(n.body);
474
+ return n;
475
+ }
476
+ visitTsTypeElements(nodes) {
477
+ return nodes.map(this.visitTsTypeElement.bind(this));
478
+ }
479
+ visitTsTypeElement(n) {
480
+ switch (n.type) {
481
+ case "TsCallSignatureDeclaration":
482
+ return this.visitTsCallSignatureDeclaration(n);
483
+ case "TsConstructSignatureDeclaration":
484
+ return this.visitTsConstructSignatureDeclaration(n);
485
+ case "TsPropertySignature":
486
+ return this.visitTsPropertySignature(n);
487
+ case "TsGetterSignature":
488
+ return this.visitTsGetterSignature(n);
489
+ case "TsSetterSignature":
490
+ return this.visitTsSetterSignature(n);
491
+ case "TsMethodSignature":
492
+ return this.visitTsMethodSignature(n);
493
+ case "TsIndexSignature":
494
+ return this.visitTsIndexSignature(n);
495
+ }
496
+ }
497
+ visitTsCallSignatureDeclaration(n) {
498
+ n.params = this.visitTsFnParameters(n.params);
499
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
500
+ return n;
501
+ }
502
+ visitTsConstructSignatureDeclaration(n) {
503
+ n.params = this.visitTsFnParameters(n.params);
504
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
505
+ return n;
506
+ }
507
+ visitTsPropertySignature(n) {
508
+ n.params = this.visitTsFnParameters(n.params);
509
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
510
+ return n;
511
+ }
512
+ visitTsGetterSignature(n) {
513
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
514
+ return n;
515
+ }
516
+ visitTsSetterSignature(n) {
517
+ n.param = this.visitTsFnParameter(n.param);
518
+ return n;
519
+ }
520
+ visitTsMethodSignature(n) {
521
+ n.params = this.visitTsFnParameters(n.params);
522
+ n.typeAnn = this.visitTsTypeAnnotation(n.typeAnn);
523
+ return n;
524
+ }
525
+ visitTsEnumDeclaration(n) {
526
+ n.id = this.visitIdentifier(n.id);
527
+ n.members = this.visitTsEnumMembers(n.members);
528
+ return n;
529
+ }
530
+ visitTsEnumMembers(nodes) {
531
+ return nodes.map(this.visitTsEnumMember.bind(this));
532
+ }
533
+ visitTsEnumMember(n) {
534
+ n.id = this.visitTsEnumMemberId(n.id);
535
+ n.init = this.visitOptionalExpression(n.init);
536
+ return n;
537
+ }
538
+ visitTsEnumMemberId(n) {
539
+ switch (n.type) {
540
+ case "Identifier":
541
+ return this.visitBindingIdentifier(n);
542
+ case "StringLiteral":
543
+ return this.visitStringLiteral(n);
544
+ }
545
+ }
546
+ visitFunctionDeclaration(decl) {
547
+ decl.identifier = this.visitIdentifier(decl.identifier);
548
+ decl = this.visitFunction(decl);
549
+ return decl;
550
+ }
551
+ visitClassDeclaration(decl) {
552
+ decl = this.visitClass(decl);
553
+ decl.identifier = this.visitIdentifier(decl.identifier);
554
+ return decl;
555
+ }
556
+ visitClassBody(members) {
557
+ return members.map(this.visitClassMember.bind(this));
558
+ }
559
+ visitClassMember(member) {
560
+ switch (member.type) {
561
+ case "ClassMethod":
562
+ return this.visitClassMethod(member);
563
+ case "ClassProperty":
564
+ return this.visitClassProperty(member);
565
+ case "Constructor":
566
+ return this.visitConstructor(member);
567
+ case "PrivateMethod":
568
+ return this.visitPrivateMethod(member);
569
+ case "PrivateProperty":
570
+ return this.visitPrivateProperty(member);
571
+ case "TsIndexSignature":
572
+ return this.visitTsIndexSignature(member);
573
+ case "EmptyStatement":
574
+ return this.visitEmptyStatement(member);
575
+ case "StaticBlock":
576
+ return this.visitStaticBlock(member);
577
+ }
578
+ }
579
+ visitTsIndexSignature(n) {
580
+ n.params = this.visitTsFnParameters(n.params);
581
+ if (n.typeAnnotation)
582
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
583
+ return n;
584
+ }
585
+ visitTsFnParameters(params) {
586
+ return params.map(this.visitTsFnParameter.bind(this));
587
+ }
588
+ visitTsFnParameter(n) {
589
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
590
+ return n;
591
+ }
592
+ visitPrivateProperty(n) {
593
+ n.decorators = this.visitDecorators(n.decorators);
594
+ n.key = this.visitPrivateName(n.key);
595
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
596
+ n.value = this.visitOptionalExpression(n.value);
597
+ return n;
598
+ }
599
+ visitPrivateMethod(n) {
600
+ n.accessibility = this.visitAccessibility(n.accessibility);
601
+ n.function = this.visitFunction(n.function);
602
+ n.key = this.visitPrivateName(n.key);
603
+ return n;
604
+ }
605
+ visitPrivateName(n) {
606
+ return n;
607
+ }
608
+ visitConstructor(n) {
609
+ n.accessibility = this.visitAccessibility(n.accessibility);
610
+ n.key = this.visitPropertyName(n.key);
611
+ n.params = this.visitConstructorParameters(n.params);
612
+ if (n.body) {
613
+ n.body = this.visitBlockStatement(n.body);
614
+ }
615
+ return n;
616
+ }
617
+ visitConstructorParameters(nodes) {
618
+ return nodes.map(this.visitConstructorParameter.bind(this));
619
+ }
620
+ visitConstructorParameter(n) {
621
+ switch (n.type) {
622
+ case "TsParameterProperty":
623
+ return this.visitTsParameterProperty(n);
624
+ default:
625
+ return this.visitParameter(n);
626
+ }
627
+ }
628
+ visitStaticBlock(n) {
629
+ n.body = this.visitBlockStatement(n.body);
630
+ return n;
631
+ }
632
+ visitTsParameterProperty(n) {
633
+ n.accessibility = this.visitAccessibility(n.accessibility);
634
+ n.decorators = this.visitDecorators(n.decorators);
635
+ n.param = this.visitTsParameterPropertyParameter(n.param);
636
+ return n;
637
+ }
638
+ visitTsParameterPropertyParameter(n) {
639
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
640
+ return n;
641
+ }
642
+ visitPropertyName(key) {
643
+ switch (key.type) {
644
+ case "Identifier":
645
+ return this.visitBindingIdentifier(key);
646
+ case "StringLiteral":
647
+ return this.visitStringLiteral(key);
648
+ case "NumericLiteral":
649
+ return this.visitNumericLiteral(key);
650
+ case "BigIntLiteral":
651
+ return this.visitBigIntLiteral(key);
652
+ default:
653
+ return this.visitComputedPropertyKey(key);
654
+ }
655
+ }
656
+ visitAccessibility(n) {
657
+ return n;
658
+ }
659
+ visitClassProperty(n) {
660
+ n.accessibility = this.visitAccessibility(n.accessibility);
661
+ n.decorators = this.visitDecorators(n.decorators);
662
+ n.key = this.visitPropertyName(n.key);
663
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
664
+ n.value = this.visitOptionalExpression(n.value);
665
+ return n;
666
+ }
667
+ visitClassMethod(n) {
668
+ n.accessibility = this.visitAccessibility(n.accessibility);
669
+ n.function = this.visitFunction(n.function);
670
+ n.key = this.visitPropertyName(n.key);
671
+ return n;
672
+ }
673
+ visitComputedPropertyKey(n) {
674
+ n.expression = this.visitExpression(n.expression);
675
+ return n;
676
+ }
677
+ visitClass(n) {
678
+ n.decorators = this.visitDecorators(n.decorators);
679
+ n.superClass = this.visitOptionalExpression(n.superClass);
680
+ n.superTypeParams = this.visitTsTypeParameterInstantiation(n.superTypeParams);
681
+ if (n.implements) {
682
+ n.implements = this.visitTsExpressionsWithTypeArguments(n.implements);
683
+ }
684
+ n.body = this.visitClassBody(n.body);
685
+ return n;
686
+ }
687
+ visitFunction(n) {
688
+ n.decorators = this.visitDecorators(n.decorators);
689
+ n.params = this.visitParameters(n.params);
690
+ if (n.body) {
691
+ n.body = this.visitBlockStatement(n.body);
692
+ }
693
+ n.returnType = this.visitTsTypeAnnotation(n.returnType);
694
+ n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters);
695
+ return n;
696
+ }
697
+ visitTsExpressionsWithTypeArguments(nodes) {
698
+ return nodes.map(this.visitTsExpressionWithTypeArguments.bind(this));
699
+ }
700
+ visitTsExpressionWithTypeArguments(n) {
701
+ n.expression = this.visitExpression(n.expression);
702
+ n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
703
+ return n;
704
+ }
705
+ visitTsTypeParameterInstantiation(n) {
706
+ if (n) {
707
+ n.params = this.visitTsTypes(n.params);
708
+ }
709
+ return n;
710
+ }
711
+ visitTsTypes(nodes) {
712
+ return nodes.map(this.visitTsType.bind(this));
713
+ }
714
+ visitTsEntityName(n) {
715
+ switch (n.type) {
716
+ case "Identifier":
717
+ return this.visitBindingIdentifier(n);
718
+ case "TsQualifiedName":
719
+ return this.visitTsQualifiedName(n);
720
+ }
721
+ }
722
+ visitTsQualifiedName(n) {
723
+ n.left = this.visitTsEntityName(n.left);
724
+ n.right = this.visitIdentifier(n.right);
725
+ return n;
726
+ }
727
+ visitDecorators(nodes) {
728
+ if (nodes) {
729
+ return nodes.map(this.visitDecorator.bind(this));
730
+ }
731
+ }
732
+ visitDecorator(n) {
733
+ n.expression = this.visitExpression(n.expression);
734
+ return n;
735
+ }
736
+ visitExpressionStatement(stmt) {
737
+ stmt.expression = this.visitExpression(stmt.expression);
738
+ return stmt;
739
+ }
740
+ visitContinueStatement(stmt) {
741
+ if (stmt.label) {
742
+ stmt.label = this.visitLabelIdentifier(stmt.label);
743
+ }
744
+ return stmt;
745
+ }
746
+ visitExpression(n) {
747
+ switch (n.type) {
748
+ case "ArrayExpression":
749
+ return this.visitArrayExpression(n);
750
+ case "ArrowFunctionExpression":
751
+ return this.visitArrowFunctionExpression(n);
752
+ case "AssignmentExpression":
753
+ return this.visitAssignmentExpression(n);
754
+ case "AwaitExpression":
755
+ return this.visitAwaitExpression(n);
756
+ case "BigIntLiteral":
757
+ return this.visitBigIntLiteral(n);
758
+ case "BinaryExpression":
759
+ return this.visitBinaryExpression(n);
760
+ case "BooleanLiteral":
761
+ return this.visitBooleanLiteral(n);
762
+ case "CallExpression":
763
+ return this.visitCallExpression(n);
764
+ case "ClassExpression":
765
+ return this.visitClassExpression(n);
766
+ case "ConditionalExpression":
767
+ return this.visitConditionalExpression(n);
768
+ case "FunctionExpression":
769
+ return this.visitFunctionExpression(n);
770
+ case "Identifier":
771
+ return this.visitIdentifierReference(n);
772
+ case "JSXElement":
773
+ return this.visitJSXElement(n);
774
+ case "JSXEmptyExpression":
775
+ return this.visitJSXEmptyExpression(n);
776
+ case "JSXFragment":
777
+ return this.visitJSXFragment(n);
778
+ case "JSXMemberExpression":
779
+ return this.visitJSXMemberExpression(n);
780
+ case "JSXNamespacedName":
781
+ return this.visitJSXNamespacedName(n);
782
+ case "JSXText":
783
+ return this.visitJSXText(n);
784
+ case "MemberExpression":
785
+ return this.visitMemberExpression(n);
786
+ case "SuperPropExpression":
787
+ return this.visitSuperPropExpression(n);
788
+ case "MetaProperty":
789
+ return this.visitMetaProperty(n);
790
+ case "NewExpression":
791
+ return this.visitNewExpression(n);
792
+ case "NullLiteral":
793
+ return this.visitNullLiteral(n);
794
+ case "NumericLiteral":
795
+ return this.visitNumericLiteral(n);
796
+ case "ObjectExpression":
797
+ return this.visitObjectExpression(n);
798
+ case "ParenthesisExpression":
799
+ return this.visitParenthesisExpression(n);
800
+ case "PrivateName":
801
+ return this.visitPrivateName(n);
802
+ case "RegExpLiteral":
803
+ return this.visitRegExpLiteral(n);
804
+ case "SequenceExpression":
805
+ return this.visitSequenceExpression(n);
806
+ case "StringLiteral":
807
+ return this.visitStringLiteral(n);
808
+ case "TaggedTemplateExpression":
809
+ return this.visitTaggedTemplateExpression(n);
810
+ case "TemplateLiteral":
811
+ return this.visitTemplateLiteral(n);
812
+ case "ThisExpression":
813
+ return this.visitThisExpression(n);
814
+ case "TsAsExpression":
815
+ return this.visitTsAsExpression(n);
816
+ case "TsNonNullExpression":
817
+ return this.visitTsNonNullExpression(n);
818
+ case "TsTypeAssertion":
819
+ return this.visitTsTypeAssertion(n);
820
+ case "TsConstAssertion":
821
+ return this.visitTsConstAssertion(n);
822
+ case "TsInstantiation":
823
+ return this.visitTsInstantiation(n);
824
+ case "UnaryExpression":
825
+ return this.visitUnaryExpression(n);
826
+ case "UpdateExpression":
827
+ return this.visitUpdateExpression(n);
828
+ case "YieldExpression":
829
+ return this.visitYieldExpression(n);
830
+ case "OptionalChainingExpression":
831
+ return this.visitOptionalChainingExpression(n);
832
+ case "Invalid":
833
+ return n;
834
+ }
835
+ }
836
+ visitOptionalChainingExpression(n) {
837
+ n.base = this.visitMemberExpressionOrOptionalChainingCall(n.base);
838
+ return n;
839
+ }
840
+ visitMemberExpressionOrOptionalChainingCall(n) {
841
+ switch (n.type) {
842
+ case "MemberExpression":
843
+ return this.visitMemberExpression(n);
844
+ case "CallExpression":
845
+ return this.visitOptionalChainingCall(n);
846
+ }
847
+ }
848
+ visitOptionalChainingCall(n) {
849
+ n.callee = this.visitExpression(n.callee);
850
+ n.arguments = this.visitExprOrSpreads(n.arguments);
851
+ if (n.typeArguments)
852
+ n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
853
+ return n;
854
+ }
855
+ visitAssignmentExpression(n) {
856
+ n.left = this.visitPatternOrExpression(n.left);
857
+ n.right = this.visitExpression(n.right);
858
+ return n;
859
+ }
860
+ visitPatternOrExpression(n) {
861
+ switch (n.type) {
862
+ case "ObjectPattern":
863
+ case "ArrayPattern":
864
+ case "Identifier":
865
+ case "AssignmentPattern":
866
+ case "RestElement":
867
+ return this.visitPattern(n);
868
+ default:
869
+ return this.visitExpression(n);
870
+ }
871
+ }
872
+ visitYieldExpression(n) {
873
+ n.argument = this.visitOptionalExpression(n.argument);
874
+ return n;
875
+ }
876
+ visitUpdateExpression(n) {
877
+ n.argument = this.visitExpression(n.argument);
878
+ return n;
879
+ }
880
+ visitUnaryExpression(n) {
881
+ n.argument = this.visitExpression(n.argument);
882
+ return n;
883
+ }
884
+ visitTsTypeAssertion(n) {
885
+ n.expression = this.visitExpression(n.expression);
886
+ n.typeAnnotation = this.visitTsType(n.typeAnnotation);
887
+ return n;
888
+ }
889
+ visitTsConstAssertion(n) {
890
+ n.expression = this.visitExpression(n.expression);
891
+ return n;
892
+ }
893
+ visitTsInstantiation(n) {
894
+ n.expression = this.visitExpression(n.expression);
895
+ return n;
896
+ }
897
+ visitTsNonNullExpression(n) {
898
+ n.expression = this.visitExpression(n.expression);
899
+ return n;
900
+ }
901
+ visitTsAsExpression(n) {
902
+ n.expression = this.visitExpression(n.expression);
903
+ n.typeAnnotation = this.visitTsType(n.typeAnnotation);
904
+ return n;
905
+ }
906
+ visitThisExpression(n) {
907
+ return n;
908
+ }
909
+ visitTemplateLiteral(n) {
910
+ n.expressions = n.expressions.map(this.visitExpression.bind(this));
911
+ return n;
912
+ }
913
+ visitParameters(n) {
914
+ return n.map(this.visitParameter.bind(this));
915
+ }
916
+ visitParameter(n) {
917
+ n.pat = this.visitPattern(n.pat);
918
+ return n;
919
+ }
920
+ visitTaggedTemplateExpression(n) {
921
+ n.tag = this.visitExpression(n.tag);
922
+ const template = this.visitTemplateLiteral(n.template);
923
+ if (template.type === "TemplateLiteral") {
924
+ n.template = template;
925
+ }
926
+ return n;
927
+ }
928
+ visitSequenceExpression(n) {
929
+ n.expressions = n.expressions.map(this.visitExpression.bind(this));
930
+ return n;
931
+ }
932
+ visitRegExpLiteral(n) {
933
+ return n;
934
+ }
935
+ visitParenthesisExpression(n) {
936
+ n.expression = this.visitExpression(n.expression);
937
+ return n;
938
+ }
939
+ visitObjectExpression(n) {
940
+ if (n.properties) {
941
+ n.properties = this.visitObjectProperties(n.properties);
942
+ }
943
+ return n;
944
+ }
945
+ visitObjectProperties(nodes) {
946
+ return nodes.map(this.visitObjectProperty.bind(this));
947
+ }
948
+ visitObjectProperty(n) {
949
+ switch (n.type) {
950
+ case "SpreadElement":
951
+ return this.visitSpreadElement(n);
952
+ default:
953
+ return this.visitProperty(n);
954
+ }
955
+ }
956
+ visitProperty(n) {
957
+ switch (n.type) {
958
+ case "Identifier":
959
+ return this.visitIdentifier(n);
960
+ case "AssignmentProperty":
961
+ return this.visitAssignmentProperty(n);
962
+ case "GetterProperty":
963
+ return this.visitGetterProperty(n);
964
+ case "KeyValueProperty":
965
+ return this.visitKeyValueProperty(n);
966
+ case "MethodProperty":
967
+ return this.visitMethodProperty(n);
968
+ case "SetterProperty":
969
+ return this.visitSetterProperty(n);
970
+ }
971
+ }
972
+ visitSetterProperty(n) {
973
+ n.key = this.visitPropertyName(n.key);
974
+ n.param = this.visitPattern(n.param);
975
+ if (n.body) {
976
+ n.body = this.visitBlockStatement(n.body);
977
+ }
978
+ return n;
979
+ }
980
+ visitMethodProperty(n) {
981
+ n.key = this.visitPropertyName(n.key);
982
+ if (n.body) {
983
+ n.body = this.visitBlockStatement(n.body);
984
+ }
985
+ n.decorators = this.visitDecorators(n.decorators);
986
+ n.params = this.visitParameters(n.params);
987
+ n.returnType = this.visitTsTypeAnnotation(n.returnType);
988
+ n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters);
989
+ return n;
990
+ }
991
+ visitKeyValueProperty(n) {
992
+ n.key = this.visitPropertyName(n.key);
993
+ n.value = this.visitExpression(n.value);
994
+ return n;
995
+ }
996
+ visitGetterProperty(n) {
997
+ n.key = this.visitPropertyName(n.key);
998
+ if (n.body) {
999
+ n.body = this.visitBlockStatement(n.body);
1000
+ }
1001
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1002
+ return n;
1003
+ }
1004
+ visitAssignmentProperty(n) {
1005
+ n.key = this.visitIdentifier(n.key);
1006
+ n.value = this.visitExpression(n.value);
1007
+ return n;
1008
+ }
1009
+ visitNullLiteral(n) {
1010
+ return n;
1011
+ }
1012
+ visitNewExpression(n) {
1013
+ n.callee = this.visitExpression(n.callee);
1014
+ if (n.arguments) {
1015
+ n.arguments = this.visitArguments(n.arguments);
1016
+ }
1017
+ n.typeArguments = this.visitTsTypeArguments(n.typeArguments);
1018
+ return n;
1019
+ }
1020
+ visitTsTypeArguments(n) {
1021
+ if (n) {
1022
+ n.params = this.visitTsTypes(n.params);
1023
+ }
1024
+ return n;
1025
+ }
1026
+ visitArguments(nodes) {
1027
+ return nodes.map(this.visitArgument.bind(this));
1028
+ }
1029
+ visitArgument(n) {
1030
+ n.expression = this.visitExpression(n.expression);
1031
+ return n;
1032
+ }
1033
+ visitMetaProperty(n) {
1034
+ return n;
1035
+ }
1036
+ visitMemberExpression(n) {
1037
+ n.object = this.visitExpression(n.object);
1038
+ switch (n.property.type) {
1039
+ case 'Computed': {
1040
+ n.property = this.visitComputedPropertyKey(n.property);
1041
+ return n;
1042
+ }
1043
+ case 'Identifier': {
1044
+ n.property = this.visitIdentifier(n.property);
1045
+ return n;
1046
+ }
1047
+ case 'PrivateName': {
1048
+ n.property = this.visitPrivateName(n.property);
1049
+ return n;
1050
+ }
1051
+ }
1052
+ }
1053
+ visitSuperPropExpression(n) {
1054
+ switch (n.property.type) {
1055
+ case 'Computed': {
1056
+ n.property = this.visitComputedPropertyKey(n.property);
1057
+ return n;
1058
+ }
1059
+ case 'Identifier': {
1060
+ n.property = this.visitIdentifier(n.property);
1061
+ return n;
1062
+ }
1063
+ }
1064
+ }
1065
+ visitCallee(n) {
1066
+ if (n.type === "Super" || n.type === "Import") {
1067
+ return n;
1068
+ }
1069
+ return this.visitExpression(n);
1070
+ }
1071
+ visitJSXText(n) {
1072
+ return n;
1073
+ }
1074
+ visitJSXNamespacedName(n) {
1075
+ n.namespace = this.visitIdentifierReference(n.namespace);
1076
+ n.name = this.visitIdentifierReference(n.name);
1077
+ return n;
1078
+ }
1079
+ visitJSXMemberExpression(n) {
1080
+ n.object = this.visitJSXObject(n.object);
1081
+ n.property = this.visitIdentifierReference(n.property);
1082
+ return n;
1083
+ }
1084
+ visitJSXObject(n) {
1085
+ switch (n.type) {
1086
+ case "Identifier":
1087
+ return this.visitIdentifierReference(n);
1088
+ case "JSXMemberExpression":
1089
+ return this.visitJSXMemberExpression(n);
1090
+ }
1091
+ }
1092
+ visitJSXFragment(n) {
1093
+ n.opening = this.visitJSXOpeningFragment(n.opening);
1094
+ if (n.children) {
1095
+ n.children = this.visitJSXElementChildren(n.children);
1096
+ }
1097
+ n.closing = this.visitJSXClosingFragment(n.closing);
1098
+ return n;
1099
+ }
1100
+ visitJSXClosingFragment(n) {
1101
+ return n;
1102
+ }
1103
+ visitJSXElementChildren(nodes) {
1104
+ return nodes.map(this.visitJSXElementChild.bind(this));
1105
+ }
1106
+ visitJSXElementChild(n) {
1107
+ switch (n.type) {
1108
+ case "JSXElement":
1109
+ return this.visitJSXElement(n);
1110
+ case "JSXExpressionContainer":
1111
+ return this.visitJSXExpressionContainer(n);
1112
+ case "JSXFragment":
1113
+ return this.visitJSXFragment(n);
1114
+ case "JSXSpreadChild":
1115
+ return this.visitJSXSpreadChild(n);
1116
+ case "JSXText":
1117
+ return this.visitJSXText(n);
1118
+ }
1119
+ }
1120
+ visitJSXExpressionContainer(n) {
1121
+ n.expression = this.visitExpression(n.expression);
1122
+ return n;
1123
+ }
1124
+ visitJSXSpreadChild(n) {
1125
+ n.expression = this.visitExpression(n.expression);
1126
+ return n;
1127
+ }
1128
+ visitJSXOpeningFragment(n) {
1129
+ return n;
1130
+ }
1131
+ visitJSXEmptyExpression(n) {
1132
+ return n;
1133
+ }
1134
+ visitJSXElement(n) {
1135
+ n.opening = this.visitJSXOpeningElement(n.opening);
1136
+ n.children = this.visitJSXElementChildren(n.children);
1137
+ n.closing = this.visitJSXClosingElement(n.closing);
1138
+ return n;
1139
+ }
1140
+ visitJSXClosingElement(n) {
1141
+ if (n) {
1142
+ n.name = this.visitJSXElementName(n.name);
1143
+ }
1144
+ return n;
1145
+ }
1146
+ visitJSXElementName(n) {
1147
+ switch (n.type) {
1148
+ case "Identifier":
1149
+ return this.visitIdentifierReference(n);
1150
+ case "JSXMemberExpression":
1151
+ return this.visitJSXMemberExpression(n);
1152
+ case "JSXNamespacedName":
1153
+ return this.visitJSXNamespacedName(n);
1154
+ }
1155
+ }
1156
+ visitJSXOpeningElement(n) {
1157
+ n.name = this.visitJSXElementName(n.name);
1158
+ n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
1159
+ n.attributes = this.visitJSXAttributeOrSpreads(n.attributes);
1160
+ return n;
1161
+ }
1162
+ visitJSXAttributes(attrs) {
1163
+ if (attrs)
1164
+ return attrs.map(this.visitJSXAttributeOrSpread.bind(this));
1165
+ }
1166
+ visitJSXAttributeOrSpread(n) {
1167
+ switch (n.type) {
1168
+ case "JSXAttribute":
1169
+ return this.visitJSXAttribute(n);
1170
+ case "SpreadElement":
1171
+ return this.visitSpreadElement(n);
1172
+ }
1173
+ }
1174
+ visitJSXAttributeOrSpreads(nodes) {
1175
+ return nodes.map(this.visitJSXAttributeOrSpread.bind(this));
1176
+ }
1177
+ visitJSXAttribute(n) {
1178
+ n.name = this.visitJSXAttributeName(n.name);
1179
+ n.value = this.visitJSXAttributeValue(n.value);
1180
+ return n;
1181
+ }
1182
+ visitJSXAttributeValue(n) {
1183
+ if (!n)
1184
+ return n;
1185
+ switch (n.type) {
1186
+ case "BooleanLiteral":
1187
+ return this.visitBooleanLiteral(n);
1188
+ case "NullLiteral":
1189
+ return this.visitNullLiteral(n);
1190
+ case "NumericLiteral":
1191
+ return this.visitNumericLiteral(n);
1192
+ case "JSXText":
1193
+ return this.visitJSXText(n);
1194
+ case "StringLiteral":
1195
+ return this.visitStringLiteral(n);
1196
+ case "JSXElement":
1197
+ return this.visitJSXElement(n);
1198
+ case "JSXExpressionContainer":
1199
+ return this.visitJSXExpressionContainer(n);
1200
+ case "JSXFragment":
1201
+ return this.visitJSXFragment(n);
1202
+ }
1203
+ return n;
1204
+ }
1205
+ visitJSXAttributeName(n) {
1206
+ switch (n.type) {
1207
+ case "Identifier":
1208
+ return this.visitIdentifierReference(n);
1209
+ case "JSXNamespacedName":
1210
+ return this.visitJSXNamespacedName(n);
1211
+ }
1212
+ }
1213
+ visitConditionalExpression(n) {
1214
+ n.test = this.visitExpression(n.test);
1215
+ n.consequent = this.visitExpression(n.consequent);
1216
+ n.alternate = this.visitExpression(n.alternate);
1217
+ return n;
1218
+ }
1219
+ visitCallExpression(n) {
1220
+ n.callee = this.visitCallee(n.callee);
1221
+ n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
1222
+ if (n.arguments) {
1223
+ n.arguments = this.visitArguments(n.arguments);
1224
+ }
1225
+ return n;
1226
+ }
1227
+ visitBooleanLiteral(n) {
1228
+ return n;
1229
+ }
1230
+ visitBinaryExpression(n) {
1231
+ n.left = this.visitExpression(n.left);
1232
+ n.right = this.visitExpression(n.right);
1233
+ return n;
1234
+ }
1235
+ visitAwaitExpression(n) {
1236
+ n.argument = this.visitExpression(n.argument);
1237
+ return n;
1238
+ }
1239
+ visitTsTypeParameterDeclaration(n) {
1240
+ if (n) {
1241
+ n.parameters = this.visitTsTypeParameters(n.parameters);
1242
+ }
1243
+ return n;
1244
+ }
1245
+ visitTsTypeParameters(nodes) {
1246
+ return nodes.map(this.visitTsTypeParameter.bind(this));
1247
+ }
1248
+ visitTsTypeParameter(n) {
1249
+ if (n.constraint) {
1250
+ n.constraint = this.visitTsType(n.constraint);
1251
+ }
1252
+ if (n.default) {
1253
+ n.default = this.visitTsType(n.default);
1254
+ }
1255
+ n.name = this.visitIdentifierReference(n.name);
1256
+ return n;
1257
+ }
1258
+ visitTsTypeAnnotation(a) {
1259
+ if (a) {
1260
+ a.typeAnnotation = this.visitTsType(a.typeAnnotation);
1261
+ }
1262
+ return a;
1263
+ }
1264
+ visitTsType(n) {
1265
+ throw new Error("Method visitTsType not implemented.");
1266
+ }
1267
+ visitPatterns(nodes) {
1268
+ return nodes.map(this.visitPattern.bind(this));
1269
+ }
1270
+ visitImportDeclaration(n) {
1271
+ n.source = this.visitStringLiteral(n.source);
1272
+ n.specifiers = this.visitImportSpecifiers(n.specifiers || []);
1273
+ return n;
1274
+ }
1275
+ visitImportSpecifiers(nodes) {
1276
+ return nodes.map(this.visitImportSpecifier.bind(this));
1277
+ }
1278
+ visitImportSpecifier(node) {
1279
+ switch (node.type) {
1280
+ case "ImportDefaultSpecifier":
1281
+ return this.visitImportDefaultSpecifier(node);
1282
+ case "ImportNamespaceSpecifier":
1283
+ return this.visitImportNamespaceSpecifier(node);
1284
+ case "ImportSpecifier":
1285
+ return this.visitNamedImportSpecifier(node);
1286
+ }
1287
+ }
1288
+ visitNamedImportSpecifier(node) {
1289
+ node.local = this.visitBindingIdentifier(node.local);
1290
+ if (node.imported) {
1291
+ node.imported = this.visitModuleExportName(node.imported);
1292
+ }
1293
+ return node;
1294
+ }
1295
+ visitImportNamespaceSpecifier(node) {
1296
+ node.local = this.visitBindingIdentifier(node.local);
1297
+ return node;
1298
+ }
1299
+ visitImportDefaultSpecifier(node) {
1300
+ node.local = this.visitBindingIdentifier(node.local);
1301
+ return node;
1302
+ }
1303
+ visitBindingIdentifier(i) {
1304
+ return this.visitIdentifier(i);
1305
+ }
1306
+ visitIdentifierReference(i) {
1307
+ return this.visitIdentifier(i);
1308
+ }
1309
+ visitLabelIdentifier(label) {
1310
+ return this.visitIdentifier(label);
1311
+ }
1312
+ visitIdentifier(n) {
1313
+ return n;
1314
+ }
1315
+ visitStringLiteral(n) {
1316
+ return n;
1317
+ }
1318
+ visitNumericLiteral(n) {
1319
+ return n;
1320
+ }
1321
+ visitBigIntLiteral(n) {
1322
+ return n;
1323
+ }
1324
+ visitPattern(n) {
1325
+ switch (n.type) {
1326
+ case "Identifier":
1327
+ return this.visitBindingIdentifier(n);
1328
+ case "ArrayPattern":
1329
+ return this.visitArrayPattern(n);
1330
+ case "ObjectPattern":
1331
+ return this.visitObjectPattern(n);
1332
+ case "AssignmentPattern":
1333
+ return this.visitAssignmentPattern(n);
1334
+ case "RestElement":
1335
+ return this.visitRestElement(n);
1336
+ default:
1337
+ return this.visitExpression(n);
1338
+ }
1339
+ }
1340
+ visitRestElement(n) {
1341
+ n.argument = this.visitPattern(n.argument);
1342
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1343
+ return n;
1344
+ }
1345
+ visitAssignmentPattern(n) {
1346
+ n.left = this.visitPattern(n.left);
1347
+ n.right = this.visitExpression(n.right);
1348
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1349
+ return n;
1350
+ }
1351
+ visitObjectPattern(n) {
1352
+ n.properties = this.visitObjectPatternProperties(n.properties || []);
1353
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1354
+ return n;
1355
+ }
1356
+ visitObjectPatternProperties(nodes) {
1357
+ return nodes.map(this.visitObjectPatternProperty.bind(this));
1358
+ }
1359
+ visitObjectPatternProperty(n) {
1360
+ switch (n.type) {
1361
+ case "AssignmentPatternProperty":
1362
+ return this.visitAssignmentPatternProperty(n);
1363
+ case "KeyValuePatternProperty":
1364
+ return this.visitKeyValuePatternProperty(n);
1365
+ case "RestElement":
1366
+ return this.visitRestElement(n);
1367
+ }
1368
+ }
1369
+ visitKeyValuePatternProperty(n) {
1370
+ n.key = this.visitPropertyName(n.key);
1371
+ n.value = this.visitPattern(n.value);
1372
+ return n;
1373
+ }
1374
+ visitAssignmentPatternProperty(n) {
1375
+ n.key = this.visitBindingIdentifier(n.key);
1376
+ n.value = this.visitOptionalExpression(n.value);
1377
+ return n;
1378
+ }
1379
+ visitArrayPattern(n) {
1380
+ n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1381
+ n.elements = this.visitArrayPatternElements(n.elements);
1382
+ return n;
1383
+ }
1384
+ visitArrayPatternElements(nodes) {
1385
+ return nodes.map(this.visitArrayPatternElement.bind(this));
1386
+ }
1387
+ visitArrayPatternElement(n) {
1388
+ if (n) {
1389
+ n = this.visitPattern(n);
1390
+ }
1391
+ return n;
1392
+ }
1393
+ }
1394
+ exports.Visitor = Visitor;
1395
+ exports.default = Visitor;