arkanalyzer 1.0.86 → 1.0.88

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 (422) hide show
  1. package/README.en.md +69 -65
  2. package/README.md +56 -70
  3. package/config/arkanalyzer.json +7 -2
  4. package/docs/cppFrontend/ArkAnalyzer-cpp_usage_guide.md +245 -0
  5. package/docs/cppFrontend/cpp_frontend_build_guide.md +126 -0
  6. package/docs/cppFrontend/cpp_frontend_user_guide.md +175 -0
  7. package/docs/cppFrontend/img.png +0 -0
  8. package/docs/cppFrontend/img_1.png +0 -0
  9. package/docs/cppFrontend/img_10.png +0 -0
  10. package/docs/cppFrontend/img_11.png +0 -0
  11. package/docs/cppFrontend/img_12.png +0 -0
  12. package/docs/cppFrontend/img_13.png +0 -0
  13. package/docs/cppFrontend/img_14.png +0 -0
  14. package/docs/cppFrontend/img_15.png +0 -0
  15. package/docs/cppFrontend/img_16.png +0 -0
  16. package/docs/cppFrontend/img_17.png +0 -0
  17. package/docs/cppFrontend/img_18.png +0 -0
  18. package/docs/cppFrontend/img_19.png +0 -0
  19. package/docs/cppFrontend/img_2.png +0 -0
  20. package/docs/cppFrontend/img_20.png +0 -0
  21. package/docs/cppFrontend/img_21.png +0 -0
  22. package/docs/cppFrontend/img_22.png +0 -0
  23. package/docs/cppFrontend/img_23.png +0 -0
  24. package/docs/cppFrontend/img_3.png +0 -0
  25. package/docs/cppFrontend/img_4.png +0 -0
  26. package/docs/cppFrontend/img_5.png +0 -0
  27. package/docs/cppFrontend/img_6.png +0 -0
  28. package/docs/cppFrontend/img_7.png +0 -0
  29. package/docs/cppFrontend/img_8.png +0 -0
  30. package/docs/cppFrontend/img_9.png +0 -0
  31. package/docs/sig_programanalysis.en.md +66 -0
  32. package/docs/sig_programanalysis.md +73 -0
  33. package/lib/Config.d.ts +35 -1
  34. package/lib/Config.d.ts.map +1 -1
  35. package/lib/Config.js +91 -2
  36. package/lib/Scene.d.ts +25 -2
  37. package/lib/Scene.d.ts.map +1 -1
  38. package/lib/Scene.js +151 -44
  39. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +4 -3
  40. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
  41. package/lib/callgraph/algorithm/AbstractAnalysis.js +17 -17
  42. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +6 -1
  43. package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
  44. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +117 -14
  45. package/lib/callgraph/common/Statistics.d.ts +4 -2
  46. package/lib/callgraph/common/Statistics.d.ts.map +1 -1
  47. package/lib/callgraph/common/Statistics.js +14 -2
  48. package/lib/callgraph/model/CallGraph.d.ts +12 -8
  49. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  50. package/lib/callgraph/model/CallGraph.js +53 -29
  51. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +1 -0
  52. package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
  53. package/lib/callgraph/model/builder/CallGraphBuilder.js +5 -1
  54. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  55. package/lib/callgraph/pointerAnalysis/Pag.js +3 -0
  56. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +4 -2
  57. package/lib/cli/cli.d.ts +3 -0
  58. package/lib/cli/cli.d.ts.map +1 -0
  59. package/lib/cli/cli.js +82 -0
  60. package/lib/cli/commands/cg.d.ts +53 -0
  61. package/lib/cli/commands/cg.d.ts.map +1 -0
  62. package/lib/cli/commands/cg.js +404 -0
  63. package/lib/cli/commands/index.d.ts +6 -0
  64. package/lib/cli/commands/index.d.ts.map +1 -0
  65. package/lib/cli/commands/index.js +64 -0
  66. package/lib/cli/commands/ir.d.ts +26 -0
  67. package/lib/cli/commands/ir.d.ts.map +1 -0
  68. package/lib/cli/commands/ir.js +94 -0
  69. package/lib/core/base/Constant.d.ts +1 -1
  70. package/lib/core/base/Constant.d.ts.map +1 -1
  71. package/lib/core/base/Constant.js +1 -1
  72. package/lib/core/base/Expr.d.ts +29 -5
  73. package/lib/core/base/Expr.d.ts.map +1 -1
  74. package/lib/core/base/Expr.js +145 -23
  75. package/lib/core/base/Position.d.ts +14 -0
  76. package/lib/core/base/Position.d.ts.map +1 -1
  77. package/lib/core/base/Position.js +27 -0
  78. package/lib/core/base/Ref.d.ts +1 -0
  79. package/lib/core/base/Ref.d.ts.map +1 -1
  80. package/lib/core/base/Ref.js +4 -1
  81. package/lib/core/base/Type.d.ts +64 -24
  82. package/lib/core/base/Type.d.ts.map +1 -1
  83. package/lib/core/base/Type.js +144 -49
  84. package/lib/core/common/ArkError.d.ts +26 -2
  85. package/lib/core/common/ArkError.d.ts.map +1 -1
  86. package/lib/core/common/ArkError.js +56 -2
  87. package/lib/core/common/ArkIRTransformer.d.ts +11 -10
  88. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  89. package/lib/core/common/ArkIRTransformer.js +1 -1
  90. package/lib/core/common/ArkValueTransformer.d.ts +14 -12
  91. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  92. package/lib/core/common/ArkValueTransformer.js +1 -5
  93. package/lib/core/common/Const.d.ts +4 -0
  94. package/lib/core/common/Const.d.ts.map +1 -1
  95. package/lib/core/common/Const.js +5 -1
  96. package/lib/core/common/DummyMainCreater.d.ts +23 -13
  97. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  98. package/lib/core/common/DummyMainCreater.js +66 -43
  99. package/lib/core/common/EtsConst.d.ts +11 -0
  100. package/lib/core/common/EtsConst.d.ts.map +1 -1
  101. package/lib/core/common/EtsConst.js +12 -1
  102. package/lib/core/common/IRInference.d.ts.map +1 -1
  103. package/lib/core/common/IRInference.js +6 -2
  104. package/lib/core/common/IRUtils.d.ts.map +1 -1
  105. package/lib/core/common/IRUtils.js +3 -33
  106. package/lib/core/common/ModelUtils.d.ts +4 -7
  107. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  108. package/lib/core/common/ModelUtils.js +77 -110
  109. package/lib/core/common/SdkUtils.d.ts +1 -1
  110. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  111. package/lib/core/common/SdkUtils.js +14 -5
  112. package/lib/core/common/TypeInference.d.ts.map +1 -1
  113. package/lib/core/common/TypeInference.js +9 -3
  114. package/lib/core/graph/BaseExplicitGraph.d.ts +4 -4
  115. package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
  116. package/lib/core/graph/BaseExplicitGraph.js +15 -8
  117. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  118. package/lib/core/graph/Scc.d.ts.map +1 -1
  119. package/lib/core/graph/Scc.js +7 -2
  120. package/lib/core/graph/builder/CfgBuilder.d.ts +10 -7
  121. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  122. package/lib/core/graph/builder/CfgBuilder.js +12 -5
  123. package/lib/core/inference/Inference.d.ts.map +1 -1
  124. package/lib/core/inference/Inference.js +7 -0
  125. package/lib/core/inference/ModelInference.d.ts +1 -1
  126. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  127. package/lib/core/inference/ValueInference.d.ts +3 -2
  128. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  129. package/lib/core/inference/ValueInference.js +64 -12
  130. package/lib/core/inference/abc/AbcInference.d.ts +28 -2
  131. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  132. package/lib/core/inference/abc/AbcInference.js +105 -4
  133. package/lib/core/model/ArkBaseModel.d.ts +14 -1
  134. package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
  135. package/lib/core/model/ArkBaseModel.js +61 -2
  136. package/lib/core/model/ArkBody.d.ts.map +1 -1
  137. package/lib/core/model/ArkBody.js +1 -3
  138. package/lib/core/model/ArkClass.d.ts +25 -2
  139. package/lib/core/model/ArkClass.d.ts.map +1 -1
  140. package/lib/core/model/ArkClass.js +72 -30
  141. package/lib/core/model/ArkField.d.ts.map +1 -1
  142. package/lib/core/model/ArkField.js +3 -1
  143. package/lib/core/model/ArkFile.d.ts +4 -1
  144. package/lib/core/model/ArkFile.d.ts.map +1 -1
  145. package/lib/core/model/ArkFile.js +44 -3
  146. package/lib/core/model/ArkImport.d.ts.map +1 -1
  147. package/lib/core/model/ArkImport.js +9 -1
  148. package/lib/core/model/ArkMetadata.d.ts +32 -1
  149. package/lib/core/model/ArkMetadata.d.ts.map +1 -1
  150. package/lib/core/model/ArkMetadata.js +28 -2
  151. package/lib/core/model/ArkMethod.d.ts +5 -0
  152. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  153. package/lib/core/model/ArkMethod.js +33 -1
  154. package/lib/core/model/ArkNamespace.d.ts +2 -0
  155. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  156. package/lib/core/model/ArkNamespace.js +11 -0
  157. package/lib/core/model/ArkSignature.d.ts +3 -3
  158. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  159. package/lib/core/model/ArkSignature.js +14 -9
  160. package/lib/core/model/builder/ArkClassBuilder.d.ts +2 -0
  161. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  162. package/lib/core/model/builder/ArkClassBuilder.js +3 -3
  163. package/lib/core/model/builder/ArkMetadataBuilder.d.ts +21 -0
  164. package/lib/core/model/builder/ArkMetadataBuilder.d.ts.map +1 -0
  165. package/lib/core/model/builder/ArkMetadataBuilder.js +160 -0
  166. package/lib/core/model/builder/ArkMethodBuilder.d.ts +4 -1
  167. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  168. package/lib/core/model/builder/ArkMethodBuilder.js +50 -29
  169. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +1 -0
  170. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  171. package/lib/core/model/builder/ArkNamespaceBuilder.js +2 -1
  172. package/lib/core/model/builder/BodyBuilder.d.ts +4 -0
  173. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  174. package/lib/core/model/builder/builderUtils.d.ts +1 -0
  175. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  176. package/lib/core/model/builder/builderUtils.js +7 -3
  177. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts +296 -0
  178. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.d.ts.map +1 -0
  179. package/lib/frontend/cppFrontend/ast/ArkCxxAstNode.js +145 -0
  180. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.d.ts +8 -0
  181. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.d.ts.map +1 -0
  182. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiApi.js +90 -0
  183. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.d.ts +8 -0
  184. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.d.ts.map +1 -0
  185. package/lib/frontend/cppFrontend/ast/astJsonNapi/napiRunner.js +183 -0
  186. package/lib/frontend/cppFrontend/ast/astParser.d.ts +25 -0
  187. package/lib/frontend/cppFrontend/ast/astParser.d.ts.map +1 -0
  188. package/lib/frontend/cppFrontend/ast/astParser.js +280 -0
  189. package/lib/frontend/cppFrontend/ast/astUtils.d.ts +18 -0
  190. package/lib/frontend/cppFrontend/ast/astUtils.d.ts.map +1 -0
  191. package/lib/frontend/cppFrontend/ast/astUtils.js +158 -0
  192. package/lib/frontend/cppFrontend/ast/const.d.ts +17 -0
  193. package/lib/frontend/cppFrontend/ast/const.d.ts.map +1 -0
  194. package/lib/frontend/cppFrontend/ast/const.js +58 -0
  195. package/lib/frontend/cppFrontend/ast/index.d.ts +5 -0
  196. package/lib/frontend/cppFrontend/ast/index.d.ts.map +1 -0
  197. package/lib/frontend/cppFrontend/ast/index.js +31 -0
  198. package/lib/frontend/cppFrontend/base/Constant.d.ts +9 -0
  199. package/lib/frontend/cppFrontend/base/Constant.d.ts.map +1 -0
  200. package/lib/frontend/cppFrontend/base/Constant.js +33 -0
  201. package/lib/frontend/cppFrontend/base/Expr.d.ts +174 -0
  202. package/lib/frontend/cppFrontend/base/Expr.d.ts.map +1 -0
  203. package/lib/frontend/cppFrontend/base/Expr.js +530 -0
  204. package/lib/frontend/cppFrontend/base/Ref.d.ts +25 -0
  205. package/lib/frontend/cppFrontend/base/Ref.d.ts.map +1 -0
  206. package/lib/frontend/cppFrontend/base/Ref.js +53 -0
  207. package/lib/frontend/cppFrontend/base/Trap.d.ts +8 -0
  208. package/lib/frontend/cppFrontend/base/Trap.d.ts.map +1 -0
  209. package/lib/frontend/cppFrontend/base/Trap.js +28 -0
  210. package/lib/frontend/cppFrontend/base/Type.d.ts +264 -0
  211. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -0
  212. package/lib/frontend/cppFrontend/base/Type.js +600 -0
  213. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts +109 -0
  214. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -0
  215. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +925 -0
  216. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +477 -0
  217. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -0
  218. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +2746 -0
  219. package/lib/frontend/cppFrontend/common/Builtin.d.ts +57 -0
  220. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -0
  221. package/lib/frontend/cppFrontend/common/Builtin.js +106 -0
  222. package/lib/frontend/cppFrontend/common/IRInference.d.ts +94 -0
  223. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -0
  224. package/lib/frontend/cppFrontend/common/IRInference.js +1087 -0
  225. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +23 -0
  226. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -0
  227. package/lib/frontend/cppFrontend/common/IRUtils.js +168 -0
  228. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +44 -0
  229. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -0
  230. package/lib/frontend/cppFrontend/common/ModelUtils.js +567 -0
  231. package/lib/frontend/cppFrontend/common/TypeInference.d.ts +278 -0
  232. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -0
  233. package/lib/frontend/cppFrontend/common/TypeInference.js +1354 -0
  234. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts +16 -0
  235. package/lib/frontend/cppFrontend/common/ValueUtil.d.ts.map +1 -0
  236. package/lib/frontend/cppFrontend/common/ValueUtil.js +61 -0
  237. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts +182 -0
  238. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -0
  239. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +1435 -0
  240. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts +21 -0
  241. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.d.ts.map +1 -0
  242. package/lib/frontend/cppFrontend/graph/builder/ConditionBuilder.js +303 -0
  243. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts +15 -0
  244. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.d.ts.map +1 -0
  245. package/lib/frontend/cppFrontend/graph/builder/IfBuilder.js +161 -0
  246. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts +21 -0
  247. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.d.ts.map +1 -0
  248. package/lib/frontend/cppFrontend/graph/builder/LoopBuilder.js +261 -0
  249. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts +12 -0
  250. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.d.ts.map +1 -0
  251. package/lib/frontend/cppFrontend/graph/builder/SwitchBuilder.js +155 -0
  252. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts +29 -0
  253. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.d.ts.map +1 -0
  254. package/lib/frontend/cppFrontend/graph/builder/TrapBuilder.js +302 -0
  255. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts +10 -0
  256. package/lib/frontend/cppFrontend/inference/CxxInference.d.ts.map +1 -0
  257. package/lib/frontend/cppFrontend/inference/CxxInference.js +41 -0
  258. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +28 -0
  259. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -0
  260. package/lib/frontend/cppFrontend/inference/CxxModelInference.js +98 -0
  261. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts +20 -0
  262. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -0
  263. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +128 -0
  264. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts +11 -0
  265. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -0
  266. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +413 -0
  267. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts +5 -0
  268. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -0
  269. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +61 -0
  270. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +17 -0
  271. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -0
  272. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +284 -0
  273. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts +6 -0
  274. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.d.ts.map +1 -0
  275. package/lib/frontend/cppFrontend/model/builder/ArkImportBuilder.js +57 -0
  276. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts +14 -0
  277. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -0
  278. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +422 -0
  279. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +8 -0
  280. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
  281. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +194 -0
  282. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +59 -0
  283. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -0
  284. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +605 -0
  285. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts +46 -0
  286. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -0
  287. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +499 -0
  288. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts +44 -0
  289. package/lib/frontend/cppFrontend/utils/cmakeUtils.d.ts.map +1 -0
  290. package/lib/frontend/cppFrontend/utils/cmakeUtils.js +240 -0
  291. package/lib/index.d.ts +2 -1
  292. package/lib/index.d.ts.map +1 -1
  293. package/lib/index.js +8 -1
  294. package/lib/node_modules/ohos-typescript/.ohos-typescript-version +1 -0
  295. package/{node_modules → lib/node_modules}/ohos-typescript/package.json +2 -1
  296. package/lib/save/CGJsonPrinter.d.ts +8 -0
  297. package/lib/save/CGJsonPrinter.d.ts.map +1 -0
  298. package/lib/save/CGJsonPrinter.js +41 -0
  299. package/lib/save/GraphPrinter.js +2 -2
  300. package/lib/save/json/JsonDto.d.ts +86 -2
  301. package/lib/save/json/JsonDto.d.ts.map +1 -1
  302. package/lib/save/json/JsonSerialization.d.ts +1 -1
  303. package/lib/save/json/JsonSerialization.d.ts.map +1 -1
  304. package/lib/save/json/JsonSerialization.js +235 -145
  305. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  306. package/lib/save/source/SourceStmt.js +3 -1
  307. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  308. package/lib/save/source/SourceTransformer.js +0 -3
  309. package/lib/utils/CxxSceneUtils.d.ts +11 -0
  310. package/lib/utils/CxxSceneUtils.d.ts.map +1 -0
  311. package/lib/utils/CxxSceneUtils.js +178 -0
  312. package/lib/utils/FileUtils.d.ts +8 -8
  313. package/lib/utils/FileUtils.d.ts.map +1 -1
  314. package/lib/utils/FileUtils.js +35 -45
  315. package/lib/utils/LRUCacheDecorator.d.ts +20 -0
  316. package/lib/utils/LRUCacheDecorator.d.ts.map +1 -0
  317. package/lib/utils/LRUCacheDecorator.js +89 -0
  318. package/lib/utils/ModuleUtils.d.ts +39 -0
  319. package/lib/utils/ModuleUtils.d.ts.map +1 -0
  320. package/lib/utils/ModuleUtils.js +261 -0
  321. package/package.json +13 -7
  322. /package/{node_modules → lib/node_modules}/ohos-typescript/LICENSE +0 -0
  323. /package/{node_modules → lib/node_modules}/ohos-typescript/README.OpenSource +0 -0
  324. /package/{node_modules → lib/node_modules}/ohos-typescript/README.md +0 -0
  325. /package/{node_modules → lib/node_modules}/ohos-typescript/SECURITY.md +0 -0
  326. /package/{node_modules → lib/node_modules}/ohos-typescript/ThirdPartyNoticeText.txt +0 -0
  327. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsc +0 -0
  328. /package/{node_modules → lib/node_modules}/ohos-typescript/bin/tsserver +0 -0
  329. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/README.md +0 -0
  330. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cancellationToken.js +0 -0
  331. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/cs/diagnosticMessages.generated.json +0 -0
  332. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/de/diagnosticMessages.generated.json +0 -0
  333. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/es/diagnosticMessages.generated.json +0 -0
  334. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/fr/diagnosticMessages.generated.json +0 -0
  335. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/it/diagnosticMessages.generated.json +0 -0
  336. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ja/diagnosticMessages.generated.json +0 -0
  337. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ko/diagnosticMessages.generated.json +0 -0
  338. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.d.ts +0 -0
  339. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.d.ts +0 -0
  340. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.dom.iterable.d.ts +0 -0
  341. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.collection.d.ts +0 -0
  342. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.core.d.ts +0 -0
  343. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.d.ts +0 -0
  344. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.generator.d.ts +0 -0
  345. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.iterable.d.ts +0 -0
  346. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.promise.d.ts +0 -0
  347. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.proxy.d.ts +0 -0
  348. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.reflect.d.ts +0 -0
  349. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.d.ts +0 -0
  350. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -0
  351. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.array.include.d.ts +0 -0
  352. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.d.ts +0 -0
  353. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2016.full.d.ts +0 -0
  354. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.d.ts +0 -0
  355. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.full.d.ts +0 -0
  356. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.intl.d.ts +0 -0
  357. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.object.d.ts +0 -0
  358. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.sharedmemory.d.ts +0 -0
  359. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.string.d.ts +0 -0
  360. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2017.typedarrays.d.ts +0 -0
  361. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -0
  362. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.asynciterable.d.ts +0 -0
  363. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.d.ts +0 -0
  364. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.full.d.ts +0 -0
  365. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.intl.d.ts +0 -0
  366. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.promise.d.ts +0 -0
  367. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2018.regexp.d.ts +0 -0
  368. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.array.d.ts +0 -0
  369. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.d.ts +0 -0
  370. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.full.d.ts +0 -0
  371. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.intl.d.ts +0 -0
  372. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.object.d.ts +0 -0
  373. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.string.d.ts +0 -0
  374. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2019.symbol.d.ts +0 -0
  375. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.bigint.d.ts +0 -0
  376. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.d.ts +0 -0
  377. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.date.d.ts +0 -0
  378. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.full.d.ts +0 -0
  379. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.intl.d.ts +0 -0
  380. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.number.d.ts +0 -0
  381. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.promise.d.ts +0 -0
  382. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.sharedmemory.d.ts +0 -0
  383. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.string.d.ts +0 -0
  384. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -0
  385. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.d.ts +0 -0
  386. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.full.d.ts +0 -0
  387. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.intl.d.ts +0 -0
  388. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.promise.d.ts +0 -0
  389. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.string.d.ts +0 -0
  390. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2021.weakref.d.ts +0 -0
  391. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.array.d.ts +0 -0
  392. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.d.ts +0 -0
  393. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.error.d.ts +0 -0
  394. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.full.d.ts +0 -0
  395. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.intl.d.ts +0 -0
  396. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.object.d.ts +0 -0
  397. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.sharedmemory.d.ts +0 -0
  398. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es2022.string.d.ts +0 -0
  399. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es5.d.ts +0 -0
  400. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.es6.d.ts +0 -0
  401. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.d.ts +0 -0
  402. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.full.d.ts +0 -0
  403. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.esnext.intl.d.ts +0 -0
  404. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.scripthost.d.ts +0 -0
  405. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.d.ts +0 -0
  406. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.importscripts.d.ts +0 -0
  407. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/lib.webworker.iterable.d.ts +0 -0
  408. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pl/diagnosticMessages.generated.json +0 -0
  409. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/pt-br/diagnosticMessages.generated.json +0 -0
  410. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/ru/diagnosticMessages.generated.json +0 -0
  411. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tr/diagnosticMessages.generated.json +0 -0
  412. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsc.js +0 -0
  413. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserver.js +0 -0
  414. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.d.ts +0 -0
  415. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/tsserverlibrary.js +0 -0
  416. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typesMap.json +0 -0
  417. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.d.ts +0 -0
  418. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typescript.js +0 -0
  419. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/typingsInstaller.js +0 -0
  420. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/watchGuard.js +0 -0
  421. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -0
  422. /package/{node_modules → lib/node_modules}/ohos-typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -0
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2025 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.CxxSceneUtils = void 0;
44
+ const path_1 = __importDefault(require("path"));
45
+ const ArkSignature_1 = require("../core/model/ArkSignature");
46
+ const ModelUtils_1 = require("../core/common/ModelUtils");
47
+ const Stmt_1 = require("../core/base/Stmt");
48
+ const ArkMethod_1 = require("../core/model/ArkMethod");
49
+ const Constant_1 = require("../core/base/Constant");
50
+ const Local_1 = require("../core/base/Local");
51
+ const Ref_1 = require("../core/base/Ref");
52
+ const ArkField_1 = require("../core/model/ArkField");
53
+ const Type_1 = require("../core/base/Type");
54
+ const TSConst_1 = require("../core/common/TSConst");
55
+ const logger_1 = __importStar(require("./logger"));
56
+ const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkValueTransformer');
57
+ class CxxSceneUtils {
58
+ static puncture(cxxModulePath, tsFile) {
59
+ var _a;
60
+ const fileName = path_1.default.relative(tsFile.getProjectDir(), path_1.default.join(cxxModulePath, '../../napi_init.cpp'));
61
+ const initFile = tsFile.getScene().getFile(new ArkSignature_1.FileSignature(tsFile.getProjectName(), fileName));
62
+ if (!initFile) {
63
+ return;
64
+ }
65
+ const ts2cxxFuncMap = initFile.getDefaultClass().getTs2cxxFuncMap();
66
+ const methods = ModelUtils_1.ModelUtils.getAllMethodsInFile(initFile);
67
+ for (const method of methods) {
68
+ const stmts = (_a = method.getCfg()) === null || _a === void 0 ? void 0 : _a.getStmts();
69
+ if (!stmts) {
70
+ continue;
71
+ }
72
+ for (const stmt of stmts) {
73
+ if (stmt instanceof Stmt_1.ArkInvokeStmt) {
74
+ this.processApiDefine(stmt, tsFile, ts2cxxFuncMap);
75
+ }
76
+ }
77
+ }
78
+ }
79
+ static processApiDefine(stmt, tsFile, ts2cxxFuncMap) {
80
+ const invokeExpr = stmt.getInvokeExpr();
81
+ const methodName = invokeExpr.getMethodSignature().getMethodSubSignature().getMethodName();
82
+ const clsConstant = invokeExpr.getArg(1);
83
+ if (methodName === 'napi_define_class' && clsConstant instanceof Constant_1.Constant) {
84
+ const tsClass = tsFile.getClassWithName(clsConstant.getValue());
85
+ if (!tsClass) {
86
+ return;
87
+ }
88
+ const props = invokeExpr.getArg(6);
89
+ this.findPropDesc(props, ts2cxxFuncMap, tsClass);
90
+ const arkMethods = ts2cxxFuncMap.get(clsConstant.getValue());
91
+ if ((arkMethods === null || arkMethods === void 0 ? void 0 : arkMethods.length) === 1) {
92
+ this.mergeMethod(TSConst_1.CONSTRUCTOR_NAME, tsClass, arkMethods[0]);
93
+ }
94
+ }
95
+ else if (methodName === 'napi_define_properties') {
96
+ const tsClass = tsFile.getDefaultClass();
97
+ const props = invokeExpr.getArg(3);
98
+ this.findPropDesc(props, ts2cxxFuncMap, tsClass);
99
+ }
100
+ }
101
+ static findPropDesc(props, ts2cxxFuncMap, tsClass) {
102
+ var _a, _b;
103
+ (_b = this.getUsedStmts((_a = this.getDeclaredAssignStmt(props)) === null || _a === void 0 ? void 0 : _a.getRightOp())) === null || _b === void 0 ? void 0 : _b.forEach(x => {
104
+ var _a;
105
+ if (x instanceof Stmt_1.ArkAssignStmt && x.getLeftOp() instanceof Ref_1.ArkArrayRef) {
106
+ (_a = this.getUsedStmts(x.getRightOp())) === null || _a === void 0 ? void 0 : _a.forEach(s => {
107
+ this.processPropDesc(s, ts2cxxFuncMap, tsClass);
108
+ });
109
+ }
110
+ });
111
+ }
112
+ static processPropDesc(s, ts2cxxFuncMap, tsClass) {
113
+ let constant;
114
+ if (s instanceof Stmt_1.ArkInvokeStmt) {
115
+ // This scenario corresponds to the registration of class objects
116
+ constant = s.getInvokeExpr().getArg(0);
117
+ }
118
+ else if (s instanceof Stmt_1.ArkAssignStmt && s.getLeftOp() instanceof Ref_1.ArkArrayRef) {
119
+ // The registration scenario is a structure aggregation scenario, where the syntax tree does not contain a construct,
120
+ // and each unit is expressed using an aggregation expression
121
+ let rightOp = s.getRightOp();
122
+ if (rightOp.getName().startsWith('%')) {
123
+ const declaringStmt = rightOp.getDeclaringStmt();
124
+ if (declaringStmt instanceof Stmt_1.ArkAssignStmt) {
125
+ rightOp = declaringStmt.getRightOp();
126
+ }
127
+ }
128
+ try {
129
+ // Due to the order of type definitions, type judgment cannot be performed here,
130
+ // so try+assertion is used to avoid runtime errors
131
+ constant = rightOp.getElements()[0];
132
+ }
133
+ catch (e) {
134
+ logger.info('This is Unknow scene');
135
+ }
136
+ }
137
+ if (constant instanceof Constant_1.Constant) {
138
+ const tsMtdName = constant.getValue();
139
+ const arkMethods = ts2cxxFuncMap.get(tsMtdName);
140
+ if ((arkMethods === null || arkMethods === void 0 ? void 0 : arkMethods.length) === 1) {
141
+ this.mergeMethod(tsMtdName, tsClass, arkMethods[0]);
142
+ }
143
+ else if ((arkMethods === null || arkMethods === void 0 ? void 0 : arkMethods.length) === 2) {
144
+ this.mergeMethod('Get-' + tsMtdName, tsClass, arkMethods[0]);
145
+ this.mergeMethod('Set-' + tsMtdName, tsClass, arkMethods[1]);
146
+ }
147
+ }
148
+ }
149
+ static getDeclaredAssignStmt(value) {
150
+ if (value instanceof Local_1.Local) {
151
+ const declaringStmt = value.getDeclaringStmt();
152
+ if (declaringStmt instanceof Stmt_1.ArkAssignStmt) {
153
+ return declaringStmt;
154
+ }
155
+ }
156
+ return undefined;
157
+ }
158
+ static getUsedStmts(value) {
159
+ if (value instanceof Local_1.Local) {
160
+ return value.getUsedStmts();
161
+ }
162
+ return undefined;
163
+ }
164
+ static mergeMethod(tsMtdName, tsClass, cppMtd) {
165
+ let tsMtd = ModelUtils_1.ModelUtils.findArkModel(tsMtdName, tsClass);
166
+ if (tsMtd instanceof Local_1.Local || tsMtd instanceof ArkField_1.ArkField) {
167
+ const type = tsMtd.getType();
168
+ if (type instanceof Type_1.FunctionType) {
169
+ tsMtd = tsClass.getDeclaringArkFile().getScene().getMethod(type.getMethodSignature());
170
+ }
171
+ }
172
+ if (tsMtd instanceof ArkMethod_1.ArkMethod && cppMtd.getBody()) {
173
+ tsMtd.setImplementationSignature(cppMtd.getSignature());
174
+ tsMtd.setBody(cppMtd.getBody());
175
+ }
176
+ }
177
+ }
178
+ exports.CxxSceneUtils = CxxSceneUtils;
@@ -7,15 +7,15 @@ export declare class FileUtils {
7
7
  static getIndexFileName(srcPath: string): string;
8
8
  static isDirectory(srcPath: string): boolean;
9
9
  static isAbsolutePath(path: string): boolean;
10
- static generateModuleMap(ohPkgContentMap: Map<string, {
11
- [k: string]: unknown;
12
- }>): Map<string, ModulePath>;
13
10
  static getFileLanguage(file: string, fileTags?: Map<string, Language>): Language;
14
11
  }
15
- export declare class ModulePath {
16
- path: string;
17
- main: string;
18
- constructor(path: string, main: string);
19
- }
20
12
  export declare function getFileRecursively(srcDir: string, fileName: string, visited?: Set<string>): string;
13
+ /**
14
+ * Try to combine each source path in the array with the relative path, returning the first absolute path that exists.
15
+ * @param srcPathList Source path array (absolute or relative paths)
16
+ * @param relativePath The relative path to concatenate
17
+ * @returns The first concatenated absolute path that exists; otherwise returns an empty string
18
+ */
19
+ export declare function getFileAbsPath(srcPathList: string[], relativePath: string): string;
20
+ export declare function getFileSignatureMapKey(projectName: string, fileName: string): string;
21
21
  //# sourceMappingURL=FileUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FileUtils.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD,qBAAa,SAAS;IAClB,gBAAuB,WAAW;;;MAGhC;WAEY,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;WASzC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;WAUrC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIrC,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC;WAkClG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ;CAgB1F;AAED,qBAAa,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAIzC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,GAAG,CAAC,MAAM,CAAqB,GAAG,MAAM,CA2BrH"}
1
+ {"version":3,"file":"FileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FileUtils.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AASjD,qBAAa,SAAS;IAClB,gBAAuB,WAAW;;;MAGhC;WAEY,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;WASzC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;WAUrC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIrC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ;CAmB1F;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,GAAG,CAAC,MAAM,CAAqB,GAAG,MAAM,CA2BrH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAclF;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIpF"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3
+ * Copyright (c) 2024-2026 Huawei Device Co., Ltd.
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
6
6
  * You may obtain a copy of the License at
@@ -40,14 +40,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  return (mod && mod.__esModule) ? mod : { "default": mod };
41
41
  };
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.getFileRecursively = exports.ModulePath = exports.FileUtils = void 0;
43
+ exports.getFileSignatureMapKey = exports.getFileAbsPath = exports.getFileRecursively = exports.FileUtils = void 0;
44
44
  const fs_1 = __importDefault(require("fs"));
45
45
  const path_1 = __importDefault(require("path"));
46
46
  const logger_1 = __importStar(require("./logger"));
47
- const pathTransfer_1 = require("./pathTransfer");
48
- const EtsConst_1 = require("../core/common/EtsConst");
49
47
  const ArkFile_1 = require("../core/model/ArkFile");
48
+ const ast_1 = require("../frontend/cppFrontend/ast");
49
+ const crypto_utils_1 = require("./crypto_utils");
50
+ const pathTransfer_1 = require("./pathTransfer");
50
51
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'FileUtils');
52
+ const CXX_EXTENSION_SET = (0, ast_1.getCxxSourceFileExtensionSet)();
51
53
  class FileUtils {
52
54
  static getIndexFileName(srcPath) {
53
55
  for (const fileInDir of fs_1.default.readdirSync(srcPath, { withFileTypes: true })) {
@@ -70,40 +72,6 @@ class FileUtils {
70
72
  static isAbsolutePath(path) {
71
73
  return /^(\/|\\|[A-Z]:\\)/.test(path);
72
74
  }
73
- static generateModuleMap(ohPkgContentMap) {
74
- const moduleMap = new Map();
75
- ohPkgContentMap.forEach((content, filePath) => {
76
- const moduleName = content.name;
77
- if (moduleName && moduleName.startsWith('@')) {
78
- const modulePath = path_1.default.dirname(filePath);
79
- moduleMap.set(moduleName, new ModulePath(modulePath, content.main ? path_1.default.resolve(modulePath, content.main) : ''));
80
- }
81
- });
82
- ohPkgContentMap.forEach((content, filePath) => {
83
- if (!content.dependencies) {
84
- return;
85
- }
86
- Object.entries(content.dependencies).forEach(([name, value]) => {
87
- if (moduleMap.get(name)) {
88
- return;
89
- }
90
- const dir = path_1.default.dirname(filePath);
91
- let modulePath = path_1.default.resolve(dir, value.replace('file:', ''));
92
- let main = '';
93
- if (this.isDirectory(modulePath)) {
94
- const target = ohPkgContentMap.get(path_1.default.resolve(modulePath, EtsConst_1.OH_PACKAGE_JSON5));
95
- if (target === null || target === void 0 ? void 0 : target.main) {
96
- main = path_1.default.resolve(modulePath, target.main);
97
- }
98
- }
99
- else {
100
- modulePath = path_1.default.resolve(dir, 'oh_modules', name);
101
- }
102
- moduleMap.set(name, new ModulePath(modulePath, main));
103
- });
104
- });
105
- return moduleMap;
106
- }
107
75
  static getFileLanguage(file, fileTags) {
108
76
  if (fileTags && fileTags.has(file)) {
109
77
  return fileTags.get(file);
@@ -117,6 +85,9 @@ class FileUtils {
117
85
  case '.js':
118
86
  return ArkFile_1.Language.JAVASCRIPT;
119
87
  default:
88
+ if (CXX_EXTENSION_SET.has(extension)) {
89
+ return ArkFile_1.Language.CXX;
90
+ }
120
91
  return ArkFile_1.Language.UNKNOWN;
121
92
  }
122
93
  }
@@ -126,13 +97,6 @@ FileUtils.FILE_FILTER = {
126
97
  ignores: ['.git', '.preview', '.hvigor', '.idea', 'test', 'ohosTest'],
127
98
  include: /(?<!\.d)\.(ets|ts|json5)$/,
128
99
  };
129
- class ModulePath {
130
- constructor(path, main) {
131
- this.path = (0, pathTransfer_1.transfer2UnixPath)(path);
132
- this.main = main ? (0, pathTransfer_1.transfer2UnixPath)(main) : main;
133
- }
134
- }
135
- exports.ModulePath = ModulePath;
136
100
  function getFileRecursively(srcDir, fileName, visited = new Set()) {
137
101
  let res = '';
138
102
  if (!FileUtils.isDirectory(srcDir)) {
@@ -160,3 +124,29 @@ function getFileRecursively(srcDir, fileName, visited = new Set()) {
160
124
  return res;
161
125
  }
162
126
  exports.getFileRecursively = getFileRecursively;
127
+ /**
128
+ * Try to combine each source path in the array with the relative path, returning the first absolute path that exists.
129
+ * @param srcPathList Source path array (absolute or relative paths)
130
+ * @param relativePath The relative path to concatenate
131
+ * @returns The first concatenated absolute path that exists; otherwise returns an empty string
132
+ */
133
+ function getFileAbsPath(srcPathList, relativePath) {
134
+ if (!srcPathList || srcPathList.length === 0 || !relativePath) {
135
+ return '';
136
+ }
137
+ for (const srcPath of srcPathList) {
138
+ const srcDir = path_1.default.dirname(path_1.default.resolve(srcPath));
139
+ const absPath = path_1.default.resolve(srcDir, relativePath);
140
+ if (fs_1.default.existsSync(absPath)) {
141
+ return absPath;
142
+ }
143
+ }
144
+ return '';
145
+ }
146
+ exports.getFileAbsPath = getFileAbsPath;
147
+ function getFileSignatureMapKey(projectName, fileName) {
148
+ const normalizedFileName = (0, pathTransfer_1.transfer2UnixPath)(fileName);
149
+ const hashcode = crypto_utils_1.CryptoUtils.hashcode(`@${projectName}/${normalizedFileName}: `);
150
+ return `${hashcode}${path_1.default.basename(normalizedFileName)}`;
151
+ }
152
+ exports.getFileSignatureMapKey = getFileSignatureMapKey;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A function that generates a cache key from method arguments.
3
+ */
4
+ export type KeyGenerator = (...args: any[]) => string;
5
+ /**
6
+ * LRU (Least Recently Used) cache decorator for methods.
7
+ * Caches return values based on method arguments, evicting the oldest entry
8
+ * when the cache reaches maxSize.
9
+ *
10
+ * @param maxSize - Maximum number of entries to keep in the cache.
11
+ * @param keyGenerator - Optional custom function to generate cache keys from method arguments.
12
+ */
13
+ export declare function LRUCache(maxSize?: number, keyGenerator?: KeyGenerator): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;
14
+ /**
15
+ * Clear the LRU cache associated with a decorated method.
16
+ * @param target - The class (for static methods) or instance (for instance methods).
17
+ * @param propertyKey - The method name.
18
+ */
19
+ export declare function clearLRUCache(target: any, propertyKey: string): void;
20
+ //# sourceMappingURL=LRUCacheDecorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LRUCacheDecorator.d.ts","sourceRoot":"","sources":["../../src/utils/LRUCacheDecorator.ts"],"names":[],"mappings":"AA0CA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC;AAItD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,MAAa,EAAE,YAAY,CAAC,EAAE,YAAY,aAG9C,GAAG,gBAAgB,MAAM,cAAc,kBAAkB,UAuBtF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAGpE"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024-2026 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.clearLRUCache = exports.LRUCache = void 0;
18
+ /**
19
+ * LRU Cache Decorator — method-level caching with Least Recently Used eviction.
20
+ *
21
+ * Usage:
22
+ * import { LRUCache, clearLRUCache } from './LRUCacheDecorator';
23
+ *
24
+ * class Foo {
25
+ * // Basic: cache up to 4096 entries (default)
26
+ * @LRUCache()
27
+ * static resolve(path: string): string { ... }
28
+ *
29
+ * // Custom capacity
30
+ * @LRUCache(1024)
31
+ * static lookup(id: number): string { ... }
32
+ *
33
+ * // Custom key generator — useful when you want case-insensitive keys,
34
+ * // partial-argument keys, or any custom serialization.
35
+ * @LRUCache(4096, (srcPath) => srcPath.toLowerCase())
36
+ * static getFileRealPath(srcPath: string): string { ... }
37
+ * }
38
+ *
39
+ * // Clear the cache of a decorated method (e.g. on dispose)
40
+ * clearLRUCache(Foo, 'resolve');
41
+ */
42
+ const LRU_CACHE_SYMBOL = Symbol('LRUCache');
43
+ const defaultKeyGenerator = (...args) => args.join();
44
+ /**
45
+ * LRU (Least Recently Used) cache decorator for methods.
46
+ * Caches return values based on method arguments, evicting the oldest entry
47
+ * when the cache reaches maxSize.
48
+ *
49
+ * @param maxSize - Maximum number of entries to keep in the cache.
50
+ * @param keyGenerator - Optional custom function to generate cache keys from method arguments.
51
+ */
52
+ function LRUCache(maxSize = 4096, keyGenerator) {
53
+ const resolveKey = keyGenerator !== null && keyGenerator !== void 0 ? keyGenerator : defaultKeyGenerator;
54
+ const cache = new Map();
55
+ return function (_target, _propertyKey, descriptor) {
56
+ const originalMethod = descriptor.value;
57
+ descriptor.value = function (...args) {
58
+ const key = resolveKey(...args);
59
+ if (cache.has(key)) {
60
+ const value = cache.get(key);
61
+ cache.delete(key);
62
+ cache.set(key, value);
63
+ return value;
64
+ }
65
+ const result = originalMethod.apply(this, args);
66
+ if (cache.size >= maxSize) {
67
+ const firstKey = cache.keys().next().value;
68
+ if (firstKey) {
69
+ cache.delete(firstKey);
70
+ }
71
+ }
72
+ cache.set(key, result);
73
+ return result;
74
+ };
75
+ descriptor.value[LRU_CACHE_SYMBOL] = cache;
76
+ };
77
+ }
78
+ exports.LRUCache = LRUCache;
79
+ /**
80
+ * Clear the LRU cache associated with a decorated method.
81
+ * @param target - The class (for static methods) or instance (for instance methods).
82
+ * @param propertyKey - The method name.
83
+ */
84
+ function clearLRUCache(target, propertyKey) {
85
+ var _a;
86
+ const cache = (_a = target[propertyKey]) === null || _a === void 0 ? void 0 : _a[LRU_CACHE_SYMBOL];
87
+ cache === null || cache === void 0 ? void 0 : cache.clear();
88
+ }
89
+ exports.clearLRUCache = clearLRUCache;
@@ -0,0 +1,39 @@
1
+ export declare class ModulePath {
2
+ path: string;
3
+ main: string;
4
+ /**
5
+ * Create a new ModulePath instance.
6
+ * @param path - The module path.
7
+ * @param main - The main entry file path of the module.
8
+ */
9
+ constructor(path: string, main: string);
10
+ }
11
+ export declare class ModuleUtils {
12
+ private static readonly FILE_EXT;
13
+ private static readonly OH_PACKAGE_DEPENDENCY_KEYS;
14
+ static MODULES: Map<string, ModulePath>;
15
+ static dispose(): void;
16
+ /**
17
+ * Get the real file path for a given source path, resolving file extensions and checking existence.
18
+ * Results are cached via LRU for performance.
19
+ * @param srcPath - The source path to resolve, e.g.: /projectA/src/foo
20
+ * @returns The resolved real file path, or empty string if not found.
21
+ */
22
+ static getFileRealPath(srcPath: string): string;
23
+ /**
24
+ * Generate a module map from oh-package.json5 content.
25
+ * @param ohPkgContentMap - A map of oh-package.json5 file paths to their parsed content.
26
+ * @returns A map of module names to their module paths.
27
+ */
28
+ static generateModuleMap(ohPkgContentMap: Map<string, {
29
+ [k: string]: unknown;
30
+ }>): Map<string, ModulePath>;
31
+ private static addDependModule;
32
+ private static processDependency;
33
+ /**
34
+ * Handle "foo_test": "@module:Foo" dependency.
35
+ */
36
+ private static handleModuleRefDependency;
37
+ private static findModulePathInOHPM;
38
+ }
39
+ //# sourceMappingURL=ModuleUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ModuleUtils.ts"],"names":[],"mappings":"AA2BA,qBAAa,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAIzC;AAGD,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA+F;IAC/H,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAA8D;IAChH,OAAc,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;WAM7C,OAAO,IAAI,IAAI;IAK7B;;;;;OAKG;WAEW,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IA6CtD;;;;OAIG;WACW,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC;IA2BhH,OAAO,CAAC,MAAM,CAAC,eAAe;IA6B9B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA8BhC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAaxC,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAyBtC"}