@idlizer/arktscgen 2.1.10-arktscgen-6 → 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 (31) hide show
  1. package/build/libarkts-copy/native/meson.build +4 -4
  2. package/build/libarkts-copy/native/src/{bridges.cc → bridges.cpp} +11 -11
  3. package/build/libarkts-copy/native/src/{common.cc → common.cpp} +163 -108
  4. package/build/libarkts-copy/native/src/common.h +22 -22
  5. package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +9 -3
  6. package/build/libarkts-copy/package.json +2 -2
  7. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +8 -3
  8. package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
  9. package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
  10. package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
  11. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +0 -1
  12. package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -10
  13. package/build/libarkts-copy/src/arkts-api/static/global.ts +0 -3
  14. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +4 -4
  15. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +7 -34
  16. package/build/libarkts-copy/src/index.ts +0 -1
  17. package/build/libarkts-copy/src/plugin-utils.ts +58 -33
  18. package/build/libarkts-copy/src/reexport-for-generated.ts +1 -1
  19. package/build/libarkts-copy/tsconfig.json +0 -3
  20. package/lib/index.js +218 -36
  21. package/package.json +2 -2
  22. package/templates/{bridges.cc → bridges.cpp} +1 -1
  23. package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
  24. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
  25. package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
  26. package/build/libarkts-copy/src/ts-api/index.ts +0 -27
  27. package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
  28. package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
  29. package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
  30. package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
  31. package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
