arkanalyzer 1.0.5

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 (322) hide show
  1. package/LICENSE +201 -0
  2. package/README.en.md +88 -0
  3. package/README.md +98 -0
  4. package/docs/HowToCreatePR.md +55 -0
  5. package/docs/HowToHandleIssues.md +155 -0
  6. package/docs/quickstart.pdf +0 -0
  7. package/lib/Config.d.ts +26 -0
  8. package/lib/Config.d.ts.map +1 -0
  9. package/lib/Config.js +128 -0
  10. package/lib/Scene.d.ts +125 -0
  11. package/lib/Scene.d.ts.map +1 -0
  12. package/lib/Scene.js +762 -0
  13. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +28 -0
  14. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -0
  15. package/lib/callgraph/algorithm/AbstractAnalysis.js +137 -0
  16. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +11 -0
  17. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -0
  18. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +71 -0
  19. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +16 -0
  20. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -0
  21. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +147 -0
  22. package/lib/callgraph/common/Statistics.d.ts +58 -0
  23. package/lib/callgraph/common/Statistics.d.ts.map +1 -0
  24. package/lib/callgraph/common/Statistics.js +203 -0
  25. package/lib/callgraph/model/BaseGraph.d.ts +62 -0
  26. package/lib/callgraph/model/BaseGraph.d.ts.map +1 -0
  27. package/lib/callgraph/model/BaseGraph.js +158 -0
  28. package/lib/callgraph/model/CallGraph.d.ts +94 -0
  29. package/lib/callgraph/model/CallGraph.d.ts.map +1 -0
  30. package/lib/callgraph/model/CallGraph.js +339 -0
  31. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +16 -0
  32. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -0
  33. package/lib/callgraph/model/builder/CallGraphBuilder.js +106 -0
  34. package/lib/callgraph/pointerAnalysis/Context.d.ts +38 -0
  35. package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -0
  36. package/lib/callgraph/pointerAnalysis/Context.js +156 -0
  37. package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts +23 -0
  38. package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -0
  39. package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +104 -0
  40. package/lib/callgraph/pointerAnalysis/Pag.d.ts +209 -0
  41. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -0
  42. package/lib/callgraph/pointerAnalysis/Pag.js +774 -0
  43. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +88 -0
  44. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -0
  45. package/lib/callgraph/pointerAnalysis/PagBuilder.js +821 -0
  46. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +64 -0
  47. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -0
  48. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +502 -0
  49. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +9 -0
  50. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -0
  51. package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +57 -0
  52. package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +58 -0
  53. package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -0
  54. package/lib/callgraph/pointerAnalysis/PtsDS.js +234 -0
  55. package/lib/core/base/Constant.d.ts +17 -0
  56. package/lib/core/base/Constant.d.ts.map +1 -0
  57. package/lib/core/base/Constant.js +53 -0
  58. package/lib/core/base/Decorator.d.ts +15 -0
  59. package/lib/core/base/Decorator.d.ts.map +1 -0
  60. package/lib/core/base/Decorator.js +43 -0
  61. package/lib/core/base/DefUseChain.d.ts +9 -0
  62. package/lib/core/base/DefUseChain.d.ts.map +1 -0
  63. package/lib/core/base/DefUseChain.js +25 -0
  64. package/lib/core/base/Expr.d.ts +219 -0
  65. package/lib/core/base/Expr.d.ts.map +1 -0
  66. package/lib/core/base/Expr.js +896 -0
  67. package/lib/core/base/Local.d.ts +40 -0
  68. package/lib/core/base/Local.d.ts.map +1 -0
  69. package/lib/core/base/Local.js +101 -0
  70. package/lib/core/base/Position.d.ts +39 -0
  71. package/lib/core/base/Position.d.ts.map +1 -0
  72. package/lib/core/base/Position.js +86 -0
  73. package/lib/core/base/Ref.d.ts +75 -0
  74. package/lib/core/base/Ref.d.ts.map +1 -0
  75. package/lib/core/base/Ref.js +286 -0
  76. package/lib/core/base/Stmt.d.ts +109 -0
  77. package/lib/core/base/Stmt.d.ts.map +1 -0
  78. package/lib/core/base/Stmt.js +374 -0
  79. package/lib/core/base/Type.d.ts +220 -0
  80. package/lib/core/base/Type.d.ts.map +1 -0
  81. package/lib/core/base/Type.js +477 -0
  82. package/lib/core/base/Value.d.ts +11 -0
  83. package/lib/core/base/Value.d.ts.map +1 -0
  84. package/lib/core/base/Value.js +16 -0
  85. package/lib/core/common/ArkIRTransformer.d.ts +101 -0
  86. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -0
  87. package/lib/core/common/ArkIRTransformer.js +1674 -0
  88. package/lib/core/common/BodyBuilder.d.ts +10 -0
  89. package/lib/core/common/BodyBuilder.d.ts.map +1 -0
  90. package/lib/core/common/BodyBuilder.js +34 -0
  91. package/lib/core/common/Builtin.d.ts +35 -0
  92. package/lib/core/common/Builtin.d.ts.map +1 -0
  93. package/lib/core/common/Builtin.js +78 -0
  94. package/lib/core/common/CfgBuilder.d.ts +136 -0
  95. package/lib/core/common/CfgBuilder.d.ts.map +1 -0
  96. package/lib/core/common/CfgBuilder.js +1241 -0
  97. package/lib/core/common/Const.d.ts +15 -0
  98. package/lib/core/common/Const.d.ts.map +1 -0
  99. package/lib/core/common/Const.js +34 -0
  100. package/lib/core/common/DummyMainCreater.d.ts +48 -0
  101. package/lib/core/common/DummyMainCreater.d.ts.map +1 -0
  102. package/lib/core/common/DummyMainCreater.js +433 -0
  103. package/lib/core/common/EtsConst.d.ts +65 -0
  104. package/lib/core/common/EtsConst.d.ts.map +1 -0
  105. package/lib/core/common/EtsConst.js +918 -0
  106. package/lib/core/common/ExprUseReplacer.d.ts +18 -0
  107. package/lib/core/common/ExprUseReplacer.d.ts.map +1 -0
  108. package/lib/core/common/ExprUseReplacer.js +88 -0
  109. package/lib/core/common/IRUtils.d.ts +7 -0
  110. package/lib/core/common/IRUtils.d.ts.map +1 -0
  111. package/lib/core/common/IRUtils.js +39 -0
  112. package/lib/core/common/ModelUtils.d.ts +61 -0
  113. package/lib/core/common/ModelUtils.d.ts.map +1 -0
  114. package/lib/core/common/ModelUtils.js +628 -0
  115. package/lib/core/common/RefUseReplacer.d.ts +14 -0
  116. package/lib/core/common/RefUseReplacer.d.ts.map +1 -0
  117. package/lib/core/common/RefUseReplacer.js +50 -0
  118. package/lib/core/common/StmtUseReplacer.d.ts +16 -0
  119. package/lib/core/common/StmtUseReplacer.d.ts.map +1 -0
  120. package/lib/core/common/StmtUseReplacer.js +88 -0
  121. package/lib/core/common/TSConst.d.ts +11 -0
  122. package/lib/core/common/TSConst.d.ts.map +1 -0
  123. package/lib/core/common/TSConst.js +28 -0
  124. package/lib/core/common/TypeInference.d.ts +44 -0
  125. package/lib/core/common/TypeInference.d.ts.map +1 -0
  126. package/lib/core/common/TypeInference.js +519 -0
  127. package/lib/core/common/ValueUtil.d.ts +17 -0
  128. package/lib/core/common/ValueUtil.d.ts.map +1 -0
  129. package/lib/core/common/ValueUtil.js +71 -0
  130. package/lib/core/common/VisibleValue.d.ts +37 -0
  131. package/lib/core/common/VisibleValue.d.ts.map +1 -0
  132. package/lib/core/common/VisibleValue.js +212 -0
  133. package/lib/core/dataflow/DataflowProblem.d.ts +21 -0
  134. package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -0
  135. package/lib/core/dataflow/DataflowProblem.js +33 -0
  136. package/lib/core/dataflow/DataflowResult.d.ts +8 -0
  137. package/lib/core/dataflow/DataflowResult.d.ts.map +1 -0
  138. package/lib/core/dataflow/DataflowResult.js +26 -0
  139. package/lib/core/dataflow/DataflowSolver.d.ts +40 -0
  140. package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -0
  141. package/lib/core/dataflow/DataflowSolver.js +318 -0
  142. package/lib/core/dataflow/Edge.d.ts +16 -0
  143. package/lib/core/dataflow/Edge.d.ts.map +1 -0
  144. package/lib/core/dataflow/Edge.js +40 -0
  145. package/lib/core/dataflow/Fact.d.ts +7 -0
  146. package/lib/core/dataflow/Fact.d.ts.map +1 -0
  147. package/lib/core/dataflow/Fact.js +24 -0
  148. package/lib/core/dataflow/TiantAnalysis.d.ts +37 -0
  149. package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -0
  150. package/lib/core/dataflow/TiantAnalysis.js +326 -0
  151. package/lib/core/dataflow/UndefinedVariable.d.ts +32 -0
  152. package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -0
  153. package/lib/core/dataflow/UndefinedVariable.js +235 -0
  154. package/lib/core/dataflow/Util.d.ts +8 -0
  155. package/lib/core/dataflow/Util.d.ts.map +1 -0
  156. package/lib/core/dataflow/Util.js +137 -0
  157. package/lib/core/graph/BasicBlock.d.ts +26 -0
  158. package/lib/core/graph/BasicBlock.d.ts.map +1 -0
  159. package/lib/core/graph/BasicBlock.js +92 -0
  160. package/lib/core/graph/Cfg.d.ts +29 -0
  161. package/lib/core/graph/Cfg.d.ts.map +1 -0
  162. package/lib/core/graph/Cfg.js +154 -0
  163. package/lib/core/graph/DominanceFinder.d.ts +16 -0
  164. package/lib/core/graph/DominanceFinder.d.ts.map +1 -0
  165. package/lib/core/graph/DominanceFinder.js +121 -0
  166. package/lib/core/graph/DominanceTree.d.ts +13 -0
  167. package/lib/core/graph/DominanceTree.d.ts.map +1 -0
  168. package/lib/core/graph/DominanceTree.js +70 -0
  169. package/lib/core/graph/ViewTree.d.ts +115 -0
  170. package/lib/core/graph/ViewTree.d.ts.map +1 -0
  171. package/lib/core/graph/ViewTree.js +16 -0
  172. package/lib/core/graph/builder/ViewTreeBuilder.d.ts +204 -0
  173. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -0
  174. package/lib/core/graph/builder/ViewTreeBuilder.js +1046 -0
  175. package/lib/core/model/ArkBody.d.ts +22 -0
  176. package/lib/core/model/ArkBody.d.ts.map +1 -0
  177. package/lib/core/model/ArkBody.js +63 -0
  178. package/lib/core/model/ArkClass.d.ts +110 -0
  179. package/lib/core/model/ArkClass.d.ts.map +1 -0
  180. package/lib/core/model/ArkClass.js +315 -0
  181. package/lib/core/model/ArkExport.d.ts +70 -0
  182. package/lib/core/model/ArkExport.d.ts.map +1 -0
  183. package/lib/core/model/ArkExport.js +143 -0
  184. package/lib/core/model/ArkField.d.ts +60 -0
  185. package/lib/core/model/ArkField.d.ts.map +1 -0
  186. package/lib/core/model/ArkField.js +157 -0
  187. package/lib/core/model/ArkFile.d.ts +62 -0
  188. package/lib/core/model/ArkFile.d.ts.map +1 -0
  189. package/lib/core/model/ArkFile.js +160 -0
  190. package/lib/core/model/ArkImport.d.ts +43 -0
  191. package/lib/core/model/ArkImport.d.ts.map +1 -0
  192. package/lib/core/model/ArkImport.js +109 -0
  193. package/lib/core/model/ArkMethod.d.ts +76 -0
  194. package/lib/core/model/ArkMethod.d.ts.map +1 -0
  195. package/lib/core/model/ArkMethod.js +235 -0
  196. package/lib/core/model/ArkNamespace.d.ts +65 -0
  197. package/lib/core/model/ArkNamespace.d.ts.map +1 -0
  198. package/lib/core/model/ArkNamespace.js +182 -0
  199. package/lib/core/model/ArkSignature.d.ts +98 -0
  200. package/lib/core/model/ArkSignature.d.ts.map +1 -0
  201. package/lib/core/model/ArkSignature.js +281 -0
  202. package/lib/core/model/builder/ArkClassBuilder.d.ts +13 -0
  203. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -0
  204. package/lib/core/model/builder/ArkClassBuilder.js +422 -0
  205. package/lib/core/model/builder/ArkExportBuilder.d.ts +25 -0
  206. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -0
  207. package/lib/core/model/builder/ArkExportBuilder.js +207 -0
  208. package/lib/core/model/builder/ArkFieldBuilder.d.ts +9 -0
  209. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -0
  210. package/lib/core/model/builder/ArkFieldBuilder.js +189 -0
  211. package/lib/core/model/builder/ArkFileBuilder.d.ts +10 -0
  212. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -0
  213. package/lib/core/model/builder/ArkFileBuilder.js +164 -0
  214. package/lib/core/model/builder/ArkImportBuilder.d.ts +4 -0
  215. package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -0
  216. package/lib/core/model/builder/ArkImportBuilder.js +125 -0
  217. package/lib/core/model/builder/ArkMethodBuilder.d.ts +60 -0
  218. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -0
  219. package/lib/core/model/builder/ArkMethodBuilder.js +419 -0
  220. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +5 -0
  221. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
  222. package/lib/core/model/builder/ArkNamespaceBuilder.js +171 -0
  223. package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
  224. package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -0
  225. package/lib/core/model/builder/ArkSignatureBuilder.js +40 -0
  226. package/lib/core/model/builder/builderUtils.d.ts +18 -0
  227. package/lib/core/model/builder/builderUtils.d.ts.map +1 -0
  228. package/lib/core/model/builder/builderUtils.js +449 -0
  229. package/lib/index.d.ts +77 -0
  230. package/lib/index.d.ts.map +1 -0
  231. package/lib/index.js +190 -0
  232. package/lib/save/ArkStream.d.ts +24 -0
  233. package/lib/save/ArkStream.d.ts.map +1 -0
  234. package/lib/save/ArkStream.js +83 -0
  235. package/lib/save/DotPrinter.d.ts +48 -0
  236. package/lib/save/DotPrinter.d.ts.map +1 -0
  237. package/lib/save/DotPrinter.js +229 -0
  238. package/lib/save/GraphPrinter.d.ts +17 -0
  239. package/lib/save/GraphPrinter.d.ts.map +1 -0
  240. package/lib/save/GraphPrinter.js +135 -0
  241. package/lib/save/JsonPrinter.d.ts +28 -0
  242. package/lib/save/JsonPrinter.d.ts.map +1 -0
  243. package/lib/save/JsonPrinter.js +511 -0
  244. package/lib/save/Printer.d.ts +17 -0
  245. package/lib/save/Printer.d.ts.map +1 -0
  246. package/lib/save/Printer.js +27 -0
  247. package/lib/save/PrinterBuilder.d.ts +38 -0
  248. package/lib/save/PrinterBuilder.d.ts.map +1 -0
  249. package/lib/save/PrinterBuilder.js +102 -0
  250. package/lib/save/serializeArkIR.d.ts +3 -0
  251. package/lib/save/serializeArkIR.d.ts.map +1 -0
  252. package/lib/save/serializeArkIR.js +166 -0
  253. package/lib/save/source/SourceBase.d.ts +32 -0
  254. package/lib/save/source/SourceBase.d.ts.map +1 -0
  255. package/lib/save/source/SourceBase.js +93 -0
  256. package/lib/save/source/SourceBody.d.ts +60 -0
  257. package/lib/save/source/SourceBody.d.ts.map +1 -0
  258. package/lib/save/source/SourceBody.js +292 -0
  259. package/lib/save/source/SourceClass.d.ts +27 -0
  260. package/lib/save/source/SourceClass.d.ts.map +1 -0
  261. package/lib/save/source/SourceClass.js +202 -0
  262. package/lib/save/source/SourceField.d.ts +15 -0
  263. package/lib/save/source/SourceField.d.ts.map +1 -0
  264. package/lib/save/source/SourceField.js +68 -0
  265. package/lib/save/source/SourceFilePrinter.d.ts +14 -0
  266. package/lib/save/source/SourceFilePrinter.d.ts.map +1 -0
  267. package/lib/save/source/SourceFilePrinter.js +73 -0
  268. package/lib/save/source/SourceMethod.d.ts +24 -0
  269. package/lib/save/source/SourceMethod.d.ts.map +1 -0
  270. package/lib/save/source/SourceMethod.js +170 -0
  271. package/lib/save/source/SourceModule.d.ts +18 -0
  272. package/lib/save/source/SourceModule.d.ts.map +1 -0
  273. package/lib/save/source/SourceModule.js +120 -0
  274. package/lib/save/source/SourceNamespace.d.ts +13 -0
  275. package/lib/save/source/SourceNamespace.d.ts.map +1 -0
  276. package/lib/save/source/SourceNamespace.js +80 -0
  277. package/lib/save/source/SourceStmt.d.ts +172 -0
  278. package/lib/save/source/SourceStmt.d.ts.map +1 -0
  279. package/lib/save/source/SourceStmt.js +757 -0
  280. package/lib/save/source/SourceTransformer.d.ts +37 -0
  281. package/lib/save/source/SourceTransformer.d.ts.map +1 -0
  282. package/lib/save/source/SourceTransformer.js +338 -0
  283. package/lib/save/source/SourceUtils.d.ts +25 -0
  284. package/lib/save/source/SourceUtils.d.ts.map +1 -0
  285. package/lib/save/source/SourceUtils.js +201 -0
  286. package/lib/transformer/FunctionTransformer.d.ts +3 -0
  287. package/lib/transformer/FunctionTransformer.d.ts.map +1 -0
  288. package/lib/transformer/FunctionTransformer.js +17 -0
  289. package/lib/transformer/SceneTransformer.d.ts +3 -0
  290. package/lib/transformer/SceneTransformer.d.ts.map +1 -0
  291. package/lib/transformer/SceneTransformer.js +17 -0
  292. package/lib/transformer/StaticSingleAssignmentFormer.d.ts +13 -0
  293. package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -0
  294. package/lib/transformer/StaticSingleAssignmentFormer.js +259 -0
  295. package/lib/transformer/Transformer.d.ts +7 -0
  296. package/lib/transformer/Transformer.d.ts.map +1 -0
  297. package/lib/transformer/Transformer.js +22 -0
  298. package/lib/utils/CfgStructualAnalysis.d.ts +93 -0
  299. package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -0
  300. package/lib/utils/CfgStructualAnalysis.js +955 -0
  301. package/lib/utils/FileUtils.d.ts +18 -0
  302. package/lib/utils/FileUtils.d.ts.map +1 -0
  303. package/lib/utils/FileUtils.js +131 -0
  304. package/lib/utils/callGraphUtils.d.ts +31 -0
  305. package/lib/utils/callGraphUtils.d.ts.map +1 -0
  306. package/lib/utils/callGraphUtils.js +208 -0
  307. package/lib/utils/entryMethodUtils.d.ts +16 -0
  308. package/lib/utils/entryMethodUtils.d.ts.map +1 -0
  309. package/lib/utils/entryMethodUtils.js +139 -0
  310. package/lib/utils/getAllFiles.d.ts +10 -0
  311. package/lib/utils/getAllFiles.d.ts.map +1 -0
  312. package/lib/utils/getAllFiles.js +91 -0
  313. package/lib/utils/json5parser.d.ts +7 -0
  314. package/lib/utils/json5parser.d.ts.map +1 -0
  315. package/lib/utils/json5parser.js +146 -0
  316. package/lib/utils/logger.d.ts +19 -0
  317. package/lib/utils/logger.d.ts.map +1 -0
  318. package/lib/utils/logger.js +90 -0
  319. package/lib/utils/pathTransfer.d.ts +2 -0
  320. package/lib/utils/pathTransfer.d.ts.map +1 -0
  321. package/lib/utils/pathTransfer.js +25 -0
  322. package/package.json +29 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ImportInfo = void 0;
