@idlizer/arktscgen 2.1.10-arktscgen-5 → 2.1.10-arktscgen-7

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.
Files changed (51) hide show
  1. package/build/libarkts-copy/generator/options.json5 +24 -47
  2. package/build/libarkts-copy/native/meson.build +29 -13
  3. package/build/libarkts-copy/native/meson_options.txt +9 -3
  4. package/build/libarkts-copy/native/mingw.cross +2 -0
  5. package/build/libarkts-copy/native/src/{bridges.cc → bridges.cpp} +31 -92
  6. package/build/libarkts-copy/native/src/{common.cc → common.cpp} +240 -107
  7. package/build/libarkts-copy/native/src/common.h +22 -22
  8. package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +45 -32
  9. package/build/libarkts-copy/package.json +13 -11
  10. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +10 -63
  11. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +9 -3
  12. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +10 -7
  13. package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +14 -5
  14. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +19 -1
  15. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
  16. package/build/libarkts-copy/src/arkts-api/index.ts +0 -2
  17. package/build/libarkts-copy/src/arkts-api/node-cache.ts +12 -3
  18. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
  19. package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
  20. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +4 -4
  21. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +0 -16
  22. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +1 -1
  23. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +9 -9
  24. package/build/libarkts-copy/src/arkts-api/plugins.ts +113 -15
  25. package/build/libarkts-copy/src/arkts-api/static/global.ts +1 -4
  26. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +5 -5
  27. package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +2 -1
  28. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +11 -43
  29. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +41 -9
  30. package/build/libarkts-copy/src/arkts-api/visitor.ts +4 -25
  31. package/build/libarkts-copy/src/checkSdk.ts +1 -1
  32. package/build/libarkts-copy/src/index.ts +1 -2
  33. package/build/libarkts-copy/src/memo-node-cache.ts +143 -0
  34. package/build/libarkts-copy/src/plugin-utils.ts +72 -40
  35. package/build/libarkts-copy/src/reexport-for-generated.ts +3 -1
  36. package/build/libarkts-copy/src/tracer.ts +2 -2
  37. package/build/libarkts-copy/src/utils.ts +10 -14
  38. package/build/libarkts-copy/tsconfig.json +0 -3
  39. package/lib/index.js +5517 -10446
  40. package/package.json +9 -7
  41. package/templates/{bridges.cc → bridges.cpp} +1 -1
  42. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
  43. package/build/libarkts-copy/src/arkts-api/peers/DiagnosticKind.ts +0 -23
  44. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
  45. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
  46. package/build/libarkts-copy/src/ts-api/index.ts +0 -27
  47. package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
  48. package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
  49. package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
  50. package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
  51. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
