@idlizer/arktscgen 2.1.2

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