18
+ const Position_1 = require("../base/Position");
19
+ const ModelUtils_1 = require("../common/ModelUtils");
20
+ /**
21
+ * @category core/model
22
+ */
23
+ class ImportInfo {
24
+ constructor() {
25
+ this.importClauseName = '';
26
+ this.importType = '';
27
+ this.modifiers = new Set();
28
+ }
29
+ build(importClauseName, importType, importFrom, originTsPosition, modifiers, nameBeforeAs) {
30
+ this.setImportClauseName(importClauseName);
31
+ this.setImportType(importType);
32
+ this.setImportFrom(importFrom);
33
+ this.setOriginTsPosition(originTsPosition);
34
+ modifiers.forEach((modifier) => {
35
+ this.addModifier(modifier);
36
+ });
37
+ this.setNameBeforeAs(nameBeforeAs);
38
+ }
39
+ getOriginName() {
40
+ var _a;
41
+ return (_a = this.nameBeforeAs) !== null && _a !== void 0 ? _a : this.importClauseName;
42
+ }
43
+ /**
44
+ * 获取实际的引用(调用时生成)
45
+ */
46
+ getLazyExportInfo() {
47
+ if (this.lazyExportInfo === undefined) {
48
+ this.lazyExportInfo = (0, ModelUtils_1.findExportInfo)(this);
49
+ }
50
+ return this.lazyExportInfo || null;
51
+ }
52
+ setDeclaringArkFile(declaringArkFile) {
53
+ this.declaringArkFile = declaringArkFile;
54
+ }
55
+ getDeclaringArkFile() {
56
+ return this.declaringArkFile;
57
+ }
58
+ getImportClauseName() {
59
+ return this.importClauseName;
60
+ }
61
+ setImportClauseName(importClauseName) {
62
+ this.importClauseName = importClauseName;
63
+ }
64
+ getImportType() {
65
+ return this.importType;
66
+ }
67
+ setImportType(importType) {
68
+ this.importType = importType;
69
+ }
70
+ setImportFrom(importFrom) {
71
+ this.importFrom = importFrom;
72
+ }
73
+ getNameBeforeAs() {
74
+ return this.nameBeforeAs;
75
+ }
76
+ setNameBeforeAs(nameBeforeAs) {
77
+ this.nameBeforeAs = nameBeforeAs;
78
+ }
79
+ getModifiers() {
80
+ return this.modifiers;
81
+ }
82
+ addModifier(name) {
83
+ this.modifiers.add(name);
84
+ }
85
+ setOriginTsPosition(originTsPosition) {
86
+ this.originTsPosition = originTsPosition;
87
+ }
88
+ getOriginTsPosition() {
89
+ var _a;
90
+ return (_a = this.originTsPosition) !== null && _a !== void 0 ? _a : Position_1.LineColPosition.DEFAULT;
91
+ }
92
+ setTsSourceCode(tsSourceCode) {
93
+ this.tsSourceCode = tsSourceCode;
94
+ }
95
+ getTsSourceCode() {
96
+ var _a;
97
+ return (_a = this.tsSourceCode) !== null && _a !== void 0 ? _a : '';
98
+ }
99
+ getFrom() {
100
+ return this.importFrom;
101
+ }
102
+ isDefault() {
103
+ if (this.nameBeforeAs === 'default') {
104
+ return true;
105
+ }
106
+ return this.importType === 'Identifier';
107
+ }
108
+ }
109
+ exports.ImportInfo = ImportInfo;
@@ -0,0 +1,76 @@
1
+ import { Stmt } from '../base/Stmt';
2
+ import { GenericType } from '../base/Type';
3
+ import { Value } from '../base/Value';
4
+ import { Cfg } from '../graph/Cfg';
5
+ import { ViewTree } from '../graph/ViewTree';
6
+ import { ArkBody } from './ArkBody';
7
+ import { ArkClass } from './ArkClass';
8
+ import { MethodSignature } from './ArkSignature';
9
+ import { Decorator } from '../base/Decorator';
10
+ import { BodyBuilder } from '../common/BodyBuilder';
11
+ import { ArkExport, ExportType } from './ArkExport';
12
+ export declare const arkMethodNodeKind: string[];
13
+ /**
14
+ * @category core/model
15
+ */
16
+ export declare class ArkMethod implements ArkExport {
17
+ private code;
18
+ private line;
19
+ private column;
20
+ private declaringArkClass;
21
+ private modifiers;
22
+ private genericTypes?;
23
+ private methodSignature;
24
+ private body?;
25
+ private viewTree?;
26
+ private bodyBuilder?;
27
+ private isGeneratedFlag;
28
+ private asteriskToken;
29
+ constructor();
30
+ getExportType(): ExportType;
31
+ getName(): string;
32
+ getCode(): string;
33
+ setCode(code: string): void;
34
+ getLine(): number;
35
+ setLine(line: number): void;
36
+ getColumn(): number;
37
+ setColumn(column: number): void;
38
+ getDeclaringArkClass(): ArkClass;
39
+ setDeclaringArkClass(declaringArkClass: ArkClass): void;
40
+ getDeclaringArkFile(): import("./ArkFile").ArkFile;
41
+ isExported(): boolean;
42
+ isStatic(): boolean;
43
+ isDefaultArkMethod(): boolean;
44
+ isAnonymousMethod(): boolean;
45
+ getParameters(): import("./builder/ArkMethodBuilder").MethodParameter[];
46
+ getReturnType(): import("../base/Type").Type;
47
+ getSignature(): MethodSignature;
48
+ setSignature(methodSignature: MethodSignature): void;
49
+ getSubSignature(): import("./ArkSignature").MethodSubSignature;
50
+ getModifiers(): Set<string | Decorator>;
51
+ addModifier(name: string | Decorator): void;
52
+ getGenericTypes(): GenericType[] | undefined;
53
+ isGenericsMethod(): boolean;
54
+ setGenericTypes(genericTypes: GenericType[]): void;
55
+ containsModifier(name: string): boolean;
56
+ getBody(): ArkBody | undefined;
57
+ setBody(body: ArkBody): void;
58
+ getCfg(): Cfg | undefined;
59
+ getOriginalCfg(): Cfg | undefined;
60
+ getParameterInstances(): Value[];
61
+ getThisInstance(): Value | null;
62
+ getReturnValues(): Value[];
63
+ getReturnStmt(): Stmt[];
64
+ getDecorators(): Decorator[];
65
+ hasBuilderDecorator(): boolean;
66
+ setViewTree(viewTree: ViewTree): void;
67
+ getViewTree(): ViewTree | undefined;
68
+ hasViewTree(): boolean;
69
+ setBodyBuilder(bodyBuilder: BodyBuilder): void;
70
+ buildBody(): void;
71
+ isGenerated(): boolean;
72
+ setIsGeneratedFlag(isGeneratedFlag: boolean): void;
73
+ getAsteriskToken(): boolean;
74
+ setAsteriskToken(asteriskToken: boolean): void;
75
+ }
76
+ //# sourceMappingURL=ArkMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArkMethod.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkMethod.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAgC,IAAI,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpD,eAAO,MAAM,iBAAiB,UACqF,CAAC;AAEpH;;GAEG;AACH,qBAAa,SAAU,YAAW,SAAS;IACvC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAAc;IAE5B,OAAO,CAAC,iBAAiB,CAAY;IAErC,OAAO,CAAC,SAAS,CAA0D;IAC3E,OAAO,CAAC,YAAY,CAAC,CAAgB;IAErC,OAAO,CAAC,eAAe,CAAmB;IAE1C,OAAO,CAAC,IAAI,CAAC,CAAU;IACvB,OAAO,CAAC,QAAQ,CAAC,CAAW;IAE5B,OAAO,CAAC,WAAW,CAAC,CAAc;IAElC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAkB;;IAKvC,aAAa,IAAI,UAAU;IAIpB,OAAO;IAIP,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,oBAAoB;IAIpB,oBAAoB,CAAC,iBAAiB,EAAE,QAAQ;IAIhD,mBAAmB;IAInB,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,OAAO;IAOnB,kBAAkB,IAAI,OAAO;IAI7B,iBAAiB,IAAI,OAAO;IAI5B,aAAa;IAIb,aAAa;IAIb,YAAY;IAIZ,YAAY,CAAC,eAAe,EAAE,eAAe;IAI7C,eAAe;IAIf,YAAY;IAIZ,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAIpC,eAAe,IAAI,WAAW,EAAE,GAAG,SAAS;IAI5C,gBAAgB,IAAI,OAAO;IAI3B,eAAe,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI;IAIlD,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,OAAO,IAAI,OAAO,GAAG,SAAS;IAI9B,OAAO,CAAC,IAAI,EAAE,OAAO;IAIrB,MAAM,IAAI,GAAG,GAAG,SAAS;IAIzB,cAAc,IAAI,GAAG,GAAG,SAAS;IAIjC,qBAAqB,IAAI,KAAK,EAAE;IAqBhC,eAAe,IAAI,KAAK,GAAG,IAAI;IAiB/B,eAAe,IAAI,KAAK,EAAE;IAgB1B,aAAa,IAAI,IAAI,EAAE;IAIvB,aAAa,IAAI,SAAS,EAAE;IAM5B,mBAAmB,IAAI,OAAO;IAO9B,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAI9B,WAAW,IAAI,QAAQ,GAAG,SAAS;IAInC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,WAAW,EAAE,WAAW;IAOvC,SAAS;IAYT,WAAW,IAAI,OAAO;IAItB,kBAAkB,CAAC,eAAe,EAAE,OAAO;IAI3C,gBAAgB,IAAI,OAAO;IAI3B,gBAAgB,CAAC,aAAa,EAAE,OAAO;CAGjD"}
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ArkMethod = exports.arkMethodNodeKind = void 0;
18
+ const Ref_1 = require("../base/Ref");
19
+ const Stmt_1 = require("../base/Stmt");
20
+ const Decorator_1 = require("../base/Decorator");
21
+ const ArkExport_1 = require("./ArkExport");
22
+ const Const_1 = require("../common/Const");
23
+ exports.arkMethodNodeKind = ['MethodDeclaration', 'Constructor', 'FunctionDeclaration', 'GetAccessor',
24
+ 'SetAccessor', 'ArrowFunction', 'FunctionExpression', 'MethodSignature', 'ConstructSignature', 'CallSignature'];
25
+ /**
26
+ * @category core/model
27
+ */
28
+ class ArkMethod {
29
+ constructor() {
30
+ this.code = '';
31
+ this.line = -1;
32
+ this.column = -1;
33
+ this.modifiers = new Set();
34
+ this.isGeneratedFlag = false;
35
+ this.asteriskToken = false;
36
+ }
37
+ getExportType() {
38
+ return ArkExport_1.ExportType.METHOD;
39
+ }
40
+ getName() {
41
+ return this.methodSignature.getMethodSubSignature().getMethodName();
42
+ }
43
+ getCode() {
44
+ return this.code;
45
+ }
46
+ setCode(code) {
47
+ this.code = code;
48
+ }
49
+ getLine() {
50
+ return this.line;
51
+ }
52
+ setLine(line) {
53
+ this.line = line;
54
+ }
55
+ getColumn() {
56
+ return this.column;
57
+ }
58
+ setColumn(column) {
59
+ this.column = column;
60
+ }
61
+ getDeclaringArkClass() {
62
+ return this.declaringArkClass;
63
+ }
64
+ setDeclaringArkClass(declaringArkClass) {
65
+ this.declaringArkClass = declaringArkClass;
66
+ }
67
+ getDeclaringArkFile() {
68
+ return this.declaringArkClass.getDeclaringArkFile();
69
+ }
70
+ isExported() {
71
+ return this.modifiers.has('ExportKeyword');
72
+ }
73
+ isStatic() {
74
+ if (this.modifiers.has('StaticKeyword')) {
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+ isDefaultArkMethod() {
80
+ return this.getName() === Const_1.DEFAULT_ARK_METHOD_NAME;
81
+ }
82
+ isAnonymousMethod() {
83
+ return this.getName().startsWith(Const_1.ANONYMOUS_METHOD_PREFIX);
84
+ }
85
+ getParameters() {
86
+ return this.methodSignature.getMethodSubSignature().getParameters();
87
+ }
88
+ getReturnType() {
89
+ return this.methodSignature.getType();
90
+ }
91
+ getSignature() {
92
+ return this.methodSignature;
93
+ }
94
+ setSignature(methodSignature) {
95
+ this.methodSignature = methodSignature;
96
+ }
97
+ getSubSignature() {
98
+ return this.methodSignature.getMethodSubSignature();
99
+ }
100
+ getModifiers() {
101
+ return this.modifiers;
102
+ }
103
+ addModifier(name) {
104
+ this.modifiers.add(name);
105
+ }
106
+ getGenericTypes() {
107
+ return this.genericTypes;
108
+ }
109
+ isGenericsMethod() {
110
+ return this.genericTypes != undefined;
111
+ }
112
+ setGenericTypes(genericTypes) {
113
+ this.genericTypes = genericTypes;
114
+ }
115
+ containsModifier(name) {
116
+ return this.modifiers.has(name);
117
+ }
118
+ getBody() {
119
+ return this.body;
120
+ }
121
+ setBody(body) {
122
+ this.body = body;
123
+ }
124
+ getCfg() {
125
+ var _a;
126
+ return (_a = this.body) === null || _a === void 0 ? void 0 : _a.getCfg();
127
+ }
128
+ getOriginalCfg() {
129
+ var _a;
130
+ return (_a = this.body) === null || _a === void 0 ? void 0 : _a.getOriginalCfg();
131
+ }
132
+ getParameterInstances() {
133
+ // 获取方法体中参数Local实例
134
+ let stmts = [];
135
+ if (this.getCfg()) {
136
+ const cfg = this.getCfg();
137
+ stmts.push(...cfg.getStmts());
138
+ }
139
+ let results = [];
140
+ for (let stmt of stmts) {
141
+ if (stmt instanceof Stmt_1.ArkAssignStmt) {
142
+ if (stmt.getRightOp() instanceof Ref_1.ArkParameterRef) {
143
+ results.push(stmt.getLeftOp());
144
+ }
145
+ }
146
+ if (results.length == this.getParameters().length) {
147
+ return results;
148
+ }
149
+ }
150
+ return results;
151
+ }
152
+ getThisInstance() {
153
+ // 获取方法体中This实例
154
+ let stmts = [];
155
+ if (this.getCfg()) {
156
+ const cfg = this.getCfg();
157
+ stmts.push(...cfg.getStmts());
158
+ }
159
+ for (let stmt of stmts) {
160
+ if (stmt instanceof Stmt_1.ArkAssignStmt) {
161
+ if (stmt.getRightOp() instanceof Ref_1.ArkThisRef) {
162
+ return stmt.getLeftOp();
163
+ }
164
+ }
165
+ }
166
+ return null;
167
+ }
168
+ getReturnValues() {
169
+ // 获取方法体中return值实例
170
+ let resultValues = [];
171
+ let stmts = [];
172
+ if (this.getCfg()) {
173
+ const cfg = this.getCfg();
174
+ stmts.push(...cfg.getStmts());
175
+ }
176
+ for (let stmt of stmts) {
177
+ if (stmt instanceof Stmt_1.ArkReturnStmt) {
178
+ resultValues.push(stmt.getOp());
179
+ }
180
+ }
181
+ return resultValues;
182
+ }
183
+ getReturnStmt() {
184
+ return this.getCfg().getStmts().filter(stmt => stmt instanceof Stmt_1.ArkReturnStmt);
185
+ }
186
+ getDecorators() {
187
+ return Array.from(this.modifiers).filter((item) => {
188
+ return item instanceof Decorator_1.Decorator;
189
+ });
190
+ }
191
+ hasBuilderDecorator() {
192
+ let decorators = this.getDecorators();
193
+ return decorators.filter((value) => {
194
+ return value.getKind() == 'Builder';
195
+ }).length != 0;
196
+ }
197
+ setViewTree(viewTree) {
198
+ this.viewTree = viewTree;
199
+ }
200
+ getViewTree() {
201
+ return this.viewTree;
202
+ }
203
+ hasViewTree() {
204
+ return this.viewTree != undefined;
205
+ }
206
+ setBodyBuilder(bodyBuilder) {
207
+ this.bodyBuilder = bodyBuilder;
208
+ if (this.getDeclaringArkFile().getScene().buildClassDone()) {
209
+ this.buildBody();
210
+ }
211
+ }
212
+ buildBody() {
213
+ if (this.bodyBuilder) {
214
+ const arkBody = this.bodyBuilder.build();
215
+ if (arkBody) {
216
+ this.setBody(arkBody);
217
+ arkBody.getCfg().setDeclaringMethod(this);
218
+ }
219
+ this.bodyBuilder = undefined;
220
+ }
221
+ }
222
+ isGenerated() {
223
+ return this.isGeneratedFlag;
224
+ }
225
+ setIsGeneratedFlag(isGeneratedFlag) {
226
+ this.isGeneratedFlag = isGeneratedFlag;
227
+ }
228
+ getAsteriskToken() {
229
+ return this.asteriskToken;
230
+ }
231
+ setAsteriskToken(asteriskToken) {
232
+ this.asteriskToken = asteriskToken;
233
+ }
234
+ }
235
+ exports.ArkMethod = ArkMethod;
@@ -0,0 +1,65 @@
1
+ import { Decorator } from '../base/Decorator';
2
+ import { ArkExport, ExportInfo, ExportType } from './ArkExport';
3
+ import { ArkClass } from './ArkClass';
4
+ import { ArkFile } from './ArkFile';
5
+ import { ArkMethod } from './ArkMethod';
6
+ import { ClassSignature, NamespaceSignature } from './ArkSignature';
7
+ /**
8
+ * @category core/model
9
+ */
10
+ export declare class ArkNamespace implements ArkExport {
11
+ private code;
12
+ private line;
13
+ private column;
14
+ private declaringArkFile;
15
+ private declaringArkNamespace;
16
+ private declaringInstance;
17
+ private modifiers;
18
+ private exportInfos;
19
+ private defaultClass;
20
+ private namespaces;
21
+ private classes;
22
+ private namespaceSignature;
23
+ private anonymousClassNumber;
24
+ constructor();
25
+ addNamespace(namespace: ArkNamespace): void;
26
+ getNamespace(namespaceSignature: NamespaceSignature): ArkNamespace | null;
27
+ getNamespaceWithName(namespaceName: string): ArkNamespace | null;
28
+ getNamespaces(): ArkNamespace[];
29
+ setSignature(namespaceSignature: NamespaceSignature): void;
30
+ getSignature(): NamespaceSignature;
31
+ getNamespaceSignature(): NamespaceSignature;
32
+ getName(): string;
33
+ getCode(): string;
34
+ setCode(code: string): void;
35
+ getLine(): number;
36
+ setLine(line: number): void;
37
+ getColumn(): number;
38
+ setColumn(column: number): void;
39
+ getDeclaringInstance(): ArkFile | ArkNamespace;
40
+ setDeclaringInstance(declaringInstance: ArkFile | ArkNamespace): void;
41
+ getDeclaringArkFile(): ArkFile;
42
+ setDeclaringArkFile(declaringArkFile: ArkFile): void;
43
+ getDeclaringArkNamespace(): ArkNamespace | null;
44
+ setDeclaringArkNamespace(declaringArkNamespace: ArkNamespace): void;
45
+ getModifiers(): Set<string | Decorator>;
46
+ addModifier(name: string | Decorator): void;
47
+ containsModifier(name: string): boolean;
48
+ getClass(classSignature: ClassSignature): ArkClass | null;
49
+ getClassWithName(Class: string): ArkClass | null;
50
+ getClasses(): ArkClass[];
51
+ addArkClass(arkClass: ArkClass): void;
52
+ isExported(): boolean;
53
+ getExportInfos(): ExportInfo[];
54
+ getExportInfoBy(name: string): ExportInfo | undefined;
55
+ addExportInfo(exportInfo: ExportInfo): void;
56
+ getDefaultClass(): ArkClass;
57
+ setDefaultClass(defaultClass: ArkClass): void;
58
+ getAllMethodsUnderThisNamespace(): ArkMethod[];
59
+ getAllClassesUnderThisNamespace(): ArkClass[];
60
+ getAllNamespacesUnderThisNamespace(): ArkNamespace[];
61
+ getDecorators(): Decorator[];
62
+ getAnonymousClassNumber(): number;
63
+ getExportType(): ExportType;
64
+ }
65
+ //# sourceMappingURL=ArkNamespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpE;;GAEG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC1C,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAAc;IAE5B,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,qBAAqB,CAA6B;IAE1D,OAAO,CAAC,iBAAiB,CAA0B;IAEnD,OAAO,CAAC,SAAS,CAA0D;IAC3E,OAAO,CAAC,WAAW,CAA0D;IAE7E,OAAO,CAAC,YAAY,CAAY;IAGhC,OAAO,CAAC,UAAU,CAA8D;IAChF,OAAO,CAAC,OAAO,CAAsD;IAErE,OAAO,CAAC,kBAAkB,CAAsB;IAEhD,OAAO,CAAC,oBAAoB,CAAa;;IAKlC,YAAY,CAAC,SAAS,EAAE,YAAY;IAIpC,YAAY,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI;IAKzE,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAIhE,aAAa,IAAI,YAAY,EAAE;IAI/B,YAAY,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI;IAI1D,YAAY;IAIZ,qBAAqB;IAIrB,OAAO;IAIP,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,oBAAoB;IAIpB,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,YAAY;IAI9D,mBAAmB;IAInB,mBAAmB,CAAC,gBAAgB,EAAE,OAAO;IAI7C,wBAAwB;IAIxB,wBAAwB,CAAC,qBAAqB,EAAE,YAAY;IAI5D,YAAY;IAIZ,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAIpC,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAKzD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAIhD,UAAU,IAAI,QAAQ,EAAE;IAIxB,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAI9B,UAAU,IAAI,OAAO;IAIrB,cAAc,IAAI,UAAU,EAAE;IAU9B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIrD,aAAa,CAAC,UAAU,EAAE,UAAU;IAIpC,eAAe;IAIf,eAAe,CAAC,YAAY,EAAE,QAAQ;IAItC,+BAA+B,IAAI,SAAS,EAAE;IAW9C,+BAA+B,IAAI,QAAQ,EAAE;IAS7C,kCAAkC,IAAI,YAAY,EAAE;IASpD,aAAa,IAAI,SAAS,EAAE;IAM5B,uBAAuB;IAI9B,aAAa,IAAI,UAAU;CAG9B"}
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ArkNamespace = void 0;
18
+ const Decorator_1 = require("../base/Decorator");
19
+ const ArkExport_1 = require("./ArkExport");
20
+ const TSConst_1 = require("../common/TSConst");
21
+ /**
22
+ * @category core/model
23
+ */
24
+ class ArkNamespace {
25
+ constructor() {
26
+ this.code = '';
27
+ this.line = -1;
28
+ this.column = -1;
29
+ this.declaringArkNamespace = null;
30
+ this.modifiers = new Set();
31
+ this.exportInfos = new Map();
32
+ // name to model
33
+ this.namespaces = new Map(); // don't contain nested namespace
34
+ this.classes = new Map();
35
+ this.anonymousClassNumber = 0;
36
+ }
37
+ addNamespace(namespace) {
38
+ this.namespaces.set(namespace.getName(), namespace);
39
+ }
40
+ getNamespace(namespaceSignature) {
41
+ const namespaceName = namespaceSignature.getNamespaceName();
42
+ return this.getNamespaceWithName(namespaceName);
43
+ }
44
+ getNamespaceWithName(namespaceName) {
45
+ return this.namespaces.get(namespaceName) || null;
46
+ }
47
+ getNamespaces() {
48
+ return Array.from(this.namespaces.values());
49
+ }
50
+ setSignature(namespaceSignature) {
51
+ this.namespaceSignature = namespaceSignature;
52
+ }
53
+ getSignature() {
54
+ return this.namespaceSignature;
55
+ }
56
+ getNamespaceSignature() {
57
+ return this.namespaceSignature;
58
+ }
59
+ getName() {
60
+ return this.namespaceSignature.getNamespaceName();
61
+ }
62
+ getCode() {
63
+ return this.code;
64
+ }
65
+ setCode(code) {
66
+ this.code = code;
67
+ }
68
+ getLine() {
69
+ return this.line;
70
+ }
71
+ setLine(line) {
72
+ this.line = line;
73
+ }
74
+ getColumn() {
75
+ return this.column;
76
+ }
77
+ setColumn(column) {
78
+ this.column = column;
79
+ }
80
+ getDeclaringInstance() {
81
+ return this.declaringInstance;
82
+ }
83
+ setDeclaringInstance(declaringInstance) {
84
+ this.declaringInstance = declaringInstance;
85
+ }
86
+ getDeclaringArkFile() {
87
+ return this.declaringArkFile;
88
+ }
89
+ setDeclaringArkFile(declaringArkFile) {
90
+ this.declaringArkFile = declaringArkFile;
91
+ }
92
+ getDeclaringArkNamespace() {
93
+ return this.declaringArkNamespace;
94
+ }
95
+ setDeclaringArkNamespace(declaringArkNamespace) {
96
+ this.declaringArkNamespace = declaringArkNamespace;
97
+ }
98
+ getModifiers() {
99
+ return this.modifiers;
100
+ }
101
+ addModifier(name) {
102
+ this.modifiers.add(name);
103
+ }
104
+ containsModifier(name) {
105
+ return this.modifiers.has(name);
106
+ }
107
+ getClass(classSignature) {
108
+ const className = classSignature.getClassName();
109
+ return this.getClassWithName(className);
110
+ }
111
+ getClassWithName(Class) {
112
+ return this.classes.get(Class) || null;
113
+ }
114
+ getClasses() {
115
+ return Array.from(this.classes.values());
116
+ }
117
+ addArkClass(arkClass) {
118
+ this.classes.set(arkClass.getName(), arkClass);
119
+ }
120
+ isExported() {
121
+ return this.containsModifier('ExportKeyword');
122
+ }
123
+ getExportInfos() {
124
+ const exportInfos = [];
125
+ this.exportInfos.forEach((value, key) => {
126
+ if (key !== TSConst_1.ALL || value.getFrom()) {
127
+ exportInfos.push(value);
128
+ }
129
+ });
130
+ return exportInfos;
131
+ }
132
+ getExportInfoBy(name) {
133
+ return this.exportInfos.get(name);
134
+ }
135
+ addExportInfo(exportInfo) {
136
+ this.exportInfos.set(exportInfo.getExportClauseName(), exportInfo);
137
+ }
138
+ getDefaultClass() {
139
+ return this.defaultClass;
140
+ }
141
+ setDefaultClass(defaultClass) {
142
+ this.defaultClass = defaultClass;
143
+ }
144
+ getAllMethodsUnderThisNamespace() {
145
+ let methods = [];
146
+ this.classes.forEach((cls) => {
147
+ methods.push(...cls.getMethods());
148
+ });
149
+ this.namespaces.forEach((ns) => {
150
+ methods.push(...ns.getAllMethodsUnderThisNamespace());
151
+ });
152
+ return methods;
153
+ }
154
+ getAllClassesUnderThisNamespace() {
155
+ let classes = [];
156
+ classes.push(...this.classes.values());
157
+ this.namespaces.forEach((ns) => {
158
+ classes.push(...ns.getAllClassesUnderThisNamespace());
159
+ });
160
+ return classes;
161
+ }
162
+ getAllNamespacesUnderThisNamespace() {
163
+ let namespaces = [];
164
+ namespaces.push(...this.namespaces.values());
165
+ this.namespaces.forEach((ns) => {
166
+ namespaces.push(...ns.getAllNamespacesUnderThisNamespace());
167
+ });
168
+ return namespaces;
169
+ }
170
+ getDecorators() {
171
+ return Array.from(this.modifiers).filter((item) => {
172
+ return item instanceof Decorator_1.Decorator;
173
+ });
174
+ }
175
+ getAnonymousClassNumber() {
176
+ return this.anonymousClassNumber++;
177
+ }
178
+ getExportType() {
179
+ return ArkExport_1.ExportType.NAME_SPACE;
180
+ }
181
+ }
182
+ exports.ArkNamespace = ArkNamespace;