@@ -1,1075 +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 * as ts from '@koalaui/ets-tsc';
17
- import * as arkts from '../arkts-api';
18
-
19
- import { throwError } from '../utils';
20
- import {
21
- passModifiers,
22
- emptyImplementation,
23
- unpackModifiers,
24
- unpackNode,
25
- unpackNodeArray,
26
- unpackVariableDeclarationKind,
27
- } from './utilities/private';
28
- import { SyntaxKind } from './static/enums';
29
-
30
- // Improve: write implementation
31
- export interface TransformationContext {}
32
-
33
- // Improve: write implementation
34
- export interface Program {}
35
-
36
- // Improve: remove U type param
37
- export type NodeArray<
38
- T extends Node<U>,
39
- U extends arkts.AstNode | undefined = arkts.AstNode | undefined,
40
- > = ts.NodeArray<T>;
41
-
42
- export abstract class Node<T extends arkts.AstNode | undefined = arkts.AstNode | undefined> implements ts.Node {
43
- constructor(node: T) {
44
- this.node = node;
45
- }
46
-
47
- readonly node: T;
48
-
49
- // Improve: remove any
50
- get parent(): any {
51
- if (this.node === undefined) {
52
- throwError('trying to get parent of undefined _node');
53
- }
54
- return unpackNode(this.node.parent);
55
- }
56
-
57
- set parent(node: Node) {
58
- if (this.node === undefined) {
59
- throwError('trying to set parent of undefined');
60
- }
61
- if (node.node === undefined) {
62
- throwError('trying to set parent to undefined');
63
- }
64
- this.node.parent = node.node;
65
- }
66
-
67
- set modifiers(flags: readonly Modifier[] | undefined) {
68
- if (this.node === undefined) {
69
- throwError('trying to set modifiers of undefined');
70
- }
71
- this.node.modifiers = passModifiers(flags);
72
- }
73
-
74
- get modifiers(): NodeArray<Modifier> {
75
- return unpackModifiers(this.node?.modifiers);
76
- }
77
-
78
- abstract kind: SyntaxKind;
79
-
80
- // Improve:
81
- forEachChild<T>(
82
- cbNode: (node: ts.Node) => T | undefined,
83
- cbNodeArray?: ((nodes: ts.NodeArray<ts.Node>) => T | undefined) | undefined
84
- ): T | undefined {
85
- throw new Error('Method not implemented.');
86
- }
87
- getSourceFile(): ts.SourceFile {
88
- throw new Error('Method not implemented.');
89
- }
90
- getChildCount(sourceFile?: ts.SourceFile | undefined): number {
91
- throw new Error('Method not implemented.');
92
- }
93
- getChildAt(index: number, sourceFile?: ts.SourceFile | undefined): ts.Node {
94
- throw new Error('Method not implemented.');
95
- }
96
- getChildren(sourceFile?: ts.SourceFile | undefined): ts.Node[] {
97
- throw new Error('Method not implemented.');
98
- }
99
-
100
- getStart(sourceFile?: ts.SourceFile | undefined, includeJsDocComment?: boolean | undefined): number {
101
- throw new Error('Method not implemented.');
102
- }
103
- getFullStart(): number {
104
- throw new Error('Method not implemented.');
105
- }
106
- getEnd(): number {
107
- throw new Error('Method not implemented.');
108
- }
109
- getWidth(sourceFile?: ts.SourceFileLike | undefined): number {
110
- throw new Error('Method not implemented.');
111
- }
112
- getFullWidth(): number {
113
- throw new Error('Method not implemented.');
114
- }
115
- getLeadingTriviaWidth(sourceFile?: ts.SourceFile | undefined): number {
116
- throw new Error('Method not implemented.');
117
- }
118
- getFullText(sourceFile?: ts.SourceFile | undefined): string {
119
- throw new Error('Method not implemented.');
120
- }
121
- getText(sourceFile?: ts.SourceFile | undefined): string {
122
- throw new Error('Method not implemented.');
123
- }
124
- getFirstToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined {
125
- throw new Error('Method not implemented.');
126
- }
127
- getLastToken(sourceFile?: ts.SourceFile | undefined): ts.Node | undefined {
128
- throw new Error('Method not implemented.');
129
- }
130
-
131
- get symbol(): ts.Symbol {
132
- return emptyImplementation();
133
- }
134
- get flags(): ts.NodeFlags {
135
- return emptyImplementation();
136
- }
137
- get pos(): number {
138
- return emptyImplementation();
139
- }
140
- get end(): number {
141
- return emptyImplementation();
142
- }
143
- }
144
-
145
- // Improve: add all tokens
146
- export type BinaryOperator = ts.SyntaxKind.PlusToken | ts.SyntaxKind.MinusToken | ts.SyntaxKind.AsteriskToken;
147
-
148
- export type BinaryOperatorToken = Token<BinaryOperator>;
149
-
150
- // Improve: rethink maybe (temporary solution)
151
- export class Token<TKind extends ts.TokenSyntaxKind> extends Node<undefined> {
152
- constructor(kind: TKind) {
153
- super(undefined);
154
- this.kind = kind;
155
- }
156
-
157
- readonly kind: TKind;
158
- }
159
-
160
- export type ModifierSyntaxKind =
161
- // | SyntaxKind.ConstructorKeyword
162
- | SyntaxKind.AbstractKeyword
163
- | SyntaxKind.AccessorKeyword
164
- | SyntaxKind.AsyncKeyword
165
- | SyntaxKind.ConstKeyword
166
- | SyntaxKind.DeclareKeyword
167
- | SyntaxKind.DefaultKeyword
168
- | SyntaxKind.ExportKeyword
169
- | SyntaxKind.InKeyword
170
- | SyntaxKind.PrivateKeyword
171
- | SyntaxKind.ProtectedKeyword
172
- | SyntaxKind.PublicKeyword
173
- | SyntaxKind.ReadonlyKeyword
174
- | SyntaxKind.OutKeyword
175
- | SyntaxKind.OverrideKeyword
176
- | SyntaxKind.StaticKeyword;
177
-
178
- export class Modifier extends Node<undefined> {
179
- constructor(kind: ModifierSyntaxKind) {
180
- super(undefined);
181
- this.kind = kind;
182
- }
183
-
184
- public toString(): string {
185
- return `${this.kind}`;
186
- }
187
-
188
- kind: ModifierSyntaxKind;
189
- }
190
-
191
- export abstract class Expression extends Node<arkts.AstNode> implements ts.Expression {
192
- // Improve: support minimal interface
193
- _expressionBrand: any;
194
- }
195
-
196
- export class FunctionDeclaration
197
- extends Node<arkts.FunctionDeclaration>
198
- implements ts.FunctionDeclaration, FunctionLikeDeclarationBase
199
- {
200
- constructor(node: arkts.FunctionDeclaration) {
201
- super(node);
202
- this.name = unpackNode(node.name);
203
- this.body = unpackNode(node.body);
204
- this.typeParameters = unpackNodeArray(node.typeParamsDecl?.parameters);
205
- this.type = unpackNode(node.returnType);
206
- this.parameters = unpackNodeArray(node.parameters);
207
- }
208
-
209
- readonly name?: Identifier | undefined;
210
- readonly body?: Block | undefined;
211
- readonly typeParameters?: NodeArray<TypeParameterDeclaration> | undefined;
212
- readonly type?: TypeNode | undefined;
213
- readonly parameters: NodeArray<ParameterDeclaration>;
214
- readonly kind: ts.SyntaxKind.FunctionDeclaration = ts.SyntaxKind.FunctionDeclaration;
215
-
216
- // brands
217
- _functionLikeDeclarationBrand: any;
218
- _declarationBrand: any;
219
- _statementBrand: any;
220
- }
221
-
222
- export class FunctionExpression
223
- extends Node<arkts.FunctionExpression>
224
- implements ts.FunctionExpression, FunctionLikeDeclarationBase
225
- {
226
- constructor(node: arkts.FunctionExpression) {
227
- super(node);
228
- this.name = unpackNode(node.scriptFunction.ident);
229
- if (node.scriptFunction.body === undefined) {
230
- throwError('body expected to be not undefined');
231
- }
232
- this.body = unpackNode(node.scriptFunction.body);
233
- this.parameters = unpackNodeArray(node.scriptFunction.parameters);
234
- }
235
-
236
- readonly name?: Identifier;
237
- readonly body: Block;
238
- readonly parameters: NodeArray<ParameterDeclaration>;
239
- readonly kind: ts.SyntaxKind.FunctionExpression = ts.SyntaxKind.FunctionExpression;
240
-
241
- // brands
242
- _primaryExpressionBrand: any;
243
- _memberExpressionBrand: any;
244
- _leftHandSideExpressionBrand: any;
245
- _updateExpressionBrand: any;
246
- _unaryExpressionBrand: any;
247
- _expressionBrand: any;
248
- _functionLikeDeclarationBrand: any;
249
- _declarationBrand: any;
250
- }
251
-
252
- export class Identifier extends Node<arkts.Identifier> implements ts.Identifier, Expression {
253
- constructor(node: arkts.Identifier) {
254
- super(node);
255
- this.text = node.name;
256
- }
257
-
258
- readonly text: string;
259
- readonly kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier;
260
-
261
- // Improve:
262
- get escapedText(): ts.__String {
263
- return emptyImplementation();
264
- }
265
-
266
- // brands
267
- _primaryExpressionBrand: any;
268
- _memberExpressionBrand: any;
269
- _leftHandSideExpressionBrand: any;
270
- _updateExpressionBrand: any;
271
- _unaryExpressionBrand: any;
272
- _expressionBrand: any;
273
- _declarationBrand: any;
274
- }
275
-
276
- export class PrivateIdentifier extends Node<arkts.Identifier> implements ts.PrivateIdentifier, Expression {
277
- constructor(node: arkts.Identifier) {
278
- super(node);
279
- this.text = node.name;
280
- if (!node.isPrivate) {
281
- throwError('identifier expected to be private');
282
- }
283
- }
284
-
285
- readonly text: string;
286
- readonly kind: ts.SyntaxKind.PrivateIdentifier = ts.SyntaxKind.PrivateIdentifier;
287
-
288
- // Improve:
289
- get escapedText(): ts.__String {
290
- return emptyImplementation();
291
- }
292
-
293
- // brands
294
- _primaryExpressionBrand: any;
295
- _memberExpressionBrand: any;
296
- _leftHandSideExpressionBrand: any;
297
- _updateExpressionBrand: any;
298
- _unaryExpressionBrand: any;
299
- _expressionBrand: any;
300
- _declarationBrand: any;
301
- }
302
-
303
- export abstract class Statement extends Node<arkts.AstNode> implements ts.Statement {
304
- // brands
305
- _statementBrand: any;
306
- }
307
-
308
- export class Block extends Node<arkts.BlockStatement> implements ts.Block {
309
- constructor(node: arkts.BlockStatement) {
310
- super(node);
311
- this.statements = unpackNodeArray(node.statements);
312
- }
313
-
314
- readonly statements: NodeArray<Statement>;
315
- readonly kind: ts.SyntaxKind.Block = ts.SyntaxKind.Block;
316
-
317
- // brands
318
- _statementBrand: any;
319
- }
320
-
321
- export class SourceFile extends Node<arkts.EtsScript> implements ts.SourceFile {
322
- constructor(node: arkts.EtsScript) {
323
- super(node);
324
-
325
- this.statements = unpackNodeArray(this.node.statements);
326
- }
327
-
328
- readonly statements: NodeArray<Statement>;
329
- readonly kind: ts.SyntaxKind.SourceFile = ts.SyntaxKind.SourceFile;
330
-
331
- // Improve:
332
- getLineAndCharacterOfPosition(pos: number): ts.LineAndCharacter {
333
- throw new Error('Method not implemented.');
334
- }
335
- getLineEndOfPosition(pos: number): number {
336
- throw new Error('Method not implemented.');
337
- }
338
- getLineStarts(): readonly number[] {
339
- throw new Error('Method not implemented.');
340
- }
341
- getPositionOfLineAndCharacter(line: number, character: number): number {
342
- throw new Error('Method not implemented.');
343
- }
344
- update(newText: string, textChangeRange: ts.TextChangeRange): ts.SourceFile {
345
- throw new Error('Method not implemented.');
346
- }
347
- get endOfFileToken(): ts.Token<ts.SyntaxKind.EndOfFileToken> {
348
- return emptyImplementation();
349
- }
350
- get fileName(): string {
351
- return emptyImplementation();
352
- }
353
- get text() {
354
- return emptyImplementation();
355
- }
356
- get amdDependencies(): readonly ts.AmdDependency[] {
357
- return emptyImplementation();
358
- }
359
- get referencedFiles(): readonly ts.FileReference[] {
360
- return emptyImplementation();
361
- }
362
- get typeReferenceDirectives(): readonly ts.FileReference[] {
363
- return emptyImplementation();
364
- }
365
- get libReferenceDirectives(): readonly ts.FileReference[] {
366
- return emptyImplementation();
367
- }
368
- get languageVariant(): ts.LanguageVariant {
369
- return emptyImplementation();
370
- }
371
- get isDeclarationFile(): boolean {
372
- return emptyImplementation();
373
- }
374
- get hasNoDefaultLib(): boolean {
375
- return emptyImplementation();
376
- }
377
- get languageVersion(): ts.ScriptTarget {
378
- return emptyImplementation();
379
- }
380
-
381
- // brands
382
- _declarationBrand: any;
383
- }
384
-
385
- export abstract class LeftHandSideExpression
386
- extends Node<arkts.AstNode>
387
- implements ts.LeftHandSideExpression, Expression
388
- {
389
- // brands
390
- _leftHandSideExpressionBrand: any;
391
- _updateExpressionBrand: any;
392
- _unaryExpressionBrand: any;
393
- _expressionBrand: any;
394
- }
395
-
396
- export class ExpressionStatement extends Node<arkts.ExpressionStatement> implements ts.ExpressionStatement, Statement {
397
- constructor(node: arkts.ExpressionStatement) {
398
- super(node);
399
- this.expression = unpackNode(this.node.expression);
400
- }
401
-
402
- readonly expression: Expression;
403
- readonly kind: ts.SyntaxKind.ExpressionStatement = ts.SyntaxKind.ExpressionStatement;
404
-
405
- // brands
406
- _statementBrand: any;
407
- }
408
-
409
- export class CallExpression extends Node<arkts.CallExpression> implements ts.CallExpression, LeftHandSideExpression {
410
- constructor(node: arkts.CallExpression) {
411
- super(node);
412
- this.expression = unpackNode(node.expression);
413
- this.arguments = unpackNodeArray(node.arguments);
414
- }
415
-
416
- readonly expression: LeftHandSideExpression;
417
- readonly arguments: NodeArray<Expression>;
418
- readonly kind: ts.SyntaxKind.CallExpression = ts.SyntaxKind.CallExpression;
419
-
420
- // brands
421
- _leftHandSideExpressionBrand: any;
422
- _updateExpressionBrand: any;
423
- _unaryExpressionBrand: any;
424
- _expressionBrand: any;
425
- _declarationBrand: any;
426
- }
427
-
428
- export class PropertyAccessExpression
429
- extends Node<arkts.MemberExpression>
430
- implements ts.PropertyAccessExpression, Expression
431
- {
432
- constructor(node: arkts.MemberExpression) {
433
- super(node);
434
- this.expression = unpackNode(node.object);
435
- this.name = unpackNode(node.property);
436
- }
437
-
438
- readonly expression: LeftHandSideExpression;
439
- readonly name: Identifier;
440
- readonly kind: ts.SyntaxKind.PropertyAccessExpression = ts.SyntaxKind.PropertyAccessExpression;
441
-
442
- // brands
443
- _memberExpressionBrand: any;
444
- _leftHandSideExpressionBrand: any;
445
- _updateExpressionBrand: any;
446
- _unaryExpressionBrand: any;
447
- _expressionBrand: any;
448
- _declarationBrand: any;
449
- }
450
-
451
- export class StringLiteral extends Node<arkts.StringLiteral> implements ts.StringLiteral {
452
- constructor(node: arkts.StringLiteral) {
453
- super(node);
454
-
455
- this.text = node.str;
456
- }
457
-
458
- readonly text: string;
459
- readonly kind: ts.SyntaxKind.StringLiteral = ts.SyntaxKind.StringLiteral;
460
-
461
- // brands
462
- _literalExpressionBrand: any;
463
- _primaryExpressionBrand: any;
464
- _memberExpressionBrand: any;
465
- _leftHandSideExpressionBrand: any;
466
- _updateExpressionBrand: any;
467
- _unaryExpressionBrand: any;
468
- _expressionBrand: any;
469
- _declarationBrand: any;
470
- }
471
-
472
- export class ClassDeclaration extends Node<arkts.ClassDeclaration> implements ts.ClassDeclaration {
473
- constructor(node: arkts.ClassDeclaration) {
474
- super(node);
475
- this.name = unpackNode(node.definition.name);
476
- this.members = unpackNodeArray(node.definition.members);
477
- this.typeParameters = unpackNodeArray(node.definition.typeParamsDecl?.parameters);
478
- }
479
-
480
- readonly name: Identifier;
481
- readonly members: NodeArray<ClassElement>;
482
- readonly typeParameters?: NodeArray<TypeParameterDeclaration>;
483
- readonly kind: ts.SyntaxKind.ClassDeclaration = ts.SyntaxKind.ClassDeclaration;
484
-
485
- // brands
486
- _declarationBrand: any;
487
- _statementBrand: any;
488
- }
489
-
490
- export abstract class ClassElement extends Node<arkts.AstNode> implements ts.ClassElement {
491
- // brands
492
- _declarationBrand: any;
493
- _classElementBrand: any;
494
- }
495
-
496
- export type MemberName = Identifier | PrivateIdentifier;
497
-
498
- // Improve: support
499
- // export type PropertyName = Identifier | StringLiteral | NumericLiteral | ts.ComputedPropertyName | PrivateIdentifier;
500
- export type PropertyName = Identifier | StringLiteral | NumericLiteral | PrivateIdentifier;
501
-
502
- // Improve: support
503
- export type DeclarationName = PropertyName;
504
- // | JsxAttributeName
505
- // | StringLiteralLike
506
- // | ElementAccessExpression
507
- // | BindingPattern
508
- // | EntityNameExpression;
509
-
510
- export interface Declaration extends Node<arkts.AstNode> {}
511
-
512
- export abstract class NamedDeclaration extends Node<arkts.AstNode> implements ts.NamedDeclaration, Declaration {
513
- readonly name?: DeclarationName;
514
-
515
- // brands
516
- _declarationBrand: any;
517
- }
518
-
519
- export type SignatureDeclaration =
520
- | ts.CallSignatureDeclaration
521
- | ts.ConstructSignatureDeclaration
522
- | MethodSignature
523
- | ts.IndexSignatureDeclaration
524
- | FunctionTypeNode
525
- | ts.ConstructorTypeNode
526
- | ts.JSDocFunctionType
527
- | FunctionDeclaration
528
- | MethodDeclaration
529
- | ConstructorDeclaration
530
- | ts.AccessorDeclaration
531
- | FunctionExpression
532
- | ArrowFunction;
533
-
534
- export interface SignatureDeclarationBase extends NamedDeclaration {}
535
-
536
- export type VariableLikeDeclaration =
537
- | ts.VariableDeclaration
538
- | ParameterDeclaration
539
- | ts.BindingElement
540
- | PropertyDeclaration
541
- | ts.PropertyAssignment
542
- | PropertySignature
543
- | ts.JsxAttribute
544
- | ts.ShorthandPropertyAssignment
545
- | ts.EnumMember
546
- | ts.JSDocPropertyTag
547
- | ts.JSDocParameterTag;
548
-
549
- export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase {
550
- // brands
551
- _functionLikeDeclarationBrand: any;
552
- }
553
-
554
- // Improve: support
555
- // export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction;
556
- export type FunctionLikeDeclaration =
557
- | FunctionDeclaration
558
- | MethodDeclaration
559
- | ConstructorDeclaration
560
- | FunctionExpression
561
- | ArrowFunction;
562
-
563
- export class MethodSignature extends Node<arkts.AstNode> implements ts.MethodSignature, SignatureDeclarationBase {
564
- constructor(node: arkts.AstNode) {
565
- super(node);
566
- }
567
-
568
- // readonly name: PropertyName
569
- // readonly parameters: NodeArray<ParameterDeclaration>
570
- readonly kind: ts.SyntaxKind.MethodSignature = ts.SyntaxKind.MethodSignature;
571
-
572
- // Improve:
573
- name: any;
574
- parameters: any;
575
-
576
- // brands
577
- _declarationBrand: any;
578
- _typeElementBrand: any;
579
- }
580
-
581
- // export class MethodDeclaration extends Node implements ts.MethodDeclaration, FunctionLikeDeclarationBase, ClassElement {
582
- export class MethodDeclaration extends Node<arkts.MethodDefinition> implements ts.MethodDeclaration, ClassElement {
583
- constructor(node: arkts.MethodDefinition) {
584
- super(node);
585
- this.name = unpackNode(node.name);
586
- this.parameters = unpackNodeArray(node.scriptFunction.parameters);
587
- this.body = unpackNode(node.scriptFunction.body);
588
- }
589
-
590
- // tsc: readonly name?: PropertyName
591
- readonly name: Identifier;
592
- readonly parameters: NodeArray<ParameterDeclaration>;
593
- // tsc: readonly body?: FunctionBody | undefined
594
- readonly body?: Block | undefined;
595
- readonly kind: ts.SyntaxKind.MethodDeclaration = ts.SyntaxKind.MethodDeclaration;
596
-
597
- // brands
598
- _functionLikeDeclarationBrand: any;
599
- _classElementBrand: any;
600
- _objectLiteralBrand: any;
601
- _declarationBrand: any;
602
- }
603
-
604
- // export class ConstructorDeclaration extends Node<arkts.MethodDefinition> implements ts.ConstructorDeclaration, FunctionLikeDeclarationBase, ClassElement {
605
- export class ConstructorDeclaration
606
- extends Node<arkts.MethodDefinition>
607
- implements ts.ConstructorDeclaration, ClassElement
608
- {
609
- constructor(node: arkts.MethodDefinition) {
610
- super(node);
611
- this.name = unpackNode(node.name);
612
- this.parameters = unpackNodeArray(node.scriptFunction.parameters);
613
- this.body = unpackNode(node.scriptFunction.body);
614
- }
615
-
616
- // ts: readonly name?: PropertyName
617
- readonly name: Identifier;
618
- readonly parameters: NodeArray<ParameterDeclaration>;
619
- // ts: readonly body?: FunctionBody | undefined
620
- readonly body?: Block;
621
- readonly kind: ts.SyntaxKind.Constructor = ts.SyntaxKind.Constructor;
622
-
623
- // brands
624
- _functionLikeDeclarationBrand: any;
625
- _classElementBrand: any;
626
- _objectLiteralBrand: any;
627
- _declarationBrand: any;
628
- }
629
-
630
- // Improve: specify arkts.AstNode type
631
- export class PropertySignature extends Node<arkts.AstNode> implements ts.TypeElement {
632
- constructor(node: arkts.AstNode) {
633
- super(node);
634
- }
635
-
636
- readonly name?: PropertyName;
637
- readonly kind: ts.SyntaxKind.PropertySignature = ts.SyntaxKind.PropertySignature;
638
-
639
- // brands
640
- _typeElementBrand: any;
641
- _declarationBrand: any;
642
- }
643
-
644
- // Improve: specify arkts.AstNode type
645
- export class PropertyDeclaration extends Node<arkts.AstNode> implements ts.PropertyDeclaration, ClassElement {
646
- constructor(node: arkts.AstNode) {
647
- super(node);
648
- }
649
-
650
- readonly kind: ts.SyntaxKind.PropertyDeclaration = ts.SyntaxKind.PropertyDeclaration;
651
-
652
- // Improve:
653
- name: any;
654
-
655
- // brands
656
- _classElementBrand: any;
657
- _declarationBrand: any;
658
- }
659
-
660
- // Improve: specify arkts.AstNode type
661
- export class GetAccessorDeclaration
662
- extends Node<arkts.AstNode>
663
- implements ts.GetAccessorDeclaration, FunctionLikeDeclarationBase, ClassElement
664
- {
665
- constructor(node: arkts.AstNode) {
666
- super(node);
667
- }
668
-
669
- // readonly name: PropertyName
670
- // readonly parameters: NodeArray<ParameterDeclaration>
671
- readonly kind: ts.SyntaxKind.GetAccessor = ts.SyntaxKind.GetAccessor;
672
-
673
- // Improve:
674
- name: any;
675
- parameters: any;
676
-
677
- // brands
678
- _functionLikeDeclarationBrand: any;
679
- _declarationBrand: any;
680
- _classElementBrand: any;
681
- _typeElementBrand: any;
682
- _objectLiteralBrand: any;
683
- }
684
-
685
- // Improve: specify arkts.AstNode type
686
- export class SetAccessorDeclaration
687
- extends Node<arkts.AstNode>
688
- implements ts.SetAccessorDeclaration, FunctionLikeDeclarationBase, ClassElement
689
- {
690
- constructor(node: arkts.AstNode) {
691
- super(node);
692
- }
693
-
694
- // readonly name: PropertyName
695
- // readonly parameters: NodeArray<ParameterDeclaration>
696
- readonly kind: ts.SyntaxKind.SetAccessor = ts.SyntaxKind.SetAccessor;
697
-
698
- // Improve:
699
- name: any;
700
- parameters: any;
701
-
702
- // brands
703
- _functionLikeDeclarationBrand: any;
704
- _declarationBrand: any;
705
- _classElementBrand: any;
706
- _typeElementBrand: any;
707
- _objectLiteralBrand: any;
708
- }
709
-
710
- export class ParameterDeclaration
711
- extends Node<arkts.ETSParameterExpression>
712
- implements ts.ParameterDeclaration, NamedDeclaration
713
- {
714
- constructor(node: arkts.ETSParameterExpression) {
715
- super(node);
716
- }
717
-
718
- readonly kind: ts.SyntaxKind.Parameter = ts.SyntaxKind.Parameter;
719
-
720
- // Improve:
721
- name: any;
722
-
723
- // brands
724
- _declarationBrand: any;
725
- }
726
-
727
- export type BindingName = Identifier | ts.BindingPattern;
728
-
729
- export class VariableStatement extends Node<arkts.VariableDeclaration> implements ts.VariableStatement {
730
- constructor(node: arkts.VariableDeclaration) {
731
- super(node);
732
- this.declarationList = new VariableDeclarationList(node);
733
- }
734
-
735
- readonly declarationList: VariableDeclarationList;
736
- readonly kind: ts.SyntaxKind.VariableStatement = ts.SyntaxKind.VariableStatement;
737
-
738
- // brands
739
- _statementBrand: any;
740
- }
741
-
742
- export class VariableDeclarationList extends Node<arkts.VariableDeclaration> implements ts.VariableDeclarationList {
743
- constructor(node: arkts.VariableDeclaration) {
744
- super(node);
745
- this.declarations = unpackNodeArray(node.declarators);
746
- }
747
-
748
- readonly declarations: NodeArray<VariableDeclaration>;
749
- get flags(): ts.NodeFlags {
750
- return unpackVariableDeclarationKind(this.node.declarationKind);
751
- }
752
- readonly kind: ts.SyntaxKind.VariableDeclarationList = ts.SyntaxKind.VariableDeclarationList;
753
- }
754
-
755
- export class VariableDeclaration
756
- extends Node<arkts.VariableDeclarator>
757
- implements ts.VariableDeclaration, NamedDeclaration
758
- {
759
- constructor(node: arkts.VariableDeclarator) {
760
- super(node);
761
- this.name = unpackNode(node.name);
762
- }
763
-
764
- readonly name: Identifier;
765
- readonly kind: ts.SyntaxKind.VariableDeclaration = ts.SyntaxKind.VariableDeclaration;
766
-
767
- // brands
768
- _declarationBrand: any;
769
- }
770
-
771
- export class TypeParameterDeclaration extends Node<arkts.TSTypeParameter> implements ts.TypeParameterDeclaration {
772
- constructor(node: arkts.TSTypeParameter) {
773
- super(node);
774
- this.name = unpackNode(node.name);
775
- }
776
-
777
- readonly name: Identifier;
778
- readonly kind: ts.SyntaxKind.TypeParameter = ts.SyntaxKind.TypeParameter;
779
-
780
- // brands
781
- _declarationBrand: any;
782
- }
783
-
784
- export abstract class TypeNode extends Node<arkts.AstNode> implements ts.TypeNode {
785
- // brands
786
- _typeNodeBrand: any;
787
- }
788
-
789
- export class KeywordTypeNode
790
- extends Node<arkts.ETSPrimitiveType | arkts.ETSTypeReference>
791
- implements ts.KeywordTypeNode, TypeNode
792
- {
793
- constructor(node: arkts.ETSPrimitiveType | arkts.ETSTypeReference) {
794
- super(node);
795
- }
796
-
797
- readonly kind: ts.KeywordTypeSyntaxKind = ts.SyntaxKind.UnknownKeyword;
798
-
799
- // brands
800
- _typeNodeBrand: any;
801
- }
802
-
803
- export class TypeReferenceNode extends Node<arkts.AstNode> implements ts.TypeReferenceNode, TypeNode {
804
- constructor(node: arkts.AstNode) {
805
- super(node);
806
- }
807
-
808
- readonly kind: ts.SyntaxKind.TypeReference = ts.SyntaxKind.TypeReference;
809
-
810
- // Improve:
811
- typeName: any;
812
-
813
- // brands
814
- _typeNodeBrand: any;
815
- }
816
-
817
- export class FunctionTypeNode
818
- extends Node<arkts.AstNode>
819
- implements ts.FunctionTypeNode, TypeNode, SignatureDeclarationBase
820
- {
821
- constructor(node: arkts.AstNode) {
822
- super(node);
823
- }
824
-
825
- readonly name?: DeclarationName;
826
- readonly kind: ts.SyntaxKind.FunctionType = ts.SyntaxKind.FunctionType;
827
-
828
- // Improve: support minimal interface
829
- parameters: any;
830
- type: any;
831
-
832
- // brands
833
- _typeNodeBrand: any;
834
- _declarationBrand: any;
835
- }
836
-
837
- export class UnionTypeNode extends Node<arkts.ETSUnionType> implements ts.UnionTypeNode, TypeNode {
838
- constructor(node: arkts.ETSUnionType) {
839
- super(node);
840
- this.types = unpackNodeArray(node.types);
841
- }
842
-
843
- readonly types: NodeArray<TypeNode>;
844
- readonly kind: ts.SyntaxKind.UnionType = ts.SyntaxKind.UnionType;
845
-
846
- // brands
847
- _typeNodeBrand: any;
848
- }
849
-
850
- export class ReturnStatement extends Node<arkts.ReturnStatement> implements ts.ReturnStatement, Statement {
851
- constructor(node: arkts.ReturnStatement) {
852
- super(node);
853
- this.expression = unpackNode(node.argument);
854
- }
855
-
856
- readonly expression: Expression | undefined;
857
- readonly kind: ts.SyntaxKind.ReturnStatement = ts.SyntaxKind.ReturnStatement;
858
-
859
- // brands
860
- _statementBrand: any;
861
- }
862
-
863
- export class IfStatement extends Node<arkts.IfStatement> implements ts.IfStatement {
864
- constructor(node: arkts.IfStatement) {
865
- super(node);
866
- }
867
-
868
- readonly kind: ts.SyntaxKind.IfStatement = ts.SyntaxKind.IfStatement;
869
-
870
- // Improve:
871
- thenStatement: any;
872
- expression: any;
873
-
874
- // brands
875
- _statementBrand: any;
876
- }
877
-
878
- export class BinaryExpression extends Node<arkts.BinaryExpression> implements ts.BinaryExpression {
879
- constructor(node: arkts.BinaryExpression) {
880
- super(node);
881
- }
882
-
883
- readonly kind: ts.SyntaxKind.BinaryExpression = ts.SyntaxKind.BinaryExpression;
884
-
885
- // Improve:
886
- left: any;
887
- right: any;
888
- operatorToken: any;
889
-
890
- // brands
891
- _expressionBrand: any;
892
- _declarationBrand: any;
893
- }
894
-
895
- export class AssignmentExpression extends Node<arkts.AssignmentExpression> implements ts.AssignmentExpression<any> {
896
- constructor(node: arkts.AssignmentExpression) {
897
- super(node);
898
- }
899
-
900
- readonly kind: ts.SyntaxKind.BinaryExpression = ts.SyntaxKind.BinaryExpression;
901
-
902
- // Improve:
903
- right: any;
904
- left: any;
905
- operatorToken: any;
906
-
907
- // brands
908
- _expressionBrand: any;
909
- _declarationBrand: any;
910
- }
911
-
912
- export class ArrowFunction extends Node<arkts.ArrowFunctionExpression> implements ts.ArrowFunction {
913
- constructor(node: arkts.ArrowFunctionExpression) {
914
- super(node);
915
- if (node.scriptFunction.body === undefined) {
916
- throwError('node.scriptFunction.body not expected to be undefined');
917
- }
918
- this.body = unpackNode(node.scriptFunction.body);
919
- this.parameters = unpackNodeArray(node.scriptFunction.parameters);
920
- }
921
-
922
- get name(): never {
923
- return throwError(`name doesn't exist for ArrowFunction`);
924
- }
925
- readonly body: Block;
926
- readonly parameters: NodeArray<ParameterDeclaration>;
927
- readonly kind: ts.SyntaxKind.ArrowFunction = ts.SyntaxKind.ArrowFunction;
928
-
929
- // Improve:
930
- equalsGreaterThanToken: any;
931
-
932
- // brands
933
- _expressionBrand: any;
934
- _functionLikeDeclarationBrand: any;
935
- _declarationBrand: any;
936
- }
937
-
938
- export class NumericLiteral extends Node<arkts.NumberLiteral> implements ts.NumericLiteral, Declaration {
939
- constructor(node: arkts.NumberLiteral) {
940
- super(node);
941
-
942
- this.text = `${node.value}`;
943
- }
944
-
945
- readonly text: string;
946
- readonly kind: ts.SyntaxKind.NumericLiteral = ts.SyntaxKind.NumericLiteral;
947
-
948
- // brands
949
- _literalExpressionBrand: any;
950
- _declarationBrand: any;
951
- _primaryExpressionBrand: any;
952
- _memberExpressionBrand: any;
953
- _leftHandSideExpressionBrand: any;
954
- _updateExpressionBrand: any;
955
- _unaryExpressionBrand: any;
956
- _expressionBrand: any;
957
- }
958
-
959
- export class SuperExpression extends Node<arkts.SuperExpression> implements ts.SuperExpression {
960
- constructor(node: arkts.SuperExpression) {
961
- super(node);
962
- }
963
-
964
- readonly kind: ts.SyntaxKind.SuperKeyword = ts.SyntaxKind.SuperKeyword;
965
-
966
- // brands
967
- _primaryExpressionBrand: any;
968
- _memberExpressionBrand: any;
969
- _leftHandSideExpressionBrand: any;
970
- _updateExpressionBrand: any;
971
- _unaryExpressionBrand: any;
972
- _expressionBrand: any;
973
- }
974
-
975
- export class HeritageClause extends Node<arkts.SuperExpression> implements ts.HeritageClause {
976
- constructor(node: arkts.SuperExpression) {
977
- super(node);
978
- }
979
-
980
- readonly kind: ts.SyntaxKind.HeritageClause = ts.SyntaxKind.HeritageClause;
981
- // token: ts.SyntaxKind.ExtendsKeyword | ts.SyntaxKind.ImplementsKeyword
982
- // types: ts.NodeArray<ts.ExpressionWithTypeArguments>
983
-
984
- // Improve:
985
- token: any;
986
- types: any;
987
- }
988
-
989
- // Improve: there is no ParenthesizedExpression in ArkTS,
990
- // so for temporary solution we're just gonna ignore this type of nodes
991
- // and replace it with Expression underneath
992
- export type ParenthesizedExpression = Expression;
993
- // export class ParenthesizedExpression extends Node<undefined> implements ts.ParenthesizedExpression {
994
- // constructor(expression: Expression) {
995
- // super(undefined)
996
- // this.expression = expression
997
- // }
998
-
999
- // readonly expression: Expression
1000
- // readonly kind: ts.SyntaxKind.ParenthesizedExpression = ts.SyntaxKind.ParenthesizedExpression
1001
-
1002
- // // brands
1003
- // _primaryExpressionBrand: any
1004
- // _memberExpressionBrand: any
1005
- // _leftHandSideExpressionBrand: any
1006
- // _updateExpressionBrand: any
1007
- // _unaryExpressionBrand: any
1008
- // _expressionBrand: any
1009
- // }
1010
-
1011
- // Improve:
1012
- export class ImportDeclaration extends Node<arkts.UnsupportedNode> implements ts.ImportDeclaration {
1013
- constructor(node: arkts.UnsupportedNode) {
1014
- super(node);
1015
- }
1016
-
1017
- readonly kind: ts.SyntaxKind.ImportDeclaration = ts.SyntaxKind.ImportDeclaration;
1018
-
1019
- // Improve:
1020
- moduleSpecifier: any;
1021
-
1022
- // brands
1023
- _statementBrand: any;
1024
- }
1025
-
1026
- // Improve:
1027
- export class ImportClause extends Node<arkts.UnsupportedNode> implements ts.ImportClause {
1028
- constructor(node: arkts.UnsupportedNode) {
1029
- super(node);
1030
- }
1031
-
1032
- readonly kind: ts.SyntaxKind.ImportClause = ts.SyntaxKind.ImportClause;
1033
-
1034
- // Improve:
1035
- isTypeOnly: any;
1036
-
1037
- // brands
1038
- _declarationBrand: any;
1039
- }
1040
-
1041
- // Improve:
1042
- export class NamedImports extends Node<arkts.UnsupportedNode> implements ts.NamedImports {
1043
- constructor(node: arkts.UnsupportedNode) {
1044
- super(node);
1045
- }
1046
-
1047
- readonly kind: ts.SyntaxKind.NamedImports = ts.SyntaxKind.NamedImports;
1048
-
1049
- // Improve:
1050
- elements: any;
1051
- }
1052
-
1053
- export class ImportSpecifier extends Node<arkts.Identifier> implements ts.ImportSpecifier {
1054
- constructor(node: arkts.Identifier) {
1055
- super(node);
1056
- this.name = unpackNode(this.node);
1057
- }
1058
-
1059
- readonly name: Identifier;
1060
- readonly kind: ts.SyntaxKind.ImportSpecifier = ts.SyntaxKind.ImportSpecifier;
1061
-
1062
- // Improve:
1063
- isTypeOnly: any;
1064
-
1065
- // brands
1066
- _declarationBrand: any;
1067
- }
1068
-
1069
- export class UnsupportedNode extends Node<arkts.AstNode> implements ts.Node {
1070
- constructor(node: arkts.AstNode) {
1071
- super(node);
1072
- }
1073
-
1074
- readonly kind: ts.SyntaxKind = SyntaxKind.Unknown;
1075
- }