@@ -1,1250 +0,0 @@
1
- /*
2
- * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { throwError } from '../../utils';
17
- import * as ts from '@koalaui/ets-tsc';
18
- import * as arkts from '../../arkts-api';
19
-
20
- import {
21
- passNode,
22
- passNodeArray,
23
- passToken,
24
- passModifiersToScriptFunction,
25
- passModifiers,
26
- passIdentifier,
27
- passTypeParams,
28
- passVariableDeclarationKind,
29
- } from '../utilities/private';
30
- import { SyntaxKind, NodeFlags } from '../static/enums';
31
- import {
32
- Es2pandaContextState,
33
- Es2pandaPrimitiveType,
34
- Es2pandaMethodDefinitionKind,
35
- Es2pandaModifierFlags,
36
- Es2pandaScriptFunctionFlags,
37
- Es2pandaMemberExpressionKind,
38
- Es2pandaClassDefinitionModifiers,
39
- Es2pandaVariableDeclarationKind,
40
- Es2pandaVariableDeclaratorFlag,
41
- } from '../../arkts-api';
42
- import {
43
- // ts types:
44
- Modifier,
45
- BinaryOperatorToken,
46
- Node,
47
- Token,
48
- Identifier,
49
- StringLiteral,
50
- FunctionDeclaration,
51
- Block,
52
- KeywordTypeNode,
53
- PropertyAccessExpression,
54
- ParameterDeclaration,
55
- ReturnStatement,
56
- IfStatement,
57
- ExpressionStatement,
58
- CallExpression,
59
- ArrowFunction,
60
- TypeReferenceNode,
61
- BinaryExpression,
62
- FunctionTypeNode,
63
- TypeNode,
64
- Expression,
65
- Statement,
66
- SourceFile,
67
- ClassElement,
68
- MethodDeclaration,
69
- ConstructorDeclaration,
70
- TypeParameterDeclaration,
71
- NumericLiteral,
72
- ClassDeclaration,
73
- VariableDeclaration,
74
- VariableDeclarationList,
75
- VariableStatement,
76
- UnionTypeNode,
77
- SuperExpression,
78
- ParenthesizedExpression,
79
- ImportDeclaration,
80
- ImportClause,
81
- ImportSpecifier,
82
- } from '../types';
83
-
84
- // Improve: add flags and base
85
- export function createNodeFactory() {
86
- return {
87
- createSourceFile,
88
- updateSourceFile,
89
- createIdentifier,
90
- createStringLiteral,
91
- createNumericLiteral,
92
- createFunctionDeclaration,
93
- updateFunctionDeclaration,
94
- createParameterDeclaration,
95
- updateParameterDeclaration,
96
- createETSTypeReferenceNode,
97
- updateTypeReferenceNode,
98
- createKeywordTypeNode,
99
- createBlock,
100
- updateBlock,
101
- createExpressionStatement,
102
- updateExpressionStatement,
103
- createReturnStatement,
104
- updateReturnStatement,
105
- createPropertyAccessExpression,
106
- updatePropertyAccessExpression,
107
- createCallExpression,
108
- updateCallExpression,
109
- createIfStatement,
110
- updateIfStatement,
111
- createToken,
112
- createBinaryExpression,
113
- updateBinaryExpression,
114
- createArrowFunction,
115
- updateArrowFunction,
116
- createFunctionTypeNode,
117
- updateFunctionTypeNode,
118
- createMethodDeclaration,
119
- updateMethodDeclaration,
120
- createConstructorDeclaration,
121
- updateConstructorDeclaration,
122
- createTypeParameterDeclaration,
123
- updateTypeParameterDeclaration,
124
- createClassDeclaration,
125
- updateClassDeclaration,
126
- createVariableDeclarationList,
127
- updateVariableDeclarationList,
128
- createVariableStatement,
129
- updateVariableStatement,
130
- createVariableDeclaration,
131
- updateVariableDeclaration,
132
- createETSUnionTypeNode,
133
- updateETSUnionTypeNode,
134
- createSuper,
135
- updateSuper,
136
- createParenthesizedExpression,
137
- updateParenthesizedExpression,
138
- // createImportDeclaration,
139
- createImportSpecifier,
140
- };
141
-
142
- // @api
143
- // function createSourceFile(
144
- // statements: readonly Statement[],
145
- // endOfFileToken: EndOfFileToken,
146
- // flags: NodeFlags,
147
- // ): SourceFile;
148
- function createSourceFile(
149
- source: string,
150
- state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED
151
- ): SourceFile {
152
- const node = arkts.EtsScript.createFromSource(source, state);
153
- return new SourceFile(node);
154
- }
155
-
156
- // Improve: fix (now doesn't create a new node)
157
- // @api
158
- // updateSourceFile(
159
- // node: SourceFile,
160
- // statements: readonly Statement[],
161
- // isDeclarationFile?: boolean,
162
- // referencedFiles?: readonly FileReference[],
163
- // typeReferences?: readonly FileReference[],
164
- // hasNoDefaultLib?: boolean,
165
- // libReferences?: readonly FileReference[]
166
- // ): SourceFile;
167
- function updateSourceFile(node: SourceFile, statements: readonly Statement[]): SourceFile {
168
- return new SourceFile(arkts.EtsScript.updateByStatements(node.node, passNodeArray(statements)));
169
- }
170
-
171
- // @api
172
- // createIdentifier(
173
- // text: string
174
- // ): Identifier;
175
- function createIdentifier(text: string, typeAnnotation?: TypeNode | undefined): Identifier {
176
- return new Identifier(arkts.factory.createIdentifier(text, passNode(typeAnnotation)));
177
- }
178
-
179
- // @api
180
- // createStringLiteral(
181
- // text: string,
182
- // isSingleQuote?: boolean
183
- // ): StringLiteral;
184
- function createStringLiteral(str: string): StringLiteral {
185
- return new StringLiteral(arkts.factory.createStringLiteral(str));
186
- }
187
-
188
- // @api
189
- // createNumericLiteral(
190
- // value: string | number,
191
- // numericLiteralFlags: TokenFlags = TokenFlags.None
192
- // ): NumericLiteral {
193
- function createNumericLiteral(value: number): NumericLiteral {
194
- return new NumericLiteral(arkts.factory.createNumberLiteral(value));
195
- }
196
-
197
- // @api
198
- // createVariableDeclarationList(
199
- // declarations: readonly VariableDeclaration[],
200
- // flags = NodeFlags.None
201
- // ): VariableDeclarationList
202
- function createVariableDeclarationList(
203
- declarations: readonly VariableDeclaration[],
204
- flags: NodeFlags = NodeFlags.None
205
- ): VariableDeclarationList {
206
- return new VariableDeclarationList(
207
- arkts.factory.createVariableDeclaration(
208
- passModifiers([]),
209
- passVariableDeclarationKind(flags),
210
- passNodeArray(declarations)
211
- )
212
- );
213
- }
214
-
215
- // @api
216
- // updateVariableDeclarationList(
217
- // node: VariableDeclarationList,
218
- // declarations: readonly VariableDeclaration[]
219
- // ): VariableDeclarationList
220
- function updateVariableDeclarationList(
221
- node: VariableDeclarationList,
222
- declarations: readonly VariableDeclaration[]
223
- ): VariableDeclarationList {
224
- return new VariableDeclarationList(
225
- arkts.factory.updateVariableDeclaration(
226
- node.node,
227
- passModifiers([]),
228
- passVariableDeclarationKind(node.flags),
229
- passNodeArray(declarations)
230
- )
231
- );
232
- }
233
-
234
- // @api
235
- // createVariableStatement(
236
- // modifiers: readonly ModifierLike[] | undefined,
237
- // declarationList: VariableDeclarationList | readonly VariableDeclaration[]
238
- // ): VariableStatement
239
- function createVariableStatement(
240
- modifiers: readonly Modifier[] | undefined,
241
- declarationList: VariableDeclarationList | readonly VariableDeclaration[]
242
- ): VariableStatement {
243
- const node: arkts.VariableDeclaration =
244
- declarationList instanceof VariableDeclarationList
245
- ? declarationList.node
246
- : createVariableDeclarationList(declarationList, undefined).node;
247
- return new VariableStatement(
248
- arkts.factory.createVariableDeclaration(passModifiers(modifiers), node.declarationKind, node.declarators)
249
- );
250
- }
251
-
252
- // @api
253
- // updateVariableStatement(
254
- // node: VariableStatement,
255
- // modifiers: readonly ModifierLike[] | undefined,
256
- // declarationList: VariableDeclarationList
257
- // ): VariableStatement
258
- function updateVariableStatement(
259
- node: VariableStatement,
260
- modifiers: readonly Modifier[] | undefined,
261
- declarationList: VariableDeclarationList
262
- ): VariableStatement {
263
- return new VariableStatement(
264
- arkts.factory.updateVariableDeclaration(
265
- node.node,
266
- passModifiers(modifiers),
267
- declarationList.node.declarationKind,
268
- declarationList.node.declarators
269
- )
270
- );
271
- }
272
-
273
- // @api
274
- // createVariableDeclaration(
275
- // name: string | BindingName,
276
- // exclamationToken: ExclamationToken | undefined,
277
- // type: TypeNode | undefined,
278
- // initializer: Expression | undefined
279
- // ): VariableDeclaration
280
- function createVariableDeclaration(
281
- name: string | Identifier,
282
- exclamationToken: undefined,
283
- type: TypeNode | undefined,
284
- initializer: Expression | undefined
285
- ): VariableDeclaration {
286
- return new VariableDeclaration(
287
- arkts.factory.createVariableDeclarator(
288
- // Improve: maybe incorrect
289
- Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_UNKNOWN,
290
- passIdentifier(name, type),
291
- passNode(initializer)
292
- )
293
- );
294
- }
295
-
296
- // @api
297
- // function updateVariableDeclaration(
298
- // node: VariableDeclaration,
299
- // name: BindingName,
300
- // exclamationToken: ExclamationToken | undefined,
301
- // type: TypeNode | undefined,
302
- // initializer: Expression | undefined
303
- // ): VariableDeclaration
304
- function updateVariableDeclaration(
305
- node: VariableDeclaration,
306
- name: Identifier,
307
- exclamationToken: undefined,
308
- type: TypeNode | undefined,
309
- initializer: Expression | undefined
310
- ): VariableDeclaration {
311
- return new VariableDeclaration(
312
- arkts.factory.updateVariableDeclarator(
313
- node.node,
314
- // Improve: maybe incorrect
315
- Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_UNKNOWN,
316
- passIdentifier(name, type),
317
- passNode(initializer)
318
- )
319
- );
320
- }
321
-
322
- // @api
323
- // createFunctionDeclaration(
324
- // modifiers: readonly ModifierLike[] | undefined,
325
- // asteriskToken: AsteriskToken | undefined,
326
- // name: string | Identifier | undefined,
327
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
328
- // parameters: readonly ParameterDeclaration[],
329
- // type: TypeNode | undefined,
330
- // body: Block | undefined
331
- // ): FunctionDeclaration;
332
- function createFunctionDeclaration(
333
- modifiers: readonly Modifier[] | undefined,
334
- asteriskToken: undefined,
335
- name: string | Identifier | undefined,
336
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
337
- parameters: readonly ParameterDeclaration[],
338
- type: TypeNode | undefined,
339
- body: Block | undefined
340
- ): FunctionDeclaration {
341
- return new FunctionDeclaration(
342
- arkts.factory.createFunctionDeclaration(
343
- arkts.factory.createScriptFunction(
344
- body?.node,
345
- arkts.FunctionSignature.create(
346
- passTypeParams(typeParameters),
347
- passNodeArray(parameters),
348
- type?.node
349
- ),
350
- 0,
351
- passModifiers(modifiers) |
352
- Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC |
353
- Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC,
354
- body === undefined,
355
- passIdentifier(name)
356
- ),
357
- false
358
- )
359
- );
360
- }
361
-
362
- // @api
363
- // updateFunctionDeclaration(
364
- // node: FunctionDeclaration,
365
- // modifiers: readonly ModifierLike[] | undefined,
366
- // asteriskToken: AsteriskToken | undefined,
367
- // name: Identifier | undefined,
368
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
369
- // parameters: readonly ParameterDeclaration[],
370
- // type: TypeNode | undefined,
371
- // body: Block | undefined
372
- // ): FunctionDeclaration;
373
- function updateFunctionDeclaration(
374
- node: FunctionDeclaration,
375
- modifiers: readonly Modifier[] | undefined,
376
- asteriskToken: undefined,
377
- name: Identifier | undefined,
378
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
379
- parameters: readonly ParameterDeclaration[],
380
- type: TypeNode | undefined,
381
- body: Block | undefined
382
- ): FunctionDeclaration {
383
- return new FunctionDeclaration(
384
- arkts.factory.updateFunctionDeclaration(
385
- node.node,
386
- arkts.factory.updateScriptFunction(
387
- node.node.scriptFunction,
388
- body?.node,
389
- arkts.FunctionSignature.create(
390
- passTypeParams(typeParameters),
391
- passNodeArray(parameters),
392
- type?.node
393
- ),
394
- 0,
395
- passModifiers(modifiers) |
396
- Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC |
397
- Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC,
398
- body === undefined,
399
- passIdentifier(name)
400
- ),
401
- false
402
- )
403
- );
404
- }
405
-
406
- // @api
407
- // createParameterDeclaration(
408
- // modifiers: readonly ModifierLike[] | undefined,
409
- // dotDotDotToken: DotDotDotToken | undefined,
410
- // name: string | BindingName,
411
- // questionToken?: QuestionToken,
412
- // type?: TypeNode,
413
- // initializer?: Expression
414
- // ): ParameterDeclaration;
415
- function createParameterDeclaration(
416
- modifiers: readonly Modifier[] | undefined,
417
- dotDotDotToken: undefined,
418
- name: string | Identifier,
419
- questionToken?: undefined,
420
- type?: TypeNode,
421
- initializer?: Expression
422
- ): ParameterDeclaration {
423
- return new ParameterDeclaration(
424
- arkts.factory.createParameterDeclaration(
425
- arkts.factory.createIdentifier(name instanceof Identifier ? name.node.name : name, type?.node),
426
- initializer?.node
427
- )
428
- );
429
- }
430
-
431
- // @api
432
- // function updateParameterDeclaration(
433
- // node: ParameterDeclaration,
434
- // modifiers: readonly ModifierLike[] | undefined,
435
- // dotDotDotToken: DotDotDotToken | undefined,
436
- // name: string | BindingName,
437
- // questionToken: QuestionToken | undefined,
438
- // type: TypeNode | undefined,
439
- // initializer: Expression | undefined,
440
- // ): ParameterDeclaration
441
- function updateParameterDeclaration(
442
- node: ParameterDeclaration,
443
- modifiers: readonly Modifier[] | undefined,
444
- dotDotDotToken: undefined,
445
- name: string | Identifier,
446
- questionToken?: undefined,
447
- type?: TypeNode,
448
- initializer?: Expression
449
- ): ParameterDeclaration {
450
- return new ParameterDeclaration(
451
- arkts.factory.updateParameterDeclaration(
452
- node.node,
453
- arkts.factory.createIdentifier(name instanceof Identifier ? name.node.name : name, type?.node),
454
- initializer?.node
455
- )
456
- );
457
- }
458
-
459
- // @api
460
- // createTypeParameterDeclaration(
461
- // modifiers: readonly Modifier[] | undefined,
462
- // name: string | Identifier,
463
- // constraint?: TypeNode,
464
- // defaultType?: TypeNode
465
- // ): TypeParameterDeclaration;
466
- function createTypeParameterDeclaration(
467
- modifiers: readonly Modifier[] | undefined,
468
- name: string | Identifier,
469
- constraint?: TypeNode,
470
- defaultType?: TypeNode
471
- ): TypeParameterDeclaration {
472
- return new TypeParameterDeclaration(
473
- arkts.factory.createTypeParameter(
474
- passIdentifier(name),
475
- constraint?.node,
476
- defaultType?.node,
477
- passModifiers(modifiers)
478
- )
479
- );
480
- }
481
-
482
- // @api
483
- // function updateTypeParameterDeclaration(
484
- // node: TypeParameterDeclaration,
485
- // modifiers: readonly Modifier[] | undefined,
486
- // name: Identifier,
487
- // constraint: TypeNode | undefined,
488
- // defaultType: TypeNode | undefined
489
- // ): TypeParameterDeclaration
490
- function updateTypeParameterDeclaration(
491
- node: TypeParameterDeclaration,
492
- modifiers: readonly Modifier[] | undefined,
493
- name: string | Identifier,
494
- constraint?: TypeNode,
495
- defaultType?: TypeNode
496
- ): TypeParameterDeclaration {
497
- return new TypeParameterDeclaration(
498
- arkts.factory.updateTypeParameter(
499
- node.node,
500
- passIdentifier(name),
501
- constraint?.node,
502
- defaultType?.node,
503
- passModifiers(modifiers)
504
- )
505
- );
506
- }
507
-
508
- // @api
509
- // createETSUnionTypeNode(
510
- // types: readonly TypeNode[]
511
- // ): UnionTypeNode
512
- function createETSUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode {
513
- return new UnionTypeNode(arkts.factory.createETSUnionType(passNodeArray(types)));
514
- }
515
-
516
- // @api
517
- // function updateETSUnionTypeNode(
518
- // node: UnionTypeNode,
519
- // types: NodeArray<TypeNode>
520
- // ): UnionTypeNode
521
- function updateETSUnionTypeNode(node: UnionTypeNode, types: readonly TypeNode[]): UnionTypeNode {
522
- return new UnionTypeNode(arkts.factory.updateETSUnionType(node.node, passNodeArray(types)));
523
- }
524
-
525
- // @api
526
- // createETSTypeReferenceNode(
527
- // typeName: string | EntityName,
528
- // typeArguments?: readonly TypeNode[]
529
- // ): TypeReferenceNode;
530
- function createETSTypeReferenceNode(typeName: Identifier, typeArguments?: undefined): TypeReferenceNode {
531
- return new TypeReferenceNode(arkts.factory.createETSTypeReferenceFromId(typeName.node));
532
- }
533
-
534
- // @api
535
- // function updateTypeReferenceNode(
536
- // node: TypeReferenceNode,
537
- // typeName: EntityName,
538
- // typeArguments: NodeArray<TypeNode> | undefined
539
- // ): TypeReferenceNode
540
- function updateTypeReferenceNode(
541
- node: TypeReferenceNode,
542
- typeName: Identifier,
543
- typeArguments?: undefined
544
- ): TypeReferenceNode {
545
- return new TypeReferenceNode(arkts.factory.updateTypeReferenceFromId(node.node, typeName.node));
546
- }
547
-
548
- // @api
549
- // createKeywordTypeNode<TKind extends KeywordTypeSyntaxKind>(
550
- // kind: TKind
551
- // ): KeywordTypeNode<TKind>;
552
- function createKeywordTypeNode(TKind: ts.KeywordTypeSyntaxKind): KeywordTypeNode {
553
- function createKeywordTypeNodeFromString(keyword: string): KeywordTypeNode {
554
- return new KeywordTypeNode(
555
- arkts.factory.createETSTypeReferenceFromId(arkts.factory.createIdentifier(keyword))
556
- );
557
- }
558
-
559
- function createKeywordTypeNodeFromKind(kind: number): KeywordTypeNode {
560
- return new KeywordTypeNode(arkts.factory.createPrimitiveType(kind));
561
- }
562
-
563
- const keywords = new Map<ts.KeywordTypeSyntaxKind, KeywordTypeNode>([
564
- [ts.SyntaxKind.NumberKeyword, createKeywordTypeNodeFromString('number')],
565
- [ts.SyntaxKind.StringKeyword, createKeywordTypeNodeFromString('string')],
566
- [ts.SyntaxKind.AnyKeyword, createKeywordTypeNodeFromString('any')],
567
- [ts.SyntaxKind.VoidKeyword, createKeywordTypeNodeFromKind(8)],
568
- ]);
569
- return keywords.get(TKind) ?? throwError('unsupported keyword');
570
- }
571
-
572
- // @api
573
- // createBlock(
574
- // statements: readonly Statement[],
575
- // multiLine?: boolean
576
- // ): Block;
577
- function createBlock(statements: readonly Statement[], multiline?: boolean): Block {
578
- return new Block(arkts.factory.createBlock(passNodeArray(statements)));
579
- }
580
-
581
- // @api
582
- // updateBlock(
583
- // node: Block,
584
- // statements: readonly Statement[]
585
- // ): Block;
586
- function updateBlock(node: Block, statements: readonly Statement[]): Block {
587
- return new Block(arkts.factory.updateBlock(node.node, passNodeArray(statements)));
588
- }
589
-
590
- // @api
591
- // createExpressionStatement(
592
- // expression: Expression
593
- // ): ExpressionStatement;
594
- function createExpressionStatement(expression: Expression): ExpressionStatement {
595
- return new ExpressionStatement(arkts.factory.createExpressionStatement(expression.node));
596
- }
597
-
598
- // @api
599
- // updateExpressionStatement(
600
- // node: ExpressionStatement,
601
- // expression: Expression
602
- // ): ExpressionStatement;
603
- function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement {
604
- return new ExpressionStatement(arkts.factory.updateExpressionStatement(node.node, expression.node));
605
- }
606
-
607
- // @api
608
- // createReturnStatement(
609
- // expression?: Expression
610
- // ): ReturnStatement;
611
- function createReturnStatement(expression: Expression): ReturnStatement {
612
- return new ReturnStatement(arkts.factory.createReturnStatement(expression.node));
613
- }
614
-
615
- // @api
616
- // function updateReturnStatement(
617
- // node: ReturnStatement,
618
- // expression: Expression | undefined
619
- // ): ReturnStatement
620
- function updateReturnStatement(node: ReturnStatement, expression: Expression): ReturnStatement {
621
- return new ReturnStatement(arkts.factory.updateReturnStatement(node.node, expression.node));
622
- }
623
-
624
- // @api
625
- // createPropertyAccessExpression(
626
- // expression: Expression,
627
- // name: string | MemberName
628
- // ): PropertyAccessExpression;
629
- function createPropertyAccessExpression(
630
- expression: Expression,
631
- name: string | Identifier
632
- ): PropertyAccessExpression {
633
- return new PropertyAccessExpression(
634
- arkts.factory.createMemberExpression(
635
- expression.node,
636
- passIdentifier(name),
637
- Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS,
638
- false,
639
- false
640
- )
641
- );
642
- }
643
-
644
- // @api
645
- // updatePropertyAccessExpression(
646
- // node: PropertyAccessExpression,
647
- // expression: Expression,
648
- // name: MemberName
649
- // ): PropertyAccessExpression;
650
- function updatePropertyAccessExpression(
651
- node: PropertyAccessExpression,
652
- expression: Expression,
653
- name: Identifier
654
- ): PropertyAccessExpression {
655
- return new PropertyAccessExpression(
656
- arkts.factory.updateMemberExpression(
657
- node.node,
658
- expression.node,
659
- passIdentifier(name),
660
- Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS,
661
- false,
662
- false
663
- )
664
- );
665
- }
666
-
667
- // @api
668
- // createCallExpression(
669
- // expression: Expression,
670
- // typeArguments: readonly TypeNode[] | undefined,
671
- // argumentsArray: readonly Expression[] | undefined
672
- // ): CallExpression;
673
- function createCallExpression(
674
- expression: Expression,
675
- typeArguments: readonly TypeNode[] | undefined,
676
- argumentsArray: readonly Expression[] | undefined
677
- ): CallExpression {
678
- return new CallExpression(
679
- arkts.factory.createCallExpression(
680
- expression.node,
681
- typeArguments !== undefined
682
- ? arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments))
683
- : undefined,
684
- passNodeArray(argumentsArray)
685
- )
686
- );
687
- }
688
-
689
- // @api
690
- // updateCallExpression(
691
- // node: CallExpression,
692
- // expression: Expression,
693
- // typeArguments: readonly TypeNode[] | undefined,
694
- // argumentsArray: readonly Expression[]
695
- // ): CallExpression;
696
- function updateCallExpression(
697
- node: CallExpression,
698
- expression: Expression,
699
- typeArguments: readonly TypeNode[] | undefined,
700
- argumentsArray: readonly Expression[] | undefined
701
- ): CallExpression {
702
- return new CallExpression(
703
- arkts.factory.updateCallExpression(
704
- node.node,
705
- expression.node,
706
- typeArguments !== undefined
707
- ? arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments))
708
- : undefined,
709
- passNodeArray(argumentsArray)
710
- )
711
- );
712
- }
713
-
714
- // @api
715
- // createIfStatement(
716
- // expression: Expression,
717
- // thenStatement: Statement,
718
- // elseStatement?: Statement
719
- // ): IfStatement;
720
- function createIfStatement(
721
- expression: Expression,
722
- thenStatement: Statement,
723
- elseStatement?: undefined
724
- ): IfStatement {
725
- return new IfStatement(
726
- arkts.factory.createIfStatement(passNode(expression), passNode(thenStatement), passNode(elseStatement))
727
- );
728
- }
729
-
730
- // @api
731
- // updateIfStatement(
732
- // expression: Expression,
733
- // thenStatement: Statement,
734
- // elseStatement: Statement | undefined
735
- // ): IfStatement;
736
- function updateIfStatement(
737
- node: IfStatement,
738
- expression: Expression,
739
- thenStatement: Statement,
740
- elseStatement?: undefined
741
- ): IfStatement {
742
- return new IfStatement(
743
- arkts.factory.updateIfStatement(
744
- node.node,
745
- passNode(expression),
746
- passNode(thenStatement),
747
- passNode(elseStatement)
748
- )
749
- );
750
- }
751
-
752
- // Improve: rewrite maybe
753
- // @api
754
- // createToken(
755
- // token: SyntaxKind._
756
- // ): _;
757
- function createToken<TKind extends ts.TokenSyntaxKind>(token: TKind) {
758
- return new Token(token);
759
- }
760
-
761
- // @api
762
- // createBinaryExpression(
763
- // left: Expression,
764
- // operator: BinaryOperator | BinaryOperatorToken,
765
- // right: Expression
766
- // ): BinaryExpression;
767
- function createBinaryExpression(
768
- left: Expression,
769
- operator: BinaryOperatorToken,
770
- right: Expression
771
- ): BinaryExpression {
772
- return new BinaryExpression(
773
- arkts.factory.createBinaryExpression(passNode(left), passToken(operator), passNode(right))
774
- );
775
- }
776
-
777
- // @api
778
- // function updateBinaryExpression(
779
- // node: BinaryExpression,
780
- // left: Expression,
781
- // operator: BinaryOperatorToken,
782
- // right: Expression
783
- // ): BinaryExpression
784
- function updateBinaryExpression(
785
- node: BinaryExpression,
786
- left: Expression,
787
- operator: BinaryOperatorToken,
788
- right: Expression
789
- ): BinaryExpression {
790
- return new BinaryExpression(
791
- arkts.factory.updateBinaryExpression(node.node, passNode(left), passToken(operator), passNode(right))
792
- );
793
- }
794
-
795
- // @api
796
- // createArrowFunction(
797
- // modifiers: readonly Modifier[] | undefined,
798
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
799
- // parameters: readonly ParameterDeclaration[],
800
- // type: TypeNode | undefined,
801
- // equalsGreaterThanToken: EqualsGreaterThanToken | undefined,
802
- // body: ConciseBody
803
- // ): ArrowFunction;
804
- function createArrowFunction(
805
- modifiers: readonly Modifier[] | undefined,
806
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
807
- parameters: readonly ParameterDeclaration[],
808
- type: TypeNode | undefined,
809
- equalsGreaterThanToken: Token<ts.SyntaxKind.EqualsGreaterThanToken> | undefined,
810
- body: Block
811
- ) {
812
- return new ArrowFunction(
813
- arkts.factory.createArrowFunction(
814
- arkts.factory.createScriptFunction(
815
- passNode(body),
816
- arkts.FunctionSignature.create(
817
- passTypeParams(typeParameters),
818
- passNodeArray(parameters),
819
- passNode(type)
820
- ),
821
- passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW,
822
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_NONE,
823
- false,
824
- undefined
825
- )
826
- )
827
- );
828
- }
829
-
830
- // @api
831
- // function updateArrowFunction(
832
- // node: ArrowFunction,
833
- // modifiers: readonly Modifier[] | undefined,
834
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
835
- // parameters: readonly ParameterDeclaration[],
836
- // type: TypeNode | undefined,
837
- // equalsGreaterThanToken: EqualsGreaterThanToken,
838
- // body: ConciseBody,
839
- // ): ArrowFunction
840
- function updateArrowFunction(
841
- node: ArrowFunction,
842
- modifiers: readonly Modifier[] | undefined,
843
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
844
- parameters: readonly ParameterDeclaration[],
845
- type: undefined,
846
- equalsGreaterThanToken: Token<ts.SyntaxKind.EqualsGreaterThanToken> | undefined,
847
- body: Block
848
- ): ArrowFunction {
849
- return new ArrowFunction(
850
- arkts.factory.updateArrowFunction(
851
- node.node,
852
- arkts.factory.updateScriptFunction(
853
- node.node.scriptFunction,
854
- passNode(body),
855
- arkts.FunctionSignature.create(
856
- passTypeParams(typeParameters),
857
- passNodeArray(parameters),
858
- passNode(type)
859
- ),
860
- passModifiersToScriptFunction(modifiers) | Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW,
861
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_NONE,
862
- false,
863
- undefined
864
- )
865
- )
866
- );
867
- }
868
-
869
- // @api
870
- // function createClassDeclaration(
871
- // modifiers: readonly ModifierLike[] | undefined,
872
- // name: string | Identifier | undefined,
873
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
874
- // heritageClauses: readonly HeritageClause[] | undefined,
875
- // members: readonly ClassElement[],
876
- // ): ClassDeclaration
877
- function createClassDeclaration(
878
- modifiers: readonly Modifier[] | undefined,
879
- name: string | Identifier | undefined,
880
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
881
- heritageClauses: readonly TypeParameterDeclaration[] | undefined,
882
- members: readonly ClassElement[]
883
- ): ClassDeclaration {
884
- return new ClassDeclaration(
885
- arkts.factory.createClassDeclaration(
886
- arkts.factory.createClassDefinition(
887
- passIdentifier(name),
888
- passNodeArray(members),
889
- // passModifiers(modifiers) | es2panda_ModifierFlags.MODIFIER_FLAGS_PUBLIC | es2panda_ModifierFlags.MODIFIER_FLAGS_STATIC,
890
- Es2pandaModifierFlags.MODIFIER_FLAGS_NONE,
891
- // Improve: pass through modifiers
892
- Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_NONE,
893
- passTypeParams(typeParameters),
894
- undefined
895
- )
896
- )
897
- );
898
- }
899
-
900
- // @api
901
- // updateClassDeclaration(
902
- // node: ClassDeclaration,
903
- // modifiers: readonly ModifierLike[] | undefined,
904
- // name: Identifier | undefined,
905
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
906
- // heritageClauses: readonly HeritageClause[] | undefined,
907
- // members: readonly ClassElement[]
908
- // ): ClassDeclaration;
909
- function updateClassDeclaration(
910
- node: ClassDeclaration,
911
- modifiers: readonly Modifier[] | undefined,
912
- name: Identifier | undefined,
913
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
914
- heritageClauses: undefined,
915
- members: readonly ClassElement[]
916
- ): ClassDeclaration {
917
- return new ClassDeclaration(
918
- arkts.factory.updateClassDeclaration(
919
- node.node,
920
- arkts.factory.updateClassDefinition(
921
- node.node.definition,
922
- passIdentifier(name),
923
- passNodeArray(members),
924
- // passModifiers(modifiers) | es2panda_ModifierFlags.MODIFIER_FLAGS_PUBLIC | es2panda_ModifierFlags.MODIFIER_FLAGS_STATIC,
925
- Es2pandaModifierFlags.MODIFIER_FLAGS_NONE,
926
- // Improve: pass through modifiers
927
- Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_NONE,
928
- passTypeParams(typeParameters)
929
- )
930
- )
931
- );
932
- }
933
-
934
- // @api
935
- // tsc: createFunctionTypeNode(
936
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
937
- // parameters: readonly ParameterDeclaration[],
938
- // type: TypeNode
939
- // ): FunctionTypeNode;
940
- function createFunctionTypeNode(
941
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
942
- parameters: readonly ParameterDeclaration[],
943
- type: TypeNode
944
- ): FunctionTypeNode {
945
- return new FunctionTypeNode(
946
- arkts.factory.createFunctionType(
947
- arkts.FunctionSignature.create(
948
- passTypeParams(typeParameters),
949
- passNodeArray(parameters),
950
- passNode(type)
951
- ),
952
- Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE
953
- )
954
- );
955
- }
956
-
957
- // @api
958
- // function updateFunctionTypeNode(
959
- // node: FunctionTypeNode,
960
- // typeParameters: NodeArray<TypeParameterDeclaration> | undefined,
961
- // parameters: NodeArray<ParameterDeclaration>,
962
- // type: TypeNode,
963
- // ): FunctionTypeNode
964
- function updateFunctionTypeNode(
965
- node: FunctionTypeNode,
966
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
967
- parameters: readonly ParameterDeclaration[],
968
- type: TypeNode
969
- ): FunctionTypeNode {
970
- return new FunctionTypeNode(
971
- arkts.factory.updateFunctionType(
972
- node.node,
973
- arkts.FunctionSignature.create(
974
- passTypeParams(typeParameters),
975
- passNodeArray(parameters),
976
- passNode(type)
977
- ),
978
- Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_NONE
979
- )
980
- );
981
- }
982
-
983
- // Improve: fix modifiers
984
- // @api
985
- // createMethodDeclaration(
986
- // modifiers: readonly ModifierLike[] | undefined,
987
- // asteriskToken: AsteriskToken | undefined,
988
- // name: string | PropertyName,
989
- // questionToken: QuestionToken | undefined,
990
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
991
- // parameters: readonly ParameterDeclaration[],
992
- // type: TypeNode | undefined,
993
- // body: Block | undefined
994
- // ): MethodDeclaration;
995
- function createMethodDeclaration(
996
- modifiers: readonly Modifier[] | undefined,
997
- asteriskToken: undefined,
998
- name: string | Identifier,
999
- questionToken: undefined,
1000
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
1001
- parameters: readonly ParameterDeclaration[],
1002
- type: TypeNode | undefined,
1003
- body: Block | undefined
1004
- ): MethodDeclaration {
1005
- const _name = passIdentifier(name);
1006
- return new MethodDeclaration(
1007
- arkts.factory.createMethodDefinition(
1008
- Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD,
1009
- _name,
1010
- arkts.factory.createFunctionExpression(
1011
- arkts.factory.createScriptFunction(
1012
- passNode(body),
1013
- arkts.FunctionSignature.create(
1014
- passTypeParams(typeParameters),
1015
- passNodeArray(parameters),
1016
- passNode(type)
1017
- ),
1018
- 0,
1019
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC ||
1020
- Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC,
1021
- false,
1022
- _name
1023
- )
1024
- ),
1025
- passModifiers(modifiers),
1026
- false
1027
- )
1028
- );
1029
- }
1030
-
1031
- // @api
1032
- // tsc: updateMethodDeclaration(
1033
- // node: MethodDeclaration,
1034
- // modifiers: readonly ModifierLike[] | undefined,
1035
- // asteriskToken: AsteriskToken | undefined,
1036
- // name: PropertyName,
1037
- // questionToken: QuestionToken | undefined,
1038
- // typeParameters: readonly TypeParameterDeclaration[] | undefined,
1039
- // parameters: readonly ParameterDeclaration[],
1040
- // type: TypeNode | undefined,
1041
- // body: Block | undefined
1042
- // ): MethodDeclaration;
1043
- function updateMethodDeclaration(
1044
- node: MethodDeclaration,
1045
- modifiers: readonly Modifier[] | undefined,
1046
- asteriskToken: undefined,
1047
- name: Identifier,
1048
- questionToken: undefined,
1049
- typeParameters: readonly TypeParameterDeclaration[] | undefined,
1050
- parameters: readonly ParameterDeclaration[],
1051
- type: undefined,
1052
- body: Block | undefined
1053
- ): MethodDeclaration {
1054
- const _name = passIdentifier(name);
1055
- return new MethodDeclaration(
1056
- arkts.factory.updateMethodDefinition(
1057
- node.node,
1058
- Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD,
1059
- _name,
1060
- arkts.factory.createFunctionExpression(
1061
- // Improve: maybe fix
1062
- arkts.factory.updateScriptFunction(
1063
- node.node.scriptFunction,
1064
- passNode(body),
1065
- arkts.FunctionSignature.create(
1066
- passTypeParams(typeParameters),
1067
- passNodeArray(parameters),
1068
- passNode(type)
1069
- ),
1070
- 0,
1071
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC ||
1072
- Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC,
1073
- false,
1074
- _name
1075
- )
1076
- ),
1077
- passModifiers(modifiers),
1078
- false
1079
- )
1080
- );
1081
- }
1082
-
1083
- // @api
1084
- // createConstructorDeclaration(
1085
- // modifiers: readonly ModifierLike[] | undefined,
1086
- // parameters: readonly ParameterDeclaration[],
1087
- // body: Block | undefined
1088
- // ): ConstructorDeclaration;
1089
- function createConstructorDeclaration(
1090
- modifiers: readonly Modifier[] | undefined,
1091
- parameters: readonly ParameterDeclaration[],
1092
- body: Block | undefined
1093
- ): ConstructorDeclaration {
1094
- const _name = arkts.factory.createIdentifier('constructor');
1095
- return new ConstructorDeclaration(
1096
- arkts.factory.createMethodDefinition(
1097
- Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR,
1098
- _name,
1099
- arkts.factory.createFunctionExpression(
1100
- arkts.factory.createScriptFunction(
1101
- passNode(body),
1102
- arkts.FunctionSignature.create(
1103
- undefined,
1104
- passNodeArray(parameters),
1105
- // Improve: change to void maybe
1106
- undefined
1107
- ),
1108
- passModifiersToScriptFunction(modifiers) |
1109
- Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR,
1110
- passModifiers(modifiers) |
1111
- Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC |
1112
- Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR,
1113
- false,
1114
- _name
1115
- )
1116
- ),
1117
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR,
1118
- false
1119
- )
1120
- );
1121
- }
1122
-
1123
- // @api
1124
- // function updateConstructorDeclaration(
1125
- // node: ConstructorDeclaration,
1126
- // modifiers: readonly ModifierLike[] | undefined,
1127
- // parameters: readonly ParameterDeclaration[],
1128
- // body: Block | undefined,
1129
- // ): ConstructorDeclaration
1130
- function updateConstructorDeclaration(
1131
- node: ConstructorDeclaration,
1132
- modifiers: readonly Modifier[] | undefined,
1133
- parameters: readonly ParameterDeclaration[],
1134
- body: Block | undefined
1135
- ): ConstructorDeclaration {
1136
- const _name = arkts.factory.updateIdentifier(node.node.name, 'constructor');
1137
- return new ConstructorDeclaration(
1138
- arkts.factory.updateMethodDefinition(
1139
- node.node,
1140
- Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR,
1141
- _name,
1142
- arkts.factory.createFunctionExpression(
1143
- // Improve: maybe fix
1144
- arkts.factory.updateScriptFunction(
1145
- node.node.scriptFunction,
1146
- passNode(body),
1147
- arkts.FunctionSignature.create(
1148
- undefined,
1149
- passNodeArray(parameters),
1150
- // Improve: change to void maybe
1151
- undefined
1152
- ),
1153
- passModifiersToScriptFunction(modifiers) |
1154
- Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR,
1155
- passModifiers(modifiers) |
1156
- Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC |
1157
- Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR,
1158
- false,
1159
- _name
1160
- )
1161
- ),
1162
- passModifiers(modifiers) | Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR,
1163
- false
1164
- )
1165
- );
1166
- }
1167
-
1168
- // @api
1169
- // tsc: createSuper(
1170
- // ): SuperExpression;
1171
- function createSuper(): SuperExpression {
1172
- return new SuperExpression(arkts.factory.createSuperExpression());
1173
- }
1174
-
1175
- // @api
1176
- // tsc: updateSuper(
1177
- // node: SuperExpression
1178
- // ): SuperExpression;
1179
- function updateSuper(node: SuperExpression): SuperExpression {
1180
- return new SuperExpression(arkts.factory.updateSuperExpression(node.node));
1181
- }
1182
-
1183
- // @api
1184
- // tsc: createParenthesizedExpression(
1185
- // expression: Expression
1186
- // ): ParenthesizedExpression;
1187
- function createParenthesizedExpression(expression: Expression): ParenthesizedExpression {
1188
- return expression;
1189
- // Improve:
1190
- // return new ParenthesizedExpression(
1191
- // expression
1192
- // )
1193
- }
1194
-
1195
- // @api
1196
- // tsc: updateParenthesizedExpression(
1197
- // node: ParenthesizedExpression,
1198
- // expression: Expression
1199
- // ): ParenthesizedExpression;
1200
- function updateParenthesizedExpression(
1201
- node: ParenthesizedExpression,
1202
- expression: Expression
1203
- ): ParenthesizedExpression {
1204
- return expression;
1205
- // Improve:
1206
- // return new ParenthesizedExpression(
1207
- // expression
1208
- // )
1209
- }
1210
-
1211
- // // @api
1212
- // // createImportDeclaration(
1213
- // // decorators: readonly Decorator[] | undefined,
1214
- // // modifiers: readonly Modifier[] | undefined,
1215
- // // importClause: ImportClause | undefined,
1216
- // // moduleSpecifier: Expression,
1217
- // // assertClause?: AssertClause
1218
- // // ): ImportDeclaration;
1219
- // function createImportDeclaration(
1220
- // decorators: undefined,
1221
- // modifiers: readonly Modifier[] | undefined,
1222
- // importClause: ImportClause | undefined,
1223
- // moduleSpecifier: StringLiteral,
1224
- // assertClause?: undefined
1225
- // ): ImportDeclaration {
1226
- // return new ImportDeclaration(
1227
- // arkts.EtsImportDeclaration.create(
1228
- // undefined,
1229
- // arkts.ImportSource.create(moduleSpecifier.node),
1230
-
1231
- // )
1232
- // )
1233
- // }
1234
-
1235
- // @api
1236
- // createImportSpecifier(
1237
- // isTypeOnly: boolean,
1238
- // propertyName: Identifier | undefined,
1239
- // name: Identifier
1240
- // ): ImportSpecifier;
1241
- function createImportSpecifier(
1242
- isTypeOnly: boolean,
1243
- propertyName: Identifier | undefined,
1244
- name: Identifier
1245
- ): ImportSpecifier {
1246
- return new ImportSpecifier(name.node);
1247
- }
1248
- }
1249
-
1250
- export const factory = createNodeFactory();