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,628 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ var desc = Object.getOwnPropertyDescriptor(m, k);
19
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
+ desc = { enumerable: true, get: function() { return m[k]; } };
21
+ }
22
+ Object.defineProperty(o, k2, desc);
23
+ }) : (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ o[k2] = m[k];
26
+ }));
27
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
29
+ }) : function(o, v) {
30
+ o["default"] = v;
31
+ });
32
+ var __importStar = (this && this.__importStar) || function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.findArkExportInFile = exports.findExportInfo = exports.getArkFile = exports.ModelUtils = void 0;
44
+ const Local_1 = require("../base/Local");
45
+ const ArkClass_1 = require("../model/ArkClass");
46
+ const ArkMethod_1 = require("../model/ArkMethod");
47
+ const ArkNamespace_1 = require("../model/ArkNamespace");
48
+ const ArkSignature_1 = require("../model/ArkSignature");
49
+ const ArkExport_1 = require("../model/ArkExport");
50
+ const logger_1 = __importStar(require("../../utils/logger"));
51
+ const FileUtils_1 = require("../../utils/FileUtils");
52
+ const path_1 = __importDefault(require("path"));
53
+ const pathTransfer_1 = require("../../utils/pathTransfer");
54
+ const TSConst_1 = require("./TSConst");
55
+ const ArkExportBuilder_1 = require("../model/builder/ArkExportBuilder");
56
+ const EtsConst_1 = require("./EtsConst");
57
+ const Type_1 = require("../base/Type");
58
+ class ModelUtils {
59
+ static getMethodSignatureFromArkClass(arkClass, methodName) {
60
+ for (const arkMethod of arkClass.getMethods()) {
61
+ if (arkMethod.getName() == methodName) {
62
+ return arkMethod.getSignature();
63
+ }
64
+ }
65
+ return null;
66
+ }
67
+ static getClassWithNameInNamespaceRecursively(className, ns) {
68
+ if (className == '') {
69
+ return null;
70
+ }
71
+ let res = null;
72
+ res = ns.getClassWithName(className);
73
+ if (res == null) {
74
+ let declaringNs = ns.getDeclaringArkNamespace();
75
+ if (declaringNs != null) {
76
+ res = this.getClassWithNameInNamespaceRecursively(className, declaringNs);
77
+ }
78
+ else {
79
+ res = this.getClassInFileWithName(className, ns.getDeclaringArkFile());
80
+ }
81
+ }
82
+ return res;
83
+ }
84
+ static getClassWithNameFromClass(className, startFrom) {
85
+ if (!className.includes('.')) {
86
+ let res = null;
87
+ const arkNamespace = startFrom.getDeclaringArkNamespace();
88
+ if (arkNamespace) {
89
+ res = this.getClassWithNameInNamespaceRecursively(className, arkNamespace);
90
+ }
91
+ else {
92
+ res = this.getClassInFileWithName(className, startFrom.getDeclaringArkFile());
93
+ }
94
+ return res;
95
+ }
96
+ else {
97
+ const names = className.split('.');
98
+ let nameSpace = this.getNamespaceWithNameFromClass(names[0], startFrom);
99
+ for (let i = 1; i < names.length - 1; i++) {
100
+ if (nameSpace)
101
+ nameSpace = nameSpace.getNamespaceWithName(names[i]);
102
+ }
103
+ if (nameSpace) {
104
+ return nameSpace.getClassWithName(names[names.length - 1]);
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+ /**
110
+ * search class within the file that contain the given method
111
+ */
112
+ static getClassWithName(className, thisClass) {
113
+ var _a;
114
+ if (thisClass.getName() == className) {
115
+ return thisClass;
116
+ }
117
+ let classSearched = (_a = thisClass.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getClassWithName(className);
118
+ if (!classSearched) {
119
+ classSearched = thisClass.getDeclaringArkFile().getClassWithName(className);
120
+ }
121
+ return classSearched;
122
+ }
123
+ /** search class within the given file */
124
+ static getClassInFileWithName(className, arkFile) {
125
+ let classSearched = arkFile.getClassWithName(className);
126
+ if (classSearched != null) {
127
+ return classSearched;
128
+ }
129
+ return null;
130
+ }
131
+ static getClassInImportInfoWithName(className, arkFile) {
132
+ let arkExport = this.getArkExportInImportInfoWithName(className, arkFile);
133
+ if (arkExport instanceof ArkClass_1.ArkClass) {
134
+ return arkExport;
135
+ }
136
+ return null;
137
+ }
138
+ /** search type within the given file import infos */
139
+ static getArkExportInImportInfoWithName(name, arkFile) {
140
+ var _a, _b, _c;
141
+ return (_c = (_b = (_a = arkFile.getImportInfoBy(name)) === null || _a === void 0 ? void 0 : _a.getLazyExportInfo()) === null || _b === void 0 ? void 0 : _b.getArkExport()) !== null && _c !== void 0 ? _c : null;
142
+ }
143
+ /** search method within the file that contain the given method */
144
+ static getMethodWithName(methodName, startFrom) {
145
+ if (!methodName.includes('.')) {
146
+ if (startFrom.getName() == methodName) {
147
+ return startFrom;
148
+ }
149
+ const thisClass = startFrom.getDeclaringArkClass();
150
+ let methodSearched = thisClass.getMethodWithName(methodName);
151
+ if (!methodSearched) {
152
+ methodSearched = thisClass.getStaticMethodWithName(methodName);
153
+ }
154
+ return methodSearched;
155
+ }
156
+ else {
157
+ const names = methodName.split('.');
158
+ let nameSpace = this.getNamespaceWithName(names[0], startFrom.getDeclaringArkClass());
159
+ for (let i = 1; i < names.length - 1; i++) {
160
+ if (nameSpace) {
161
+ nameSpace = nameSpace.getNamespaceWithName(names[i]);
162
+ }
163
+ }
164
+ if (nameSpace) {
165
+ return nameSpace.getDefaultClass().getMethodWithName(names[names.length - 1]);
166
+ }
167
+ }
168
+ return null;
169
+ }
170
+ static getNamespaceWithNameFromClass(namespaceName, startFrom) {
171
+ const thisNamespace = startFrom.getDeclaringArkNamespace();
172
+ let namespaceSearched = null;
173
+ if (thisNamespace) {
174
+ namespaceSearched = thisNamespace.getNamespaceWithName(namespaceName);
175
+ if (namespaceSearched) {
176
+ return namespaceSearched;
177
+ }
178
+ }
179
+ const thisFile = startFrom.getDeclaringArkFile();
180
+ namespaceSearched = this.getNamespaceInFileWithName(namespaceName, thisFile);
181
+ return namespaceSearched;
182
+ }
183
+ static getNamespaceWithName(namespaceName, thisClass) {
184
+ const thisNamespace = thisClass.getDeclaringArkNamespace();
185
+ let namespaceSearched = null;
186
+ if (thisNamespace) {
187
+ namespaceSearched = thisNamespace.getNamespaceWithName(namespaceName);
188
+ }
189
+ if (!namespaceSearched) {
190
+ namespaceSearched = thisClass.getDeclaringArkFile().getNamespaceWithName(namespaceName);
191
+ }
192
+ return namespaceSearched;
193
+ }
194
+ static getNamespaceInFileWithName(namespaceName, arkFile) {
195
+ let namespaceSearched = arkFile.getNamespaceWithName(namespaceName);
196
+ if (namespaceSearched) {
197
+ return namespaceSearched;
198
+ }
199
+ return null;
200
+ }
201
+ static getNamespaceInImportInfoWithName(namespaceName, arkFile) {
202
+ let arkExport = this.getArkExportInImportInfoWithName(namespaceName, arkFile);
203
+ if (arkExport instanceof ArkNamespace_1.ArkNamespace) {
204
+ return arkExport;
205
+ }
206
+ return null;
207
+ }
208
+ static getStaticMethodWithName(methodName, thisClass) {
209
+ const thisNamespace = thisClass.getDeclaringArkNamespace();
210
+ if (thisNamespace) {
211
+ const defaultClass = thisNamespace.getClassWithName('_DEFAULT_ARK_CLASS');
212
+ if (defaultClass) {
213
+ const method = defaultClass.getMethodWithName(methodName);
214
+ if (method) {
215
+ return method;
216
+ }
217
+ }
218
+ }
219
+ return this.getStaticMethodInFileWithName(methodName, thisClass.getDeclaringArkFile());
220
+ }
221
+ static getStaticMethodInFileWithName(methodName, arkFile) {
222
+ const defaultClass = arkFile.getClasses().find(cls => cls.getName() == '_DEFAULT_ARK_CLASS') || null;
223
+ if (defaultClass) {
224
+ let method = defaultClass.getMethodWithName(methodName);
225
+ if (method) {
226
+ return method;
227
+ }
228
+ }
229
+ return null;
230
+ }
231
+ static getStaticMethodInImportInfoWithName(methodName, arkFile) {
232
+ let arkExport = this.getArkExportInImportInfoWithName(methodName, arkFile);
233
+ if (arkExport instanceof ArkMethod_1.ArkMethod) {
234
+ return arkExport;
235
+ }
236
+ return null;
237
+ }
238
+ static getLocalInImportInfoWithName(localName, arkFile) {
239
+ let arkExport = this.getArkExportInImportInfoWithName(localName, arkFile);
240
+ if (arkExport instanceof Local_1.Local) {
241
+ return arkExport;
242
+ }
243
+ return null;
244
+ }
245
+ /* get nested namespaces in a file */
246
+ static getAllNamespacesInFile(arkFile) {
247
+ const arkNamespaces = arkFile.getNamespaces();
248
+ for (const arkNamespace of arkFile.getNamespaces()) {
249
+ this.getAllNamespacesInNamespace(arkNamespace, arkNamespaces);
250
+ }
251
+ return arkNamespaces;
252
+ }
253
+ /* get nested namespaces in a namespace */
254
+ static getAllNamespacesInNamespace(arkNamespace, allNamespaces) {
255
+ allNamespaces.push(...arkNamespace.getNamespaces());
256
+ for (const nestedNamespace of arkNamespace.getNamespaces()) {
257
+ this.getAllNamespacesInNamespace(nestedNamespace, allNamespaces);
258
+ }
259
+ }
260
+ static getAllClassesInFile(arkFile) {
261
+ const allClasses = arkFile.getClasses();
262
+ this.getAllNamespacesInFile(arkFile).forEach((namespace) => {
263
+ allClasses.push(...namespace.getClasses());
264
+ });
265
+ return allClasses;
266
+ }
267
+ static getAllMethodsInFile(arkFile) {
268
+ const allMethods = [];
269
+ this.getAllClassesInFile(arkFile).forEach((cls) => {
270
+ allMethods.push(...cls.getMethods());
271
+ });
272
+ return allMethods;
273
+ }
274
+ static isArkUIBuilderMethod(arkMethod) {
275
+ let isArkUIBuilderMethod = arkMethod.hasBuilderDecorator() || this.implicitArkUIBuilderMethods.has(arkMethod);
276
+ if (!isArkUIBuilderMethod &&
277
+ arkMethod.getName() == 'build' &&
278
+ arkMethod.getDeclaringArkClass().hasComponentDecorator() &&
279
+ !arkMethod.containsModifier('StaticKeyword')) {
280
+ const fileName = arkMethod.getDeclaringArkClass().getDeclaringArkFile().getName();
281
+ if (fileName.endsWith('.ets')) {
282
+ isArkUIBuilderMethod = true;
283
+ }
284
+ }
285
+ return isArkUIBuilderMethod;
286
+ }
287
+ static getArkClassInBuild(scene, classType) {
288
+ var _a;
289
+ const classSignature = classType.getClassSignature();
290
+ const file = scene.getFile(classSignature.getDeclaringFileSignature());
291
+ const namespaceSignature = classSignature.getDeclaringNamespaceSignature();
292
+ if (namespaceSignature) {
293
+ return ((_a = file === null || file === void 0 ? void 0 : file.getNamespace(namespaceSignature)) === null || _a === void 0 ? void 0 : _a.getClass(classSignature)) || null;
294
+ }
295
+ return (file === null || file === void 0 ? void 0 : file.getClassWithName(classSignature.getClassName())) || null;
296
+ }
297
+ static getDefaultClass(arkClass) {
298
+ var _a, _b;
299
+ return (_b = (_a = arkClass.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getDefaultClass()) !== null && _b !== void 0 ? _b : arkClass.getDeclaringArkFile().getDefaultClass();
300
+ }
301
+ static getClass(method, signature) {
302
+ var _a;
303
+ let cls = method.getDeclaringArkFile().getScene().getClass(signature);
304
+ if (cls) {
305
+ return cls;
306
+ }
307
+ let importInfo = method.getDeclaringArkFile().getImportInfoBy(signature.getClassName());
308
+ let exportInfo = importInfo ? findExportInfo(importInfo) : null;
309
+ let arkExport = exportInfo === null || exportInfo === void 0 ? void 0 : exportInfo.getArkExport();
310
+ if (arkExport instanceof ArkClass_1.ArkClass) {
311
+ return arkExport;
312
+ }
313
+ cls = (_a = method.getDeclaringArkClass().getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getClassWithName(signature.getClassName());
314
+ if (cls) {
315
+ return cls;
316
+ }
317
+ for (const ns of method.getDeclaringArkFile().getAllNamespacesUnderThisFile()) {
318
+ cls = ns.getClassWithName(signature.getClassName());
319
+ if (cls) {
320
+ return cls;
321
+ }
322
+ }
323
+ return method.getDeclaringArkFile().getClassWithName(signature.getClassName());
324
+ }
325
+ static findPropertyInNamespace(name, namespace) {
326
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
327
+ return (_j = (_e = (_d = (_c = (_b = (_a = namespace.getDefaultClass()) === null || _a === void 0 ? void 0 : _a.getMethodWithName(name)) !== null && _b !== void 0 ? _b : findArkExport(namespace.getExportInfoBy(name))) !== null && _c !== void 0 ? _c : namespace.getClassWithName(name)) !== null && _d !== void 0 ? _d : namespace.getNamespaceWithName(name)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = namespace.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name)) !== null && _j !== void 0 ? _j : (_o = (_m = (_l = (_k = namespace.getDefaultClass()) === null || _k === void 0 ? void 0 : _k.getDefaultArkMethod()) === null || _l === void 0 ? void 0 : _l.getBody()) === null || _m === void 0 ? void 0 : _m.getLocals()) === null || _o === void 0 ? void 0 : _o.get(name);
328
+ }
329
+ static findPropertyInClass(name, arkClass) {
330
+ var _a, _b, _c, _d;
331
+ let arkMethod = (_b = (_a = arkClass.getMethodWithName(name)) !== null && _a !== void 0 ? _a : arkClass.getStaticMethodWithName(name)) !== null && _b !== void 0 ? _b : (_c = arkClass.getSuperClass()) === null || _c === void 0 ? void 0 : _c.getMethodWithName(name);
332
+ if (arkMethod) {
333
+ return arkMethod;
334
+ }
335
+ const arkField = (_d = arkClass.getFieldWithName(name)) !== null && _d !== void 0 ? _d : arkClass.getStaticFieldWithName(name);
336
+ if (arkField) {
337
+ return arkField;
338
+ }
339
+ if (arkClass.isDefaultArkClass()) {
340
+ return findArkExport(arkClass.getDeclaringArkFile().getExportInfoBy(name));
341
+ }
342
+ return null;
343
+ }
344
+ static buildGlobalMap(file, globalMap) {
345
+ var _a, _b;
346
+ if (file.getFilePath().includes(EtsConst_1.COMPONENT_PATH) || file.getFilePath().includes(EtsConst_1.API_INTERNAL)) {
347
+ this.getAllClassesInFile(file).forEach(cls => {
348
+ if (!cls.isAnonymousClass()) {
349
+ globalMap.set(cls.getName(), cls);
350
+ cls.getMethods().forEach(mtd => {
351
+ if (!mtd.isDefaultArkMethod() && !mtd.isAnonymousMethod()) {
352
+ globalMap.set(mtd.getName(), mtd);
353
+ }
354
+ });
355
+ }
356
+ });
357
+ (_b = (_a = file.getDefaultClass().getDefaultArkMethod()) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => {
358
+ const name = local.getName();
359
+ if (name !== TSConst_1.THIS_NAME && !name.startsWith(TSConst_1.TEMP_LOCAL_PREFIX) && !name.endsWith(EtsConst_1.COMPONENT_INSTANCE)) {
360
+ const type = local.getType();
361
+ let arkExport;
362
+ if (type instanceof Type_1.UnclearReferenceType) {
363
+ arkExport = findArkExportInFile(type.getName(), file);
364
+ }
365
+ else if (type instanceof Type_1.ClassType) {
366
+ arkExport = file.getScene().getClass(type.getClassSignature());
367
+ }
368
+ if (arkExport instanceof ArkClass_1.ArkClass) {
369
+ const signature = new ArkSignature_1.ClassSignature(name, arkExport.getSignature().getDeclaringFileSignature(), arkExport.getSignature().getDeclaringNamespaceSignature());
370
+ let entry = new ArkClass_1.ArkClass();
371
+ entry.setSignature(signature);
372
+ arkExport.getMethods().forEach(m => {
373
+ const ms = m.getSignature();
374
+ m.setSignature(new ArkSignature_1.MethodSignature(signature, ms.getMethodSubSignature()));
375
+ entry.addMethod(m);
376
+ });
377
+ const attr = globalMap.get(name + EtsConst_1.COMPONENT_ATTRIBUTE);
378
+ if (attr instanceof ArkClass_1.ArkClass) {
379
+ attr.getMethods().forEach(m => {
380
+ const ms = m.getSignature();
381
+ m.setSignature(new ArkSignature_1.MethodSignature(signature, ms.getMethodSubSignature()));
382
+ entry.addMethod(m);
383
+ });
384
+ }
385
+ globalMap.set(name, entry);
386
+ }
387
+ }
388
+ });
389
+ }
390
+ }
391
+ }
392
+ exports.ModelUtils = ModelUtils;
393
+ ModelUtils.implicitArkUIBuilderMethods = new Set();
394
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
395
+ let moduleMap = undefined;
396
+ const fileSuffixArray = ['.ets: ', '.ts: ', '.d.ets: ', '.d.ts: '];
397
+ /**
398
+ * find arkFile by from info
399
+ * export xx from '../xx'
400
+ * import xx from '@ohos/xx'
401
+ * import xx from '@ohos.xx'
402
+ * @param im importInfo or exportInfo
403
+ */
404
+ function getArkFile(im) {
405
+ const from = im.getFrom();
406
+ if (!from) {
407
+ return null;
408
+ }
409
+ if (/^([^@]*\/)([^\/]*)$/.test(from)) { //relative path
410
+ const parentPath = /^\.{1,2}\//.test(from) ? path_1.default.dirname(im.getDeclaringArkFile().getFilePath())
411
+ : im.getDeclaringArkFile().getProjectDir();
412
+ const originPath = path_1.default.resolve(parentPath, from);
413
+ return getArkFileFromScene(im, originPath);
414
+ }
415
+ else if (/^@[a-z|\-]+?\//.test(from)) { //module path
416
+ const arkFile = getArkFileFromOtherModule(im);
417
+ if (arkFile) {
418
+ return arkFile;
419
+ }
420
+ }
421
+ //sdk path
422
+ const scene = im.getDeclaringArkFile().getScene();
423
+ for (const sdk of scene.getProjectSdkMap().values()) {
424
+ const arkFile = getArkFileFormMap(processSdkPath(sdk, from), scene.getSdkArkFilesMap());
425
+ if (arkFile) {
426
+ return arkFile;
427
+ }
428
+ }
429
+ }
430
+ exports.getArkFile = getArkFile;
431
+ /**
432
+ * find from info's export
433
+ * @param fromInfo importInfo or exportInfo
434
+ */
435
+ function findExportInfo(fromInfo) {
436
+ var _a, _b;
437
+ let file = getArkFile(fromInfo);
438
+ if (!file) {
439
+ logger.warn(`${fromInfo.getOriginName()} ${fromInfo.getFrom()} file not found:
440
+ ${(_b = (_a = fromInfo.getDeclaringArkFile()) === null || _a === void 0 ? void 0 : _a.getFileSignature()) === null || _b === void 0 ? void 0 : _b.toString()}`);
441
+ return null;
442
+ }
443
+ let exportInfo = findExportInfoInfile(fromInfo, file) || null;
444
+ if (exportInfo === null) {
445
+ logger.warn('export info not found, ' + fromInfo.getFrom() + ' in file: '
446
+ + fromInfo.getDeclaringArkFile().getFileSignature().toString());
447
+ return null;
448
+ }
449
+ const arkExport = findArkExport(exportInfo);
450
+ exportInfo.setArkExport(arkExport);
451
+ if (arkExport) {
452
+ exportInfo.setExportClauseType(arkExport.getExportType());
453
+ }
454
+ return exportInfo;
455
+ }
456
+ exports.findExportInfo = findExportInfo;
457
+ function findArkExport(exportInfo) {
458
+ var _a, _b, _c, _d;
459
+ if (!exportInfo) {
460
+ return null;
461
+ }
462
+ let arkExport = exportInfo.getArkExport();
463
+ if (arkExport || arkExport === null) {
464
+ return arkExport;
465
+ }
466
+ if (!exportInfo.getFrom()) {
467
+ const name = exportInfo.getOriginName();
468
+ if (exportInfo.getExportClauseType() === ArkExport_1.ExportType.LOCAL) {
469
+ arkExport = ((_b = (_a = exportInfo.getDeclaringArkFile().getDefaultClass().getDefaultArkMethod()) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().get(name)) || null;
470
+ }
471
+ else if (exportInfo.getExportClauseType() === ArkExport_1.ExportType.TYPE) {
472
+ arkExport = ((_d = (_c = exportInfo.getDeclaringArkFile().getDefaultClass().getDefaultArkMethod()) === null || _c === void 0 ? void 0 : _c.getBody()) === null || _d === void 0 ? void 0 : _d.getAliasTypeByName(name)) || null;
473
+ }
474
+ else {
475
+ arkExport = findArkExportInFile(name, exportInfo.getDeclaringArkFile());
476
+ }
477
+ }
478
+ else if (exportInfo.getExportClauseType() === ArkExport_1.ExportType.UNKNOWN) {
479
+ const result = findExportInfo(exportInfo);
480
+ if (result) {
481
+ arkExport = result.getArkExport() || null;
482
+ }
483
+ }
484
+ if (!arkExport) {
485
+ logger.warn(`${exportInfo.getExportClauseName()} get arkExport fail from ${exportInfo.getFrom()} at
486
+ ${exportInfo.getDeclaringArkFile().getFileSignature().toString()}`);
487
+ }
488
+ return arkExport || null;
489
+ }
490
+ function findArkExportInFile(name, declaringArkFile) {
491
+ var _a, _b, _c, _d, _e, _f, _g, _h;
492
+ let arkExport = (_f = (_c = (_b = (_a = declaringArkFile.getClassWithName(name)) !== null && _a !== void 0 ? _a : declaringArkFile.getDefaultClass().getMethodWithName(name)) !== null && _b !== void 0 ? _b : declaringArkFile.getNamespaceWithName(name)) !== null && _c !== void 0 ? _c : (_e = (_d = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _d === void 0 ? void 0 : _d.getBody()) === null || _e === void 0 ? void 0 : _e.getLocals().get(name)) !== null && _f !== void 0 ? _f : (_h = (_g = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name);
493
+ if (!arkExport) {
494
+ const importInfo = declaringArkFile.getImportInfoBy(name);
495
+ if (importInfo) {
496
+ const result = findExportInfo(importInfo);
497
+ if (result) {
498
+ arkExport = result.getArkExport();
499
+ }
500
+ }
501
+ }
502
+ return arkExport || null;
503
+ }
504
+ exports.findArkExportInFile = findArkExportInFile;
505
+ function processSdkPath(sdk, formPath) {
506
+ const sdkName = sdk.name;
507
+ let dir;
508
+ if (formPath.startsWith('@ohos.') || formPath.startsWith('@hms.') || formPath.startsWith('@system.')) {
509
+ dir = 'api';
510
+ }
511
+ else if (formPath.startsWith('@kit.')) {
512
+ dir = 'kits';
513
+ }
514
+ else if (formPath.startsWith('@arkts.')) {
515
+ dir = 'arkts';
516
+ }
517
+ else {
518
+ let originPath = path_1.default.join(sdk.path, formPath);
519
+ if (FileUtils_1.FileUtils.isDirectory(originPath)) {
520
+ formPath = path_1.default.join(formPath, FileUtils_1.FileUtils.getIndexFileName(originPath));
521
+ }
522
+ return `@${sdkName}/${formPath}`;
523
+ }
524
+ return `@${sdkName}/${dir}/${formPath}`;
525
+ }
526
+ function getArkFileFromScene(im, originPath) {
527
+ if (FileUtils_1.FileUtils.isDirectory(originPath)) {
528
+ originPath = path_1.default.join(originPath, FileUtils_1.FileUtils.getIndexFileName(originPath));
529
+ }
530
+ const fileName = path_1.default.relative(im.getDeclaringArkFile().getProjectDir(), originPath);
531
+ const scene = im.getDeclaringArkFile().getScene();
532
+ if (/\.e?ts$/.test(originPath)) {
533
+ const fromSignature = new ArkSignature_1.FileSignature(im.getDeclaringArkFile().getProjectName(), fileName);
534
+ return scene.getFile(fromSignature);
535
+ }
536
+ const projectName = im.getDeclaringArkFile().getProjectName();
537
+ const filePath = `@${projectName}/${fileName}`;
538
+ if (projectName !== scene.getProjectName()) {
539
+ return getArkFileFormMap(filePath, scene.getSdkArkFilesMap());
540
+ }
541
+ return getArkFileFormMap(filePath, scene.getFilesMap());
542
+ }
543
+ function getArkFileFormMap(filePath, map) {
544
+ if (/\.e?ts$/.test(filePath)) {
545
+ return map.get((0, pathTransfer_1.transfer2UnixPath)(filePath) + ': ');
546
+ }
547
+ for (const suffix of fileSuffixArray) {
548
+ const arkFile = map.get((0, pathTransfer_1.transfer2UnixPath)(filePath) + suffix);
549
+ if (arkFile) {
550
+ return arkFile;
551
+ }
552
+ }
553
+ }
554
+ function findExportInfoInfile(fromInfo, file) {
555
+ const exportName = fromInfo.isDefault() ? TSConst_1.DEFAULT : fromInfo.getOriginName();
556
+ let exportInfo = file.getExportInfoBy(exportName);
557
+ if (exportInfo) {
558
+ return exportInfo;
559
+ }
560
+ if (fromInfo.isDefault()) {
561
+ exportInfo = file.getExportInfos().find(p => p.isDefault());
562
+ if (exportInfo) {
563
+ file.addExportInfo(exportInfo, TSConst_1.DEFAULT);
564
+ return exportInfo;
565
+ }
566
+ }
567
+ if (fromInfo.getOriginName() === TSConst_1.ALL) {
568
+ exportInfo = (0, ArkExportBuilder_1.buildDefaultExportInfo)(fromInfo, file);
569
+ file.addExportInfo(exportInfo, TSConst_1.ALL);
570
+ }
571
+ else if (/\.d\.e?ts$/.test(file.getName())) {
572
+ const declare = findArkExportInFile(fromInfo.getOriginName(), file);
573
+ if (declare) {
574
+ exportInfo = (0, ArkExportBuilder_1.buildDefaultExportInfo)(fromInfo, file, declare);
575
+ }
576
+ }
577
+ return exportInfo;
578
+ }
579
+ function getArkFileFromOtherModule(fromInfo) {
580
+ if (moduleMap === undefined) {
581
+ moduleMap = FileUtils_1.FileUtils.generateModuleMap(fromInfo.getDeclaringArkFile().getScene().getOhPkgContentMap());
582
+ }
583
+ if (!moduleMap || moduleMap.size === 0) {
584
+ return;
585
+ }
586
+ const from = fromInfo.getFrom();
587
+ let index;
588
+ let file;
589
+ let modulePath;
590
+ //find file by given from like '@ohos/module/src/xxx' '@ohos/module/index'
591
+ if ((index = from.indexOf('src')) > 0 || (index = from.indexOf('Index')) > 0 || (index = from.indexOf('index')) > 0) {
592
+ modulePath = moduleMap.get(from.substring(0, index).replace(/\/*$/, ''));
593
+ file = findFileInModule(fromInfo, modulePath, from.substring(index));
594
+ }
595
+ if (file) {
596
+ return file;
597
+ }
598
+ modulePath = modulePath !== null && modulePath !== void 0 ? modulePath : moduleMap.get(from);
599
+ if (!modulePath) {
600
+ return file;
601
+ }
602
+ //find file in module json main path
603
+ if (modulePath.main) {
604
+ file = getArkFileFromScene(fromInfo, modulePath.main);
605
+ }
606
+ //find file in module path Index.ts
607
+ if (!file && FileUtils_1.FileUtils.isDirectory(modulePath.path)) {
608
+ file = findFileInModule(fromInfo, modulePath, FileUtils_1.FileUtils.getIndexFileName(modulePath.path));
609
+ }
610
+ //find file in module path/src/main/ets/TsIndex.ts
611
+ if (!file) {
612
+ file = findFileInModule(fromInfo, modulePath, '/src/main/ets/TsIndex.ts');
613
+ }
614
+ return file;
615
+ }
616
+ function findFileInModule(fromInfo, modulePath, contentPath) {
617
+ if (!modulePath) {
618
+ return;
619
+ }
620
+ const originPath = path_1.default.join(modulePath.path, contentPath);
621
+ let file;
622
+ if (originPath !== modulePath.main) {
623
+ file = getArkFileFromScene(fromInfo, originPath);
624
+ }
625
+ if (file && findExportInfoInfile(fromInfo, file)) {
626
+ return file;
627
+ }
628
+ }
@@ -0,0 +1,14 @@
1
+ import { AbstractRef } from '../base/Ref';
2
+ import { Value } from '../base/Value';
3
+ /**
4
+ * Replace old use of a Ref inplace
5
+ */
6
+ export declare class RefUseReplacer {
7
+ private oldUse;
8
+ private newUse;
9
+ constructor(oldUse: Value, newUse: Value);
10
+ caseRef(ref: AbstractRef): void;
11
+ private caseFieldRef;
12
+ private caseArrayRef;
13
+ }
14
+ //# sourceMappingURL=RefUseReplacer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefUseReplacer.d.ts","sourceRoot":"","sources":["../../../src/core/common/RefUseReplacer.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAoC,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAMjC,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAQtC,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,YAAY;CAOvB"}