arkanalyzer 1.0.90 → 1.0.91

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 (122) hide show
  1. package/config/arkanalyzer.json +0 -1
  2. package/lib/Config.d.ts +3 -0
  3. package/lib/Config.d.ts.map +1 -1
  4. package/lib/Scene.d.ts +99 -0
  5. package/lib/Scene.d.ts.map +1 -1
  6. package/lib/Scene.js +229 -13
  7. package/lib/callgraph/common/Statistics.js +2 -2
  8. package/lib/callgraph/model/CallGraph.d.ts +2 -2
  9. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  10. package/lib/callgraph/model/CallGraph.js +6 -6
  11. package/lib/callgraph/model/CallSite.d.ts +1 -1
  12. package/lib/callgraph/model/CallSite.d.ts.map +1 -1
  13. package/lib/callgraph/model/CallSite.js +2 -2
  14. package/lib/core/base/Ref.d.ts.map +1 -1
  15. package/lib/core/base/Ref.js +6 -1
  16. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  17. package/lib/core/common/ArkIRTransformer.js +5 -0
  18. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  19. package/lib/core/common/ArkValueTransformer.js +2 -1
  20. package/lib/core/common/Const.d.ts +3 -0
  21. package/lib/core/common/Const.d.ts.map +1 -1
  22. package/lib/core/common/Const.js +5 -1
  23. package/lib/core/common/DummyMainCreater.d.ts +25 -12
  24. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  25. package/lib/core/common/DummyMainCreater.js +90 -76
  26. package/lib/core/common/EtsConst.d.ts +2 -0
  27. package/lib/core/common/EtsConst.d.ts.map +1 -1
  28. package/lib/core/common/EtsConst.js +133 -125
  29. package/lib/core/common/SdkUtils.d.ts +1 -0
  30. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  31. package/lib/core/common/SdkUtils.js +29 -0
  32. package/lib/core/graph/BaseExplicitGraph.d.ts +2 -0
  33. package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
  34. package/lib/core/graph/BaseExplicitGraph.js +12 -1
  35. package/lib/core/graph/BaseImplicitGraph.d.ts +16 -0
  36. package/lib/core/graph/BaseImplicitGraph.d.ts.map +1 -1
  37. package/lib/core/graph/BaseImplicitGraph.js +21 -0
  38. package/lib/core/graph/FileDepGraph.d.ts +75 -0
  39. package/lib/core/graph/FileDepGraph.d.ts.map +1 -0
  40. package/lib/core/graph/FileDepGraph.js +170 -0
  41. package/lib/core/graph/GraphTraits.d.ts +2 -0
  42. package/lib/core/graph/GraphTraits.d.ts.map +1 -1
  43. package/lib/core/graph/GraphTraits.js +1 -1
  44. package/lib/core/graph/ModuleDepGraph.d.ts +175 -0
  45. package/lib/core/graph/ModuleDepGraph.d.ts.map +1 -0
  46. package/lib/core/graph/ModuleDepGraph.js +421 -0
  47. package/lib/core/graph/Scc.d.ts +1 -3
  48. package/lib/core/graph/Scc.d.ts.map +1 -1
  49. package/lib/core/graph/Scc.js +6 -19
  50. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  51. package/lib/core/graph/builder/CfgBuilder.js +7 -1
  52. package/lib/core/graph/builder/TrapBuilder.d.ts +1 -0
  53. package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
  54. package/lib/core/graph/builder/TrapBuilder.js +27 -7
  55. package/lib/core/model/ArkBody.d.ts +1 -0
  56. package/lib/core/model/ArkBody.d.ts.map +1 -1
  57. package/lib/core/model/ArkBody.js +7 -0
  58. package/lib/core/model/ArkClass.d.ts +1 -0
  59. package/lib/core/model/ArkClass.d.ts.map +1 -1
  60. package/lib/core/model/ArkClass.js +37 -0
  61. package/lib/core/model/ArkExport.d.ts +1 -0
  62. package/lib/core/model/ArkExport.d.ts.map +1 -1
  63. package/lib/core/model/ArkExport.js +6 -0
  64. package/lib/core/model/ArkField.d.ts +1 -0
  65. package/lib/core/model/ArkField.d.ts.map +1 -1
  66. package/lib/core/model/ArkField.js +5 -0
  67. package/lib/core/model/ArkFile.d.ts +5 -0
  68. package/lib/core/model/ArkFile.d.ts.map +1 -1
  69. package/lib/core/model/ArkFile.js +30 -0
  70. package/lib/core/model/ArkImport.d.ts +1 -0
  71. package/lib/core/model/ArkImport.d.ts.map +1 -1
  72. package/lib/core/model/ArkImport.js +5 -0
  73. package/lib/core/model/ArkMethod.d.ts +8 -0
  74. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  75. package/lib/core/model/ArkMethod.js +22 -0
  76. package/lib/core/model/ArkModule.d.ts +136 -0
  77. package/lib/core/model/ArkModule.d.ts.map +1 -0
  78. package/lib/core/model/ArkModule.js +250 -0
  79. package/lib/core/model/ArkNamespace.d.ts +1 -0
  80. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  81. package/lib/core/model/ArkNamespace.js +18 -0
  82. package/lib/core/model/builder/ArkFileBuilder.d.ts +19 -0
  83. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
  84. package/lib/core/model/builder/ArkFileBuilder.js +155 -51
  85. package/lib/frontend/FrontendBuilder.d.ts +116 -0
  86. package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
  87. package/lib/frontend/FrontendBuilder.js +256 -0
  88. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +11 -0
  89. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
  90. package/lib/frontend/arktsFrontend/ArktsFrontend.js +15 -0
  91. package/lib/frontend/common/MemoryMonitor.d.ts +62 -0
  92. package/lib/frontend/common/MemoryMonitor.d.ts.map +1 -0
  93. package/lib/frontend/common/MemoryMonitor.js +108 -0
  94. package/lib/frontend/common/ModuleAnalysisConfig.d.ts +92 -0
  95. package/lib/frontend/common/ModuleAnalysisConfig.d.ts.map +1 -0
  96. package/lib/frontend/common/ModuleAnalysisConfig.js +144 -0
  97. package/lib/frontend/common/ModuleBuilder.d.ts +497 -0
  98. package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -0
  99. package/lib/frontend/common/ModuleBuilder.js +1458 -0
  100. package/lib/frontend/common/ModuleCache.d.ts +119 -0
  101. package/lib/frontend/common/ModuleCache.d.ts.map +1 -0
  102. package/lib/frontend/common/ModuleCache.js +197 -0
  103. package/lib/frontend/common/ModuleDepth.d.ts +28 -0
  104. package/lib/frontend/common/ModuleDepth.d.ts.map +1 -0
  105. package/lib/frontend/common/ModuleDepth.js +45 -0
  106. package/lib/frontend/cppFrontend/CppFrontend.d.ts +5 -0
  107. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
  108. package/lib/frontend/cppFrontend/CppFrontend.js +11 -1
  109. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +8 -0
  110. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  111. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +105 -2
  112. package/lib/index.d.ts +9 -1
  113. package/lib/index.d.ts.map +1 -1
  114. package/lib/index.js +22 -3
  115. package/lib/utils/Canonicalizer.d.ts +105 -0
  116. package/lib/utils/Canonicalizer.d.ts.map +1 -0
  117. package/lib/utils/Canonicalizer.js +520 -0
  118. package/lib/utils/ModuleUtils.js +4 -2
  119. package/lib/utils/entryMethodUtils.d.ts +23 -0
  120. package/lib/utils/entryMethodUtils.d.ts.map +1 -1
  121. package/lib/utils/entryMethodUtils.js +53 -1
  122. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ import type { ModuleID } from '../../core/model/ArkModule';
2
+ import type { MemoryMonitor } from './MemoryMonitor';
3
+ import { ModuleDepthLevel } from './ModuleDepth';
4
+ /**
5
+ * Mutable heapUsed estimate tracking state used during eviction.
6
+ *
7
+ * `estimate` starts at the actual heapUsed measured before eviction and is
8
+ * decremented by the heapUsed table value of each unloaded/downgraded module.
9
+ * Eviction stops when `estimate` falls to or below `limit`.
10
+ */
11
+ export interface HeapUsedEstimateState {
12
+ estimate: number;
13
+ limit: number;
14
+ }
15
+ /**
16
+ * Maintains the set of currently-loaded modules and evicts them when memory pressure
17
+ * exceeds the threshold.
18
+ *
19
+ * This class performs Phase 1 only: evicting modules that are neither in the hard nor soft
20
+ * protected set (not depended on by the current or subsequent modules), in LRU order. The
21
+ * caller ({@link ModuleBuilder.evictIfNeeded}) handles the subsequent phases:
22
+ * - **Phase 2** — downgrade protected dependencies to dependencyLoadLevel (release method
23
+ * bodies/AST, keep signatures), in reverse-topo order.
24
+ * - **Phase 3** — if still over threshold, evict the protected dependencies (full unload),
25
+ * in reverse-topo order.
26
+ *
27
+ * The hard protected set contains modules that must never be evicted (the current target
28
+ * module and its dependency closure). The soft protected set contains modules that are
29
+ * directly depended on by not-yet-loaded modules (evicting them causes reload overhead
30
+ * but is safe).
31
+ *
32
+ * SCC groups: if a module belongs to a cyclic dependency group (size > 1), the entire
33
+ * group is treated as a unit — either all members are evictable or none is evicted.
34
+ *
35
+ * ## heapUsed Table
36
+ *
37
+ * A heapUsed table ({@link heapUsedTable}) records the heapUsed increment observed during
38
+ * the first load of each module at each depth level. This table is:
39
+ * - Populated on first load only (subsequent reloads do not update it).
40
+ * - Not cleared on module unload (persists across load/unload cycles).
41
+ * - Cleared only on full cache reset ({@link clear}).
42
+ *
43
+ * During eviction, the table provides estimated heapUsed decreases for unload/downgrade
44
+ * via the `getHeapUsedDecrease` callback — only one actual heapUsed measurement is taken
45
+ * at the start of eviction, and all subsequent tracking uses table values.
46
+ *
47
+ * @category frontend/common
48
+ */
49
+ export declare class ModuleCache {
50
+ private loadedModules;
51
+ private accessOrder;
52
+ /**
53
+ * Per-module heapUsed table, indexed by depth level.
54
+ * Records the heapUsed increment (bytes) from the first load of each module at each level.
55
+ * Persists across unload/load cycles; cleared only by {@link clear}.
56
+ */
57
+ private heapUsedTable;
58
+ /** Register a module as loaded. */
59
+ register(moduleId: ModuleID): void;
60
+ /** Unregister a module (called after it has been unloaded). Does NOT clear the heapUsed table. */
61
+ unregister(moduleId: ModuleID): void;
62
+ /** Whether the given module is currently loaded. */
63
+ has(moduleId: ModuleID): boolean;
64
+ /** Number of currently loaded modules. */
65
+ size(): number;
66
+ /** All currently loaded module IDs. */
67
+ getLoadedModules(): ModuleID[];
68
+ /** Remove all entries from the cache, including the heapUsed table. */
69
+ clear(): void;
70
+ /**
71
+ * Record the heapUsed increment for a module at the given depth level.
72
+ *
73
+ * Only records on the first load (when no entry exists for this module+level pair).
74
+ * Subsequent reloads do not update the value. Module unload does not erase it.
75
+ *
76
+ * @param moduleId - The module ID.
77
+ * @param level - The depth level at which the module was loaded.
78
+ * @param heapUsedBytes - The heapUsed increment (bytes) observed during loading.
79
+ */
80
+ recordHeapUsed(moduleId: ModuleID, level: ModuleDepthLevel, heapUsedBytes: number): void;
81
+ /**
82
+ * Get the recorded heapUsed for a module at the given depth level.
83
+ *
84
+ * @returns The recorded heapUsed in bytes, or `undefined` if not yet recorded.
85
+ */
86
+ getHeapUsed(moduleId: ModuleID, level: ModuleDepthLevel): number | undefined;
87
+ /**
88
+ * Evict loaded modules until the heapUsed estimate is below the limit (or no more candidates remain).
89
+ *
90
+ * This performs Phase 1 only: evicting modules that are neither in the hard nor soft protected
91
+ * set. Downgrading (Phase 2) and evicting protected dependencies (Phase 3) are handled by
92
+ * the caller (ModuleBuilder.evictIfNeeded).
93
+ *
94
+ * Instead of calling `process.memoryUsage()` after each unload, this method uses the
95
+ * {@link HeapUsedEstimateState} to track the estimated heapUsed. The `getHeapUsedDecrease`
96
+ * callback provides the estimated heapUsed decrease for each module (from the heapUsed table
97
+ * or fallback).
98
+ *
99
+ * @param hardProtectedSet - Modules that must never be evicted.
100
+ * @param softProtectedSet - Modules that should not be evicted in Phase 1.
101
+ * @param monitor - The memory monitor (used only for `isEnabled()` guard).
102
+ * @param unloadFn - Callback to unload a module by ID.
103
+ * @param sccGroups - Optional SCC group map; members of the same group are evicted together.
104
+ * @param heapUsedState - Mutable heapUsed estimate state; `estimate` is decremented as modules are evicted.
105
+ * @param getHeapUsedDecrease - Callback returning the estimated heapUsed decrease (bytes) for a module.
106
+ */
107
+ evict(hardProtectedSet: Set<ModuleID>, softProtectedSet: Set<ModuleID>, monitor: MemoryMonitor, unloadFn: (moduleId: ModuleID) => void, sccGroups: Map<ModuleID, ModuleID[]> | undefined, heapUsedState: HeapUsedEstimateState, getHeapUsedDecrease: (moduleId: ModuleID) => number): void;
108
+ private evictFromList;
109
+ /**
110
+ * Try to evict an SCC group as a unit. Returns true if the module belongs to an SCC group
111
+ * (size > 1) and the group was handled (either evicted or skipped due to protected members).
112
+ * Returns false if the module is not part of a multi-member SCC group.
113
+ *
114
+ * When evicting, the heapUsed decrease for each group member is obtained from
115
+ * `getHeapUsedDecrease` and subtracted from `heapUsedState.estimate`.
116
+ */
117
+ private tryEvictSCCGroup;
118
+ }
119
+ //# sourceMappingURL=ModuleCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleCache.d.ts","sourceRoot":"","sources":["../../../src/frontend/common/ModuleCache.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,WAAW,CAAkB;IAErC;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAA2D;IAEhF,mCAAmC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAOzC,kGAAkG;IAC3F,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAS3C,oDAAoD;IAC7C,GAAG,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAIvC,0CAA0C;IACnC,IAAI,IAAI,MAAM;IAIrB,uCAAuC;IAChC,gBAAgB,IAAI,QAAQ,EAAE;IAIrC,uEAAuE;IAChE,KAAK,IAAI,IAAI;IAMpB;;;;;;;;;OASG;IACI,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAW/F;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS;IAInF;;;;;;;;;;;;;;;;;;;OAmBG;IACI,KAAK,CACR,gBAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,EAC/B,gBAAgB,EAAE,GAAG,CAAC,QAAQ,CAAC,EAC/B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,EACtC,SAAS,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAChD,aAAa,EAAE,qBAAqB,EACpC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,MAAM,GACpD,IAAI;IAUP,OAAO,CAAC,aAAa;IA2BrB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;CAwB3B"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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.ModuleCache = void 0;
18
+ /**
19
+ * Maintains the set of currently-loaded modules and evicts them when memory pressure
20
+ * exceeds the threshold.
21
+ *
22
+ * This class performs Phase 1 only: evicting modules that are neither in the hard nor soft
23
+ * protected set (not depended on by the current or subsequent modules), in LRU order. The
24
+ * caller ({@link ModuleBuilder.evictIfNeeded}) handles the subsequent phases:
25
+ * - **Phase 2** — downgrade protected dependencies to dependencyLoadLevel (release method
26
+ * bodies/AST, keep signatures), in reverse-topo order.
27
+ * - **Phase 3** — if still over threshold, evict the protected dependencies (full unload),
28
+ * in reverse-topo order.
29
+ *
30
+ * The hard protected set contains modules that must never be evicted (the current target
31
+ * module and its dependency closure). The soft protected set contains modules that are
32
+ * directly depended on by not-yet-loaded modules (evicting them causes reload overhead
33
+ * but is safe).
34
+ *
35
+ * SCC groups: if a module belongs to a cyclic dependency group (size > 1), the entire
36
+ * group is treated as a unit — either all members are evictable or none is evicted.
37
+ *
38
+ * ## heapUsed Table
39
+ *
40
+ * A heapUsed table ({@link heapUsedTable}) records the heapUsed increment observed during
41
+ * the first load of each module at each depth level. This table is:
42
+ * - Populated on first load only (subsequent reloads do not update it).
43
+ * - Not cleared on module unload (persists across load/unload cycles).
44
+ * - Cleared only on full cache reset ({@link clear}).
45
+ *
46
+ * During eviction, the table provides estimated heapUsed decreases for unload/downgrade
47
+ * via the `getHeapUsedDecrease` callback — only one actual heapUsed measurement is taken
48
+ * at the start of eviction, and all subsequent tracking uses table values.
49
+ *
50
+ * @category frontend/common
51
+ */
52
+ class ModuleCache {
53
+ constructor() {
54
+ this.loadedModules = new Set();
55
+ this.accessOrder = [];
56
+ /**
57
+ * Per-module heapUsed table, indexed by depth level.
58
+ * Records the heapUsed increment (bytes) from the first load of each module at each level.
59
+ * Persists across unload/load cycles; cleared only by {@link clear}.
60
+ */
61
+ this.heapUsedTable = new Map();
62
+ }
63
+ /** Register a module as loaded. */
64
+ register(moduleId) {
65
+ if (!this.loadedModules.has(moduleId)) {
66
+ this.loadedModules.add(moduleId);
67
+ this.accessOrder.push(moduleId);
68
+ }
69
+ }
70
+ /** Unregister a module (called after it has been unloaded). Does NOT clear the heapUsed table. */
71
+ unregister(moduleId) {
72
+ if (this.loadedModules.delete(moduleId)) {
73
+ const idx = this.accessOrder.indexOf(moduleId);
74
+ if (idx >= 0) {
75
+ this.accessOrder.splice(idx, 1);
76
+ }
77
+ }
78
+ }
79
+ /** Whether the given module is currently loaded. */
80
+ has(moduleId) {
81
+ return this.loadedModules.has(moduleId);
82
+ }
83
+ /** Number of currently loaded modules. */
84
+ size() {
85
+ return this.loadedModules.size;
86
+ }
87
+ /** All currently loaded module IDs. */
88
+ getLoadedModules() {
89
+ return Array.from(this.loadedModules);
90
+ }
91
+ /** Remove all entries from the cache, including the heapUsed table. */
92
+ clear() {
93
+ this.loadedModules.clear();
94
+ this.accessOrder.length = 0;
95
+ this.heapUsedTable.clear();
96
+ }
97
+ /**
98
+ * Record the heapUsed increment for a module at the given depth level.
99
+ *
100
+ * Only records on the first load (when no entry exists for this module+level pair).
101
+ * Subsequent reloads do not update the value. Module unload does not erase it.
102
+ *
103
+ * @param moduleId - The module ID.
104
+ * @param level - The depth level at which the module was loaded.
105
+ * @param heapUsedBytes - The heapUsed increment (bytes) observed during loading.
106
+ */
107
+ recordHeapUsed(moduleId, level, heapUsedBytes) {
108
+ let levelMap = this.heapUsedTable.get(moduleId);
109
+ if (!levelMap) {
110
+ levelMap = new Map();
111
+ this.heapUsedTable.set(moduleId, levelMap);
112
+ }
113
+ if (!levelMap.has(level)) {
114
+ levelMap.set(level, heapUsedBytes);
115
+ }
116
+ }
117
+ /**
118
+ * Get the recorded heapUsed for a module at the given depth level.
119
+ *
120
+ * @returns The recorded heapUsed in bytes, or `undefined` if not yet recorded.
121
+ */
122
+ getHeapUsed(moduleId, level) {
123
+ var _a;
124
+ return (_a = this.heapUsedTable.get(moduleId)) === null || _a === void 0 ? void 0 : _a.get(level);
125
+ }
126
+ /**
127
+ * Evict loaded modules until the heapUsed estimate is below the limit (or no more candidates remain).
128
+ *
129
+ * This performs Phase 1 only: evicting modules that are neither in the hard nor soft protected
130
+ * set. Downgrading (Phase 2) and evicting protected dependencies (Phase 3) are handled by
131
+ * the caller (ModuleBuilder.evictIfNeeded).
132
+ *
133
+ * Instead of calling `process.memoryUsage()` after each unload, this method uses the
134
+ * {@link HeapUsedEstimateState} to track the estimated heapUsed. The `getHeapUsedDecrease`
135
+ * callback provides the estimated heapUsed decrease for each module (from the heapUsed table
136
+ * or fallback).
137
+ *
138
+ * @param hardProtectedSet - Modules that must never be evicted.
139
+ * @param softProtectedSet - Modules that should not be evicted in Phase 1.
140
+ * @param monitor - The memory monitor (used only for `isEnabled()` guard).
141
+ * @param unloadFn - Callback to unload a module by ID.
142
+ * @param sccGroups - Optional SCC group map; members of the same group are evicted together.
143
+ * @param heapUsedState - Mutable heapUsed estimate state; `estimate` is decremented as modules are evicted.
144
+ * @param getHeapUsedDecrease - Callback returning the estimated heapUsed decrease (bytes) for a module.
145
+ */
146
+ evict(hardProtectedSet, softProtectedSet, monitor, unloadFn, sccGroups, heapUsedState, getHeapUsedDecrease) {
147
+ if (!monitor.isEnabled() || heapUsedState.estimate <= heapUsedState.limit) {
148
+ return;
149
+ }
150
+ // Phase 1: evict modules not in hard or soft protected set, in LRU order
151
+ const phase1Protected = new Set([...hardProtectedSet, ...softProtectedSet]);
152
+ this.evictFromList([...this.accessOrder], phase1Protected, unloadFn, sccGroups, heapUsedState, getHeapUsedDecrease);
153
+ }
154
+ evictFromList(list, protectedSet, unloadFn, sccGroups, heapUsedState, getHeapUsedDecrease) {
155
+ for (const moduleId of list) {
156
+ if (heapUsedState.estimate <= heapUsedState.limit) {
157
+ return;
158
+ }
159
+ if (!this.loadedModules.has(moduleId) || protectedSet.has(moduleId)) {
160
+ continue;
161
+ }
162
+ if (sccGroups && this.tryEvictSCCGroup(moduleId, protectedSet, unloadFn, sccGroups, heapUsedState, getHeapUsedDecrease)) {
163
+ continue;
164
+ }
165
+ const decrease = getHeapUsedDecrease(moduleId);
166
+ unloadFn(moduleId);
167
+ this.unregister(moduleId);
168
+ heapUsedState.estimate -= decrease;
169
+ }
170
+ }
171
+ /**
172
+ * Try to evict an SCC group as a unit. Returns true if the module belongs to an SCC group
173
+ * (size > 1) and the group was handled (either evicted or skipped due to protected members).
174
+ * Returns false if the module is not part of a multi-member SCC group.
175
+ *
176
+ * When evicting, the heapUsed decrease for each group member is obtained from
177
+ * `getHeapUsedDecrease` and subtracted from `heapUsedState.estimate`.
178
+ */
179
+ tryEvictSCCGroup(moduleId, protectedSet, unloadFn, sccGroups, heapUsedState, getHeapUsedDecrease) {
180
+ const group = sccGroups.get(moduleId);
181
+ if (!group || group.length <= 1) {
182
+ return false;
183
+ }
184
+ // All members must be evictable and currently loaded
185
+ const blocked = group.some(m => protectedSet.has(m) || !this.loadedModules.has(m));
186
+ if (!blocked) {
187
+ for (const m of group) {
188
+ const decrease = getHeapUsedDecrease(m);
189
+ unloadFn(m);
190
+ this.unregister(m);
191
+ heapUsedState.estimate -= decrease;
192
+ }
193
+ }
194
+ return true;
195
+ }
196
+ }
197
+ exports.ModuleCache = ModuleCache;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Module data depth levels controlling how much data is built for ArkFile objects.
3
+ * Higher levels are supersets of lower levels (incremental relationship).
4
+ *
5
+ * @category core/model
6
+ */
7
+ export declare enum ModuleDepthLevel {
8
+ /**
9
+ * Level 0: Module metadata + dependency topology + ArkFile (path-only basic info).
10
+ * Index files (index.ets/index.ts) are exceptions: their ArkFile includes export/import info.
11
+ * Other files are NOT read or parsed.
12
+ */
13
+ META = 0,
14
+ /**
15
+ * Level 1: META + export/import info for ALL ArkFiles + intra-module file dependencies.
16
+ */
17
+ IMPORTS = 1,
18
+ /**
19
+ * Level 2: IMPORTS + ArkFile content excluding method bodies
20
+ * (namespaces, classes, method signatures, parameters, return types).
21
+ */
22
+ SIGNATURES = 2,
23
+ /**
24
+ * Level 3: SIGNATURES + method bodies (ArkBody, CFG, Stmt/Expr).
25
+ */
26
+ BODIES = 3
27
+ }
28
+ //# sourceMappingURL=ModuleDepth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModuleDepth.d.ts","sourceRoot":"","sources":["../../../src/frontend/common/ModuleDepth.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,oBAAY,gBAAgB;IACxB;;;;OAIG;IACH,IAAI,IAAI;IAER;;OAEG;IACH,OAAO,IAAI;IAEX;;;OAGG;IACH,UAAU,IAAI;IAEd;;OAEG;IACH,MAAM,IAAI;CACb"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 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.ModuleDepthLevel = void 0;
18
+ /**
19
+ * Module data depth levels controlling how much data is built for ArkFile objects.
20
+ * Higher levels are supersets of lower levels (incremental relationship).
21
+ *
22
+ * @category core/model
23
+ */
24
+ var ModuleDepthLevel;
25
+ (function (ModuleDepthLevel) {
26
+ /**
27
+ * Level 0: Module metadata + dependency topology + ArkFile (path-only basic info).
28
+ * Index files (index.ets/index.ts) are exceptions: their ArkFile includes export/import info.
29
+ * Other files are NOT read or parsed.
30
+ */
31
+ ModuleDepthLevel[ModuleDepthLevel["META"] = 0] = "META";
32
+ /**
33
+ * Level 1: META + export/import info for ALL ArkFiles + intra-module file dependencies.
34
+ */
35
+ ModuleDepthLevel[ModuleDepthLevel["IMPORTS"] = 1] = "IMPORTS";
36
+ /**
37
+ * Level 2: IMPORTS + ArkFile content excluding method bodies
38
+ * (namespaces, classes, method signatures, parameters, return types).
39
+ */
40
+ ModuleDepthLevel[ModuleDepthLevel["SIGNATURES"] = 2] = "SIGNATURES";
41
+ /**
42
+ * Level 3: SIGNATURES + method bodies (ArkBody, CFG, Stmt/Expr).
43
+ */
44
+ ModuleDepthLevel[ModuleDepthLevel["BODIES"] = 3] = "BODIES";
45
+ })(ModuleDepthLevel = exports.ModuleDepthLevel || (exports.ModuleDepthLevel = {}));
@@ -8,6 +8,11 @@ export declare class CppFrontend {
8
8
  private static readonly AUTO_MAX_PARALLEL_PROCESSES;
9
9
  private static readonly AUTO_MAX_PENDING_AST_RESULTS;
10
10
  buildProjectFile(scene: Scene, filePath: string, arkFile: ArkFile): void;
11
+ /**
12
+ * Imports-only build for a single C++ file: parses #include directives and fills
13
+ * ImportInfo without building ArkClass/ArkMethod/ArkBody.
14
+ */
15
+ buildProjectFileForImports(arkFile: ArkFile): void;
11
16
  buildProjectFiles(scene: Scene, filePaths: string[]): FrontendParseResult;
12
17
  /** Returns true if astJsonDumper and cxx-ast-parser are available; otherwise logs a warning. */
13
18
  private requireAstJsonDumper;
@@ -1 +1 @@
1
- {"version":3,"file":"CppFrontend.d.ts","sourceRoot":"","sources":["../../../src/frontend/cppFrontend/CppFrontend.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,EAAwB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAM/E;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAM;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAM;IAEnD,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAOxE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,mBAAmB;IAYhF,gGAAgG;IAChG,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,iBAAiB;CAG5B"}
1
+ {"version":3,"file":"CppFrontend.d.ts","sourceRoot":"","sources":["../../../src/frontend/cppFrontend/CppFrontend.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD,OAAO,EAAwB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK/E;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAM;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAM;IAEnD,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAO/E;;;OAGG;IACI,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOlD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,mBAAmB;IAYhF,gGAAgG;IAChG,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,iBAAiB;CAG5B"}
@@ -41,10 +41,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  };
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.CppFrontend = void 0;
44
+ const os_1 = __importDefault(require("os"));
44
45
  const logger_1 = __importStar(require("../../utils/logger"));
45
46
  const ArkFileBuilder_1 = require("./model/builder/ArkFileBuilder");
46
47
  const cxxAstParserTypes_1 = require("./utils/cxxAstParserTypes");
47
- const os_1 = __importDefault(require("os"));
48
48
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'CppFrontend');
49
49
  /**
50
50
  * C++ language frontend. Matches the former {@link Scene} branches for {@link Language#CXX}.
@@ -56,6 +56,16 @@ class CppFrontend {
56
56
  }
57
57
  (0, ArkFileBuilder_1.prepareArkFile)(scene, filePath, arkFile, this.resolveLogAstInfo(scene));
58
58
  }
59
+ /**
60
+ * Imports-only build for a single C++ file: parses #include directives and fills
61
+ * ImportInfo without building ArkClass/ArkMethod/ArkBody.
62
+ */
63
+ buildProjectFileForImports(arkFile) {
64
+ if (!this.requireAstJsonDumper()) {
65
+ return;
66
+ }
67
+ (0, ArkFileBuilder_1.buildImportExportInfoFromFile)(arkFile);
68
+ }
59
69
  buildProjectFiles(scene, filePaths) {
60
70
  if (!this.requireAstJsonDumper()) {
61
71
  return { arkFiles: [], failedFiles: [] };
@@ -12,6 +12,14 @@ export interface CppStreamBuildResult {
12
12
  */
13
13
  export declare function prepareArkFiles(scene: Scene, absoluteSourceFiles: string[], maxParallelProcesses?: number, maxPendingAstResults?: number, logAstInfo?: boolean): CppStreamBuildResult;
14
14
  export declare function prepareArkFile(scene: Scene, absoluteFilePath: string, targetArkFile: ArkFile, logAstInfo?: boolean): void;
15
+ /**
16
+ * Imports-only variant of {@link prepareArkFile}. Parses the C++ AST for the given
17
+ * file and populates only basic file metadata and ImportInfo (#include directives
18
+ * and using-namespace declarations). Does NOT build ArkClass/ArkMethod/ArkNamespace/ArkBody.
19
+ *
20
+ * @param arkFile - Pre-allocated ArkFile to populate (must have scene and file path set).
21
+ */
22
+ export declare function buildImportExportInfoFromFile(arkFile: ArkFile): void;
15
23
  export declare const classMap: Map<string, ArkClass>;
16
24
  export declare function buildArkClassFromCxxClass(classNode: CxxAstNode, arkFile: ArkFile, astRoot: CxxAstNode): void;
17
25
  //# sourceMappingURL=ArkFileBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArkFileBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/model/builder/ArkFileBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAY,MAAM,gCAAgC,CAAC;AAMnE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAS3D,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAyBhE,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,MAAM,EAAE,EAC7B,oBAAoB,GAAE,MAAU,EAChC,oBAAoB,GAAE,MAAU,EAChC,UAAU,GAAE,OAAe,GAC5B,oBAAoB,CAkCtB;AAED,wBAAgB,cAAc,CAC1B,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,OAAO,EACtB,UAAU,GAAE,OAAe,GAC5B,IAAI,CA0BN;AAED,eAAO,MAAM,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAA+B,CAAC;AAE3E,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAU5G"}
1
+ {"version":3,"file":"ArkFileBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/frontend/cppFrontend/model/builder/ArkFileBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAY,MAAM,gCAAgC,CAAC;AAMnE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAS3D,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAwFhE,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,MAAM,EAAE,EAC7B,oBAAoB,GAAE,MAAU,EAChC,oBAAoB,GAAE,MAAU,EAChC,UAAU,GAAE,OAAe,GAC5B,oBAAoB,CAkCtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,GAAE,OAAe,GAAG,IAAI,CA0BhI;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4BpE;AAED,eAAO,MAAM,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAA+B,CAAC;AAE3E,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAU5G"}
@@ -40,7 +40,7 @@ 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.buildArkClassFromCxxClass = exports.classMap = exports.prepareArkFile = exports.prepareArkFiles = void 0;
43
+ exports.buildArkClassFromCxxClass = exports.classMap = exports.buildImportExportInfoFromFile = exports.prepareArkFile = exports.prepareArkFiles = void 0;
44
44
  const fs_1 = __importDefault(require("fs"));
45
45
  const path_1 = __importDefault(require("path"));
46
46
  const ArkFile_1 = require("../../../../core/model/ArkFile");
@@ -83,13 +83,77 @@ function applyArkFile(arkFile, sourceFile, astRoot) {
83
83
  genDefaultArkClass(arkFile, astRoot);
84
84
  buildArkFile(arkFile, astRoot);
85
85
  }
86
+ /**
87
+ * Lightweight variant of {@link applyArkFile} that only sets basic file metadata and
88
+ * fills ImportInfo from #include / using-namespace directives. It does NOT build
89
+ * ArkClass, ArkMethod, ArkNamespace, or ArkBody.
90
+ *
91
+ * @param arkFile - Target ArkFile to populate.
92
+ * @param sourceFile - Absolute path of the C++ source file.
93
+ * @param astRoot - Root AST node returned by the C++ AST parser.
94
+ */
95
+ function applyArkFileForImports(arkFile, sourceFile, astRoot) {
96
+ var _a;
97
+ const scene = arkFile.getScene();
98
+ const projectDir = scene.getRealProjectDir();
99
+ const projectName = scene.getProjectName();
100
+ arkFile.setFilePath(sourceFile);
101
+ arkFile.setProjectDir(projectDir);
102
+ arkFile.setFileSignature(new ArkSignature_1.FileSignature(projectName, path_1.default.relative(projectDir, sourceFile)));
103
+ const sourceText = fs_1.default.readFileSync(arkFile.getFilePath(), 'utf8');
104
+ const options = scene.getOptions();
105
+ const eagerLoad = (_a = options.saveSourceCodeByDefault) !== null && _a !== void 0 ? _a : false;
106
+ if (eagerLoad && scene.getProjectName() === arkFile.getProjectName()) {
107
+ arkFile.setCode(sourceText);
108
+ }
109
+ buildImportsOnly(arkFile, astRoot);
110
+ }
111
+ /**
112
+ * Imports-only subset of {@link buildArkFile}. Processes #include directives from
113
+ * header units and using-namespace directives from the top-level statement list.
114
+ * Recurses into LinkageSpecDecl nodes which may contain their own includes/usings.
115
+ *
116
+ * @param arkFile - Target ArkFile to populate with ImportInfo.
117
+ * @param astRoot - Root AST node returned by the C++ AST parser.
118
+ */
119
+ function buildImportsOnly(arkFile, astRoot) {
120
+ var _a, _b;
121
+ // handle header units - process #include directives
122
+ (_a = astRoot.headerUnits) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
123
+ var _a;
124
+ if (!child.includes) {
125
+ return;
126
+ }
127
+ for (const includeInfo of child.includes) {
128
+ if (includeInfo.kind !== ArkCxxAstNode_1.AstKind.InclusionDirective) {
129
+ logger.trace('Unprocess kind of header unit: ', (_a = includeInfo.kind) !== null && _a !== void 0 ? _a : includeInfo.includeName);
130
+ continue;
131
+ }
132
+ buildImportInfoFromInclude(includeInfo, child, astRoot, arkFile);
133
+ }
134
+ });
135
+ // handle non-header unit - only import-related declarations
136
+ const statements = (_b = astRoot.inner) !== null && _b !== void 0 ? _b : [];
137
+ statements.forEach((child) => {
138
+ switch (child.kind) {
139
+ case ArkCxxAstNode_1.AstKind.UsingDirectiveDecl:
140
+ buildImportInfoFromUsing(child, astRoot, arkFile);
141
+ break;
142
+ case ArkCxxAstNode_1.AstKind.LinkageSpecDecl:
143
+ buildImportsOnly(arkFile, child);
144
+ break;
145
+ default:
146
+ break;
147
+ }
148
+ });
149
+ }
86
150
  /**
87
151
  * C++ AST manifest pipeline: addon emits per-TU records, consumed synchronously per record.
88
152
  */
89
153
  function prepareArkFiles(scene, absoluteSourceFiles, maxParallelProcesses = 1, maxPendingAstResults = 2, logAstInfo = false) {
90
154
  const arkFiles = [];
91
155
  const failedFiles = [];
92
- const sources = absoluteSourceFiles.map((f) => path_1.default.resolve(f));
156
+ const sources = absoluteSourceFiles.map(f => path_1.default.resolve(f));
93
157
  if (sources.length === 0) {
94
158
  return { arkFiles, failedFiles };
95
159
  }
@@ -150,6 +214,45 @@ function prepareArkFile(scene, absoluteFilePath, targetArkFile, logAstInfo = fal
150
214
  }
151
215
  }
152
216
  exports.prepareArkFile = prepareArkFile;
217
+ /**
218
+ * Imports-only variant of {@link prepareArkFile}. Parses the C++ AST for the given
219
+ * file and populates only basic file metadata and ImportInfo (#include directives
220
+ * and using-namespace declarations). Does NOT build ArkClass/ArkMethod/ArkNamespace/ArkBody.
221
+ *
222
+ * @param arkFile - Pre-allocated ArkFile to populate (must have scene and file path set).
223
+ */
224
+ function buildImportExportInfoFromFile(arkFile) {
225
+ var _a, _b;
226
+ const scene = arkFile.getScene();
227
+ const sourceFile = path_1.default.resolve(arkFile.getFilePath());
228
+ const projectDir = scene.getRealProjectDir();
229
+ const includeDirs = scene.getIncludeDirs();
230
+ const logAstInfo = ((_b = (_a = scene.getOptions().languages) === null || _a === void 0 ? void 0 : _a.cpp) === null || _b === void 0 ? void 0 : _b.logAstInfo) === true;
231
+ const result = getAstParser().runCppAst({
232
+ scene,
233
+ sources: [sourceFile],
234
+ projectDir,
235
+ includeDirs,
236
+ maxParallelProcesses: 1,
237
+ maxPendingAstResults: 2,
238
+ logAstInfo,
239
+ onSourceAst: (source, astRoot) => {
240
+ try {
241
+ applyArkFileForImports(arkFile, source, astRoot);
242
+ }
243
+ catch (err) {
244
+ logger.warn(`Failed to apply C++ AST (imports-only) to ArkFile: ${source}`, err);
245
+ }
246
+ },
247
+ });
248
+ for (const e of result.dumpErrors) {
249
+ logger.warn(`C++ AST dump error for ${e.filePath}`, e.reason);
250
+ }
251
+ if (result.exitCode !== 0) {
252
+ logger.warn(`C++ single-file AST parse not completed successfully: ${sourceFile}`);
253
+ }
254
+ }
255
+ exports.buildImportExportInfoFromFile = buildImportExportInfoFromFile;
153
256
  exports.classMap = new Map();
154
257
  function buildArkClassFromCxxClass(classNode, arkFile, astRoot) {
155
258
  let cls = new ArkClass_1.ArkClass();
package/lib/index.d.ts CHANGED
@@ -42,8 +42,15 @@ export { ViewTree, ViewTreeNode } from './core/graph/ViewTree';
42
42
  export { DominanceFinder } from './core/graph/DominanceFinder';
43
43
  export { DominanceTree } from './core/graph/DominanceTree';
44
44
  export { NodeID, Kind, BaseEdge, BaseNode, BaseExplicitGraph } from './core/graph/BaseExplicitGraph';
45
+ export { BaseImplicitGraph } from './core/graph/BaseImplicitGraph';
45
46
  export { SCCDetection } from './core/graph/Scc';
47
+ export { ModuleDepGraph, DependencyType } from './core/graph/ModuleDepGraph';
48
+ export { FileDepGraph } from './core/graph/FileDepGraph';
46
49
  export { ArkFile } from './core/model/ArkFile';
50
+ export { ArkModule, ModuleLoadState, ModuleType, ModuleID } from './core/model/ArkModule';
51
+ export { ModuleDepthLevel } from './frontend/common/ModuleDepth';
52
+ export { ModuleAnalysisConfig, ModuleAnalysisCallback } from './frontend/common/ModuleAnalysisConfig';
53
+ export { ModuleBuilder } from './frontend/common/ModuleBuilder';
47
54
  export { ArkNamespace } from './core/model/ArkNamespace';
48
55
  export { ArkClass } from './core/model/ArkClass';
49
56
  export { ArkMethod } from './core/model/ArkMethod';
@@ -53,7 +60,7 @@ export { ImportInfo } from './core/model/ArkImport';
53
60
  export { ArkBody } from './core/model/ArkBody';
54
61
  export * from './core/model/ArkSignature';
55
62
  export * from './core/model/builder/ArkSignatureBuilder';
56
- export { SceneConfig, SceneOptions, buildSceneConfigFromProject, LanguageOptions, SceneLanguagesOptions, } from './Config';
63
+ export { SceneConfig, SceneOptions, buildSceneConfigFromProject, LanguageOptions, SceneLanguagesOptions } from './Config';
57
64
  export { Scene } from './Scene';
58
65
  export { FrontendBuilder, FrontendParseFailure, FrontendParseResult } from './frontend/FrontendBuilder';
59
66
  export { ArktsFrontend } from './frontend/arktsFrontend/ArktsFrontend';
@@ -82,6 +89,7 @@ export { default as Logger } from './utils/logger';
82
89
  export { IntMap } from './utils/IntMap';
83
90
  export { IntWorkList } from './utils/IntWorkList';
84
91
  export { PackedSparseMap } from './utils/PackedSparseMap';
92
+ export { Canonicalizer } from './utils/Canonicalizer';
85
93
  import ts from 'ohos-typescript';
86
94
  export { ts };
87
95
  //# sourceMappingURL=index.d.ts.map