arkanalyzer 1.0.13 → 1.0.15

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 (107) hide show
  1. package/README.md +10 -10
  2. package/config/arkanalyzer.json +5 -0
  3. package/lib/Config.d.ts +2 -0
  4. package/lib/Config.d.ts.map +1 -1
  5. package/lib/core/base/Expr.d.ts +3 -0
  6. package/lib/core/base/Expr.d.ts.map +1 -1
  7. package/lib/core/base/Expr.js +22 -5
  8. package/lib/core/base/Ref.d.ts +1 -0
  9. package/lib/core/base/Ref.d.ts.map +1 -1
  10. package/lib/core/base/Ref.js +5 -2
  11. package/lib/core/base/Stmt.js +1 -1
  12. package/lib/core/base/Type.d.ts +25 -1
  13. package/lib/core/base/Type.d.ts.map +1 -1
  14. package/lib/core/base/Type.js +39 -2
  15. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  16. package/lib/core/common/ArkIRTransformer.js +33 -2
  17. package/lib/core/common/ArkValueTransformer.js +2 -2
  18. package/lib/core/common/CfgBuilder.d.ts.map +1 -1
  19. package/lib/core/common/CfgBuilder.js +3 -2
  20. package/lib/core/common/Const.d.ts +1 -0
  21. package/lib/core/common/Const.d.ts.map +1 -1
  22. package/lib/core/common/Const.js +3 -2
  23. package/lib/core/common/DummyMainCreater.d.ts +0 -6
  24. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  25. package/lib/core/common/DummyMainCreater.js +12 -160
  26. package/lib/core/common/EtsConst.d.ts +0 -3
  27. package/lib/core/common/EtsConst.d.ts.map +1 -1
  28. package/lib/core/common/EtsConst.js +1 -8
  29. package/lib/core/common/IRInference.d.ts.map +1 -1
  30. package/lib/core/common/IRInference.js +8 -2
  31. package/lib/core/common/IRUtils.d.ts +3 -2
  32. package/lib/core/common/IRUtils.d.ts.map +1 -1
  33. package/lib/core/common/IRUtils.js +27 -13
  34. package/lib/core/common/ModelUtils.d.ts +1 -0
  35. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  36. package/lib/core/common/ModelUtils.js +14 -23
  37. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  38. package/lib/core/common/SdkUtils.js +12 -5
  39. package/lib/core/common/TypeInference.d.ts.map +1 -1
  40. package/lib/core/common/TypeInference.js +21 -8
  41. package/lib/core/dataflow/DataflowProblem.d.ts +0 -1
  42. package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
  43. package/lib/core/dataflow/DataflowProblem.js +0 -13
  44. package/lib/core/dataflow/Edge.d.ts +0 -4
  45. package/lib/core/dataflow/Edge.d.ts.map +1 -1
  46. package/lib/core/dataflow/Edge.js +1 -10
  47. package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
  48. package/lib/core/dataflow/UndefinedVariable.js +28 -21
  49. package/lib/core/dataflow/Util.d.ts +0 -2
  50. package/lib/core/dataflow/Util.d.ts.map +1 -1
  51. package/lib/core/dataflow/Util.js +1 -95
  52. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  53. package/lib/core/graph/builder/ViewTreeBuilder.js +2 -2
  54. package/lib/core/model/ArkClass.d.ts +5 -0
  55. package/lib/core/model/ArkClass.d.ts.map +1 -1
  56. package/lib/core/model/ArkClass.js +10 -2
  57. package/lib/core/model/ArkExport.d.ts +3 -1
  58. package/lib/core/model/ArkExport.d.ts.map +1 -1
  59. package/lib/core/model/ArkExport.js +9 -3
  60. package/lib/core/model/ArkFile.d.ts +4 -4
  61. package/lib/core/model/ArkFile.d.ts.map +1 -1
  62. package/lib/core/model/ArkFile.js +7 -6
  63. package/lib/core/model/ArkMetadata.d.ts +14 -2
  64. package/lib/core/model/ArkMetadata.d.ts.map +1 -1
  65. package/lib/core/model/ArkMetadata.js +12 -1
  66. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  67. package/lib/core/model/ArkNamespace.js +4 -2
  68. package/lib/core/model/ArkSignature.d.ts +10 -0
  69. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  70. package/lib/core/model/ArkSignature.js +13 -1
  71. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  72. package/lib/core/model/builder/ArkClassBuilder.js +44 -10
  73. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  74. package/lib/core/model/builder/ArkExportBuilder.js +6 -3
  75. package/lib/core/model/builder/ArkFieldBuilder.js +2 -2
  76. package/lib/core/model/builder/ArkImportBuilder.js +6 -6
  77. package/lib/core/model/builder/ArkMethodBuilder.js +3 -3
  78. package/lib/core/model/builder/ArkNamespaceBuilder.js +1 -1
  79. package/lib/core/model/builder/builderUtils.d.ts +2 -2
  80. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  81. package/lib/core/model/builder/builderUtils.js +19 -5
  82. package/lib/index.d.ts +4 -2
  83. package/lib/index.d.ts.map +1 -1
  84. package/lib/index.js +9 -6
  85. package/lib/save/source/SourceClass.d.ts.map +1 -1
  86. package/lib/save/source/SourceClass.js +7 -3
  87. package/lib/save/source/SourceField.d.ts.map +1 -1
  88. package/lib/save/source/SourceField.js +7 -3
  89. package/lib/save/source/SourceMethod.d.ts.map +1 -1
  90. package/lib/save/source/SourceMethod.js +7 -3
  91. package/lib/save/source/SourceModule.d.ts.map +1 -1
  92. package/lib/save/source/SourceModule.js +14 -6
  93. package/lib/save/source/SourceNamespace.d.ts.map +1 -1
  94. package/lib/save/source/SourceNamespace.js +8 -6
  95. package/lib/save/source/SourceStmt.d.ts +1 -0
  96. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  97. package/lib/save/source/SourceStmt.js +39 -11
  98. package/lib/utils/AstTreeUtils.d.ts +5 -0
  99. package/lib/utils/AstTreeUtils.d.ts.map +1 -0
  100. package/lib/utils/AstTreeUtils.js +26 -0
  101. package/lib/utils/entryMethodUtils.d.ts +0 -2
  102. package/lib/utils/entryMethodUtils.d.ts.map +1 -1
  103. package/lib/utils/entryMethodUtils.js +1 -31
  104. package/package.json +3 -3
  105. package/lib/core/dataflow/TiantAnalysis.d.ts +0 -38
  106. package/lib/core/dataflow/TiantAnalysis.d.ts.map +0 -1
  107. package/lib/core/dataflow/TiantAnalysis.js +0 -340
@@ -13,36 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
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
16
  Object.defineProperty(exports, "__esModule", { value: true });
43
17
  exports.DummyMainCreater = void 0;
44
- const fs_1 = __importDefault(require("fs"));
45
- const path_1 = __importDefault(require("path"));
46
18
  const entryMethodUtils_1 = require("../../utils/entryMethodUtils");
47
19
  const Constant_1 = require("../base/Constant");
48
20
  const Expr_1 = require("../base/Expr");
@@ -55,15 +27,11 @@ const ArkBody_1 = require("../model/ArkBody");
55
27
  const ArkClass_1 = require("../model/ArkClass");
56
28
  const ArkFile_1 = require("../model/ArkFile");
57
29
  const ArkMethod_1 = require("../model/ArkMethod");
58
- const ArkNamespace_1 = require("../model/ArkNamespace");
59
30
  const ArkSignature_1 = require("../model/ArkSignature");
60
31
  const ArkSignatureBuilder_1 = require("../model/builder/ArkSignatureBuilder");
61
32
  const TSConst_1 = require("./TSConst");
62
- const json5parser_1 = require("../../utils/json5parser");
63
- const logger_1 = __importStar(require("../../utils/logger"));
64
33
  const ArkMethodBuilder_1 = require("../model/builder/ArkMethodBuilder");
65
34
  const ValueUtil_1 = require("./ValueUtil");
66
- const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'Scene');
67
35
  /**
68
36
  收集所有的onCreate,onStart等函数,构造一个虚拟函数,具体为:
69
37
  %statInit()
@@ -93,22 +61,12 @@ class DummyMainCreater {
93
61
  this.classLocalMap = new Map();
94
62
  this.dummyMain = new ArkMethod_1.ArkMethod();
95
63
  this.tempLocalIndex = 0;
96
- this.builtInClass = new Map;
97
64
  this.scene = scene;
98
65
  // Currently get entries from module.json5 can't visit all of abilities
99
66
  // Todo: handle ablity/component jump, then get entries from module.json5
100
67
  this.entryMethods = this.getMethodsFromAllAbilities();
101
68
  this.entryMethods.push(...this.getEntryMethodsFromComponents());
102
69
  this.entryMethods.push(...this.getCallbackMethods());
103
- this.buildBuiltInClass();
104
- }
105
- buildBuiltInClass() {
106
- for (const sdkFile of this.scene.getSdkArkFiles()) {
107
- if (sdkFile.getName() === 'api\\@ohos.app.ability.Want.d.ts') {
108
- const arkClass = sdkFile.getClassWithName('Want');
109
- this.builtInClass.set('Want', arkClass);
110
- }
111
- }
112
70
  }
113
71
  setEntryMethods(methods) {
114
72
  this.entryMethods = methods;
@@ -133,9 +91,10 @@ class DummyMainCreater {
133
91
  this.dummyMain.setLineCol(0);
134
92
  (0, ArkMethodBuilder_1.checkAndUpdateMethod)(this.dummyMain, dummyMainClass);
135
93
  dummyMainClass.addMethod(this.dummyMain);
94
+ let defaultMethods = [];
136
95
  for (const method of this.entryMethods) {
137
96
  if (method.getDeclaringArkClass().isDefaultArkClass()) {
138
- this.classLocalMap.set(method, null);
97
+ defaultMethods.push(method);
139
98
  }
140
99
  else {
141
100
  const declaringArkClass = method.getDeclaringArkClass();
@@ -153,6 +112,9 @@ class DummyMainCreater {
153
112
  this.classLocalMap.set(method, newLocal);
154
113
  }
155
114
  }
115
+ for (const defaultMethod of defaultMethods) {
116
+ this.classLocalMap.set(defaultMethod, null);
117
+ }
156
118
  const localSet = new Set(Array.from(this.classLocalMap.values()).filter((value) => value !== null));
157
119
  const dummyBody = new ArkBody_1.ArkBody(localSet, this.createDummyMainCfg());
158
120
  this.dummyMain.setBody(dummyBody);
@@ -181,9 +143,6 @@ class DummyMainCreater {
181
143
  }
182
144
  let clsType = local.getType();
183
145
  let cls = this.scene.getClass(clsType.getClassSignature());
184
- if (!cls) {
185
- continue;
186
- }
187
146
  const assStmt = new Stmt_1.ArkAssignStmt(local, new Expr_1.ArkNewExpr(clsType));
188
147
  firstBlock.addStmt(assStmt);
189
148
  let consMtd = cls.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
@@ -209,7 +168,7 @@ class DummyMainCreater {
209
168
  whileBlock.addPredecessorBlock(firstBlock);
210
169
  let lastBlocks = [whileBlock];
211
170
  let count = 0;
212
- for (const method of this.entryMethods) {
171
+ for (let method of this.entryMethods) {
213
172
  count++;
214
173
  const condition = new Expr_1.ArkConditionExpr(countLocal, new Constant_1.Constant(count.toString(), Type_1.NumberType.getInstance()), Expr_1.RelationalBinaryOperator.Equality);
215
174
  const ifStmt = new Stmt_1.ArkIfStmt(condition);
@@ -225,7 +184,6 @@ class DummyMainCreater {
225
184
  let paramIdx = 0;
226
185
  for (const param of method.getParameters()) {
227
186
  let paramType = param.getType();
228
- let checkMethod = method;
229
187
  // In ArkIR from abc scenario, param type is undefined in some cases
230
188
  // Then try to get it from super class(SDK)
231
189
  // TODO - need handle method overload to get the correct method
@@ -234,7 +192,7 @@ class DummyMainCreater {
234
192
  let methodInSuperCls = superCls === null || superCls === void 0 ? void 0 : superCls.getMethodWithName(method.getName());
235
193
  if (methodInSuperCls) {
236
194
  paramType = (_a = methodInSuperCls.getParameters().at(paramIdx)) === null || _a === void 0 ? void 0 : _a.getType();
237
- checkMethod = methodInSuperCls;
195
+ method = methodInSuperCls;
238
196
  }
239
197
  }
240
198
  const paramLocal = new Local_1.Local('temp' + this.tempLocalIndex++, paramType);
@@ -243,25 +201,10 @@ class DummyMainCreater {
243
201
  const assStmt = new Stmt_1.ArkAssignStmt(paramLocal, new Expr_1.ArkNewExpr(paramType));
244
202
  invokeBlock.addStmt(assStmt);
245
203
  }
246
- else if (paramType instanceof Type_1.UnclearReferenceType) {
247
- const arkClass = this.getArkClassFromParamType(paramType.getName(), checkMethod.getDeclaringArkFile());
248
- if (arkClass) {
249
- const classType = new Type_1.ClassType(arkClass.getSignature());
250
- paramLocal.setType(classType);
251
- const assStmt = new Stmt_1.ArkAssignStmt(paramLocal, new Expr_1.ArkNewExpr(classType));
252
- invokeBlock.addStmt(assStmt);
253
- }
254
- }
255
204
  paramIdx++;
256
205
  }
257
206
  const local = this.classLocalMap.get(method);
258
- let invokeExpr;
259
- if (local) {
260
- invokeExpr = new Expr_1.ArkInstanceInvokeExpr(local, method.getSignature(), paramLocals);
261
- }
262
- else {
263
- invokeExpr = new Expr_1.ArkStaticInvokeExpr(method.getSignature(), paramLocals);
264
- }
207
+ let invokeExpr = new Expr_1.ArkInstanceInvokeExpr(local, method.getSignature(), paramLocals);
265
208
  const invokeStmt = new Stmt_1.ArkInvokeStmt(invokeExpr);
266
209
  invokeBlock.addStmt(invokeStmt);
267
210
  dummyCfg.addBlock(invokeBlock);
@@ -281,29 +224,6 @@ class DummyMainCreater {
281
224
  returnBlock.addPredecessorBlock(whileBlock);
282
225
  return dummyCfg;
283
226
  }
284
- getArkClassFromParamType(name, file) {
285
- var _a, _b;
286
- if (name.includes('.')) {
287
- const nsName = name.split('.')[0];
288
- const clsName = name.split('.')[1];
289
- const importInfo = file.getImportInfoBy(nsName);
290
- const arkExport = (_a = importInfo === null || importInfo === void 0 ? void 0 : importInfo.getLazyExportInfo()) === null || _a === void 0 ? void 0 : _a.getArkExport();
291
- if (arkExport instanceof ArkNamespace_1.ArkNamespace) {
292
- const arkClass = arkExport.getClassWithName(clsName);
293
- if (arkClass) {
294
- return arkClass;
295
- }
296
- }
297
- }
298
- else {
299
- const importInfo = file.getImportInfoBy(name);
300
- const arkExport = (_b = importInfo === null || importInfo === void 0 ? void 0 : importInfo.getLazyExportInfo()) === null || _b === void 0 ? void 0 : _b.getArkExport();
301
- if (arkExport instanceof ArkClass_1.ArkClass) {
302
- return arkExport;
303
- }
304
- }
305
- return null;
306
- }
307
227
  addCfg2Stmt() {
308
228
  const cfg = this.dummyMain.getCfg();
309
229
  if (!cfg) {
@@ -338,9 +258,12 @@ class DummyMainCreater {
338
258
  }
339
259
  classInheritsAbility(arkClass) {
340
260
  const ABILITY_BASE_CLASSES = ['UIExtensionAbility', 'Ability', 'FormExtensionAbility', 'UIAbility', 'BackupExtensionAbility'];
261
+ if (ABILITY_BASE_CLASSES.includes(arkClass.getSuperClassName())) {
262
+ return true;
263
+ }
341
264
  let superClass = arkClass.getSuperClass();
342
265
  while (superClass) {
343
- if (ABILITY_BASE_CLASSES.includes(superClass.getName())) {
266
+ if (ABILITY_BASE_CLASSES.includes(superClass.getSuperClassName())) {
344
267
  return true;
345
268
  }
346
269
  superClass = superClass.getSuperClass();
@@ -356,77 +279,6 @@ class DummyMainCreater {
356
279
  });
357
280
  return methods;
358
281
  }
359
- getEntryMethodsFromModuleJson5() {
360
- const projectDir = this.scene.getRealProjectDir();
361
- const buildProfile = path_1.default.join(projectDir, 'build-profile.json5');
362
- if (!fs_1.default.existsSync(buildProfile)) {
363
- logger.error(`${buildProfile} is not exists.`);
364
- return [];
365
- }
366
- const abilities = [];
367
- const buildProfileConfig = (0, json5parser_1.fetchDependenciesFromFile)(buildProfile);
368
- let modules;
369
- if (buildProfileConfig instanceof Object) {
370
- Object.entries(buildProfileConfig).forEach(([k, v]) => {
371
- if (k === 'modules' && Array.isArray(v)) {
372
- modules = v;
373
- return;
374
- }
375
- });
376
- }
377
- if (Array.isArray(modules)) {
378
- for (const module of modules) {
379
- const modulePath = path_1.default.join(projectDir, module.srcPath);
380
- let moduleAbilities = this.getAbilitiesByParseModuleJson(modulePath);
381
- abilities.push(...moduleAbilities);
382
- }
383
- }
384
- const entryMethods = [];
385
- for (const ability of abilities) {
386
- const abilityEntryMethods = [];
387
- let cls = ability;
388
- for (const method of cls.getMethods()) {
389
- if (method.isPrivate()) {
390
- continue;
391
- }
392
- for (const mtd of abilityEntryMethods) {
393
- if (mtd.getName() === method.getName()) {
394
- continue;
395
- }
396
- }
397
- if (entryMethodUtils_1.LIFECYCLE_METHOD_NAME.includes(method.getName()) && !entryMethods.includes(method)) {
398
- abilityEntryMethods.push(method);
399
- }
400
- }
401
- entryMethods.push(...abilityEntryMethods);
402
- }
403
- return entryMethods;
404
- }
405
- getAbilitiesByParseModuleJson(modulePath) {
406
- const jsonPath = path_1.default.join(modulePath, '/src/main/module.json5');
407
- let abilities = [];
408
- const ABILITY_NAMES = ['abilities', 'extensionAbilities'];
409
- try {
410
- const config = (0, json5parser_1.fetchDependenciesFromFile)(jsonPath);
411
- const configModule = config.module;
412
- if (configModule instanceof Object) {
413
- Object.entries(configModule).forEach(([k, v]) => {
414
- if (ABILITY_NAMES.includes(k)) {
415
- const moduleAbilities = (0, entryMethodUtils_1.getAbilities)(v, modulePath, this.scene);
416
- for (const ability of moduleAbilities) {
417
- if (!abilities.includes(ability)) {
418
- abilities.push(ability);
419
- }
420
- }
421
- }
422
- });
423
- }
424
- }
425
- catch (err) {
426
- logger.error(err);
427
- }
428
- return abilities;
429
- }
430
282
  getCallbackMethods() {
431
283
  const callbackMethods = [];
432
284
  this.scene.getMethods().forEach(method => {
@@ -64,11 +64,8 @@ export declare const COMPONENT_IF_BRANCH: string;
64
64
  export declare const COMPONENT_BRANCH_FUNCTION: string;
65
65
  export declare const COMPONENT_BUILD_FUNCTION: string;
66
66
  export declare const SPECIAL_CONTAINER_COMPONENT: Set<string>;
67
- export declare const COMPONENT_PATH: string;
68
67
  export declare const COMPONENT_COMMON: string;
69
68
  export declare const COMPONENT_INSTANCE: string;
70
- export declare const API_INTERNAL: string;
71
- export declare const API_COMMON: string;
72
69
  export declare const COMPONENT_ATTRIBUTE: string;
73
70
  export declare const CALL_BACK: string;
74
71
  export declare const ON_OFF: Set<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAy4BhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAC;AACpD,eAAO,MAAM,uBAAuB,EAAE,MAAsB,CAAC;AAE7D,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAI/C,CAAC;AAEH,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAqD/C,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAqE,CAAC;AAClH,eAAO,MAAM,eAAe,EAAE,MAAgB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,EAAE,MAAkB,CAAC;AACnD,eAAO,MAAM,uBAAuB,EAAE,MAAuB,CAAC;AAE9D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,EAAE,MAAc,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAe,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AAEjD,eAAO,M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AkB,CAAC;AACnD,eAAO,MAAM,uBAAuB,EAAE,MAAuB,CAAC;AAE9D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,EAAE,MAAc,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAe,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,EAAE,MAAa,CAAC;AACzC,eAAO,MAAM,mBAAmB,EAAE,MAAmB,CAAC;AACtD,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,EAAE,MAAgB,CAAC;AAExD,eAAO,MAAM,2BAA2B,EAAE,GAAG,CAAC,MAAM,CAKlD,CAAC;AAGH,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AACjD,eAAO,MAAM,kBAAkB,EAAE,MAAmB,CAAC;AAErD,eAAO,MAAM,mBAAmB,EAAE,MAAoB,CAAC;AACvD,eAAO,MAAM,SAAS,EAAE,MAAmB,CAAC;AAC5C,eAAO,MAAM,MAAM,EAAE,GAAG,CAAC,MAAM,CAA0B,CAAC;AAE1D,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,mBAAmB,wBAAwB,CAAC"}
@@ -13,12 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.API_COMMON = exports.API_INTERNAL = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.COMPONENT_PATH = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
21
- const path_1 = __importDefault(require("path"));
17
+ exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
22
18
  exports.ETS_COMPILER_OPTIONS = {
23
19
  ets: {
24
20
  emitDecorators: [
@@ -1016,11 +1012,8 @@ exports.SPECIAL_CONTAINER_COMPONENT = new Set([
1016
1012
  exports.COMPONENT_CUSTOMVIEW,
1017
1013
  exports.COMPONENT_REPEAT,
1018
1014
  ]);
1019
- exports.COMPONENT_PATH = path_1.default.sep + 'component' + path_1.default.sep;
1020
1015
  exports.COMPONENT_COMMON = 'Common';
1021
1016
  exports.COMPONENT_INSTANCE = 'Instance';
1022
- exports.API_INTERNAL = path_1.default.sep + '@internal' + path_1.default.sep;
1023
- exports.API_COMMON = path_1.default.sep + 'common' + path_1.default.sep;
1024
1017
  exports.COMPONENT_ATTRIBUTE = 'Attribute';
1025
1018
  exports.CALL_BACK = 'Callback';
1026
1019
  exports.ON_OFF = new Set(['on', 'off']);
@@ -1 +1 @@
1
- {"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAKH,SAAS,EAIT,IAAI,EAIP,MAAM,cAAc,CAAC;AAGtB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAGH,cAAc,EAEd,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAEH,WAAW,EAEX,mBAAmB,EAGtB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,qBAAa,WAAW;IAEpB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAY/B,OAAO,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AG,IAAI;WAehF,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI;IAgBxF,OAAO,CAAC,MAAM,CAAC,eAAe;IA0C9B,OAAO,CAAC,MAAM,CAAC,gCAAgC;IAgD/C,OAAO,CAAC,MAAM,CAAC,YAAY;WAYb,sBAAsB,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe;IAcvG,OAAO,CAAC,MAAM,CAAC,cAAc;IAmB7B,OAAO,CAAC,MAAM,CAAC,UAAU;IAsBzB,OAAO,CAAC,MAAM,CAAC,yBAAyB;WA4C1B,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI;IA+B/H,OAAO,CAAC,MAAM,CAAC,eAAe;WA+BhB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY;CAuB5F"}
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.IRInference = void 0;
27
27
  /*
28
- * Copyright (c) 2024 Huawei Device Co., Ltd.
28
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
29
29
  * Licensed under the Apache License, Version 2.0 (the "License");
30
30
  * you may not use this file except in compliance with the License.
31
31
  * You may obtain a copy of the License at
@@ -423,7 +423,10 @@ class IRInference {
423
423
  static inferLocal(base, arkMethod) {
424
424
  var _a, _b, _c;
425
425
  const arkClass = arkMethod.getDeclaringArkClass();
426
- if (base.getName() === TSConst_1.THIS_NAME && arkClass.isAnonymousClass()) {
426
+ if (base.getName() === TSConst_1.THIS_NAME) {
427
+ if (!arkClass.isAnonymousClass()) {
428
+ base.setType(new Type_1.ClassType(arkClass.getSignature(), arkClass.getGenericsTypes()));
429
+ }
427
430
  return;
428
431
  }
429
432
  let baseType = base.getType();
@@ -561,6 +564,9 @@ class IRInference {
561
564
  else if (type) {
562
565
  model = type;
563
566
  }
567
+ if (expr.getRealGenericTypes() !== undefined && originalObject instanceof Type_1.UnclearReferenceType) {
568
+ expr.setRealGenericTypes(originalObject.getGenericTypes());
569
+ }
564
570
  }
565
571
  if (Expr_1.AliasTypeExpr.isAliasTypeOriginalModel(model)) {
566
572
  expr.setOriginalObject(model);
@@ -2,14 +2,15 @@ import { Value } from '../base/Value';
2
2
  import { Scene } from '../../Scene';
3
3
  import ts from 'ohos-typescript';
4
4
  import { SceneOptions } from '../../Config';
5
+ import { CommentsMetadata } from '../model/ArkMetadata';
5
6
  import { Stmt } from '../base/Stmt';
6
7
  import { ArkBaseModel } from '../model/ArkBaseModel';
7
8
  import { FullPosition } from '../base/Position';
8
9
  export declare class IRUtils {
9
10
  static moreThanOneAddress(value: Value): boolean;
10
11
  static generateTextForStmt(scene: Scene): void;
11
- static setLeadingComments(metadata: Stmt | ArkBaseModel, node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions): void;
12
- static getLeadingComments(node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions): string[];
12
+ static setComments(metadata: Stmt | ArkBaseModel, node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions): void;
13
+ static getCommentsMetadata(node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions, isLeading: boolean): CommentsMetadata;
13
14
  static isTempLocal(value: Value): boolean;
14
15
  static findOperandIdx(stmt: Stmt, operand: Value): number;
15
16
  static adjustOperandOriginalPositions(stmt: Stmt, oldValue: Value, newValue: Value): void;
@@ -1 +1 @@
1
- {"version":3,"file":"IRUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRUtils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO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,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,qBAAa,OAAO;WACF,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;WAczC,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;WAWvC,WAAW,CAAC,QAAQ,EAAE,IAAI,GAAG,YAAY,EAC7B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,YAAY,GAAG,IAAI;WAYxC,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,EAC/D,SAAS,EAAE,OAAO,GAAG,gBAAgB;WA0BzD,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;WAIlC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM;WAYlD,8BAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI;WA0ClF,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE;CAOxE"}
@@ -22,9 +22,9 @@ const Expr_1 = require("../base/Expr");
22
22
  const Ref_1 = require("../base/Ref");
23
23
  const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
24
24
  const ArkMetadata_1 = require("../model/ArkMetadata");
25
+ const Position_1 = require("../base/Position");
25
26
  const Local_1 = require("../base/Local");
26
27
  const Const_1 = require("./Const");
27
- const Position_1 = require("../base/Position");
28
28
  class IRUtils {
29
29
  static moreThanOneAddress(value) {
30
30
  if (value instanceof Expr_1.AbstractBinopExpr ||
@@ -47,23 +47,37 @@ class IRUtils {
47
47
  }
48
48
  }
49
49
  }
50
- static setLeadingComments(metadata, node, sourceFile, options) {
51
- let comments = this.getLeadingComments(node, sourceFile, options);
52
- if (comments.length > 0) {
53
- metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS, comments);
50
+ static setComments(metadata, node, sourceFile, options) {
51
+ const leadingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, true);
52
+ if (leadingCommentsMetadata.getComments().length > 0) {
53
+ metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS, leadingCommentsMetadata);
54
+ }
55
+ const trailingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, false);
56
+ if (trailingCommentsMetadata.getComments().length > 0) {
57
+ metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.TRAILING_COMMENTS, trailingCommentsMetadata);
54
58
  }
55
59
  }
56
- static getLeadingComments(node, sourceFile, options) {
57
- let comments = [];
58
- if (!options.enableLeadingComments) {
59
- return comments;
60
+ static getCommentsMetadata(node, sourceFile, options, isLeading) {
61
+ const comments = [];
62
+ if ((isLeading && !options.enableLeadingComments) || (!isLeading && !options.enableTrailingComments)) {
63
+ return new ArkMetadata_1.CommentsMetadata(comments);
60
64
  }
61
- const commentRanges = ohos_typescript_1.default.getLeadingCommentRanges(node.getFullText(sourceFile), 0) || [];
65
+ const commentRanges = (isLeading ? ohos_typescript_1.default.getLeadingCommentRanges(sourceFile.text, node.pos)
66
+ : ohos_typescript_1.default.getTrailingCommentRanges(sourceFile.text, node.end)) || []; // node.pos is the start position of
67
+ // leading comment, while node.end is the
68
+ // end position of the statement
69
+ const getPosition = (pos, end) => {
70
+ const start = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, pos);
71
+ const endPos = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, end);
72
+ return new Position_1.FullPosition(start.line + 1, start.character + 1, endPos.line + 1, endPos.character + 1);
73
+ };
62
74
  for (const range of commentRanges) {
63
- const comment = node.getFullText(sourceFile).slice(range.pos, range.end).replace(/\r\n/g, '\n');
64
- comments.push(comment);
75
+ comments.push({
76
+ content: sourceFile.text.substring(range.pos, range.end).replace(/\r\n/g, '\n'),
77
+ position: getPosition(range.pos, range.end),
78
+ });
65
79
  }
66
- return comments;
80
+ return new ArkMetadata_1.CommentsMetadata(comments);
67
81
  }
68
82
  static isTempLocal(value) {
69
83
  return value instanceof Local_1.Local && value.getName().startsWith(Const_1.NAME_PREFIX);
@@ -47,6 +47,7 @@ export declare class ModelUtils {
47
47
  static findArkModelByRefName(refName: string, arkClass: ArkClass): ArkExport | ArkField | null;
48
48
  static findArkModelBySignature(signature: Signature, scene: Scene): ArkExport | ArkField | null;
49
49
  }
50
+ export declare const sdkImportMap: Map<string, ArkFile>;
50
51
  /**
51
52
  * find arkFile by from info
52
53
  * export xx from '../xx'
@@ -1 +1 @@
1
- {"version":3,"file":"ModelUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/ModelUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACH,cAAc,EAKd,eAAe,EAEf,SAAS,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,OAAO,EAA2B,SAAS,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIpC,qBAAa,UAAU;IACnB,OAAc,2BAA2B,EAA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WAmBlF,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAE,MAAU,GAAG,KAAK,GAAG,IAAI;WAqCtF,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI;WAmB/E,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI;WA4BvF,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI;CAsBzG;AAMD,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAA8B,CAAC;AAE7E;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CA6BnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CA4BpE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CA4BlF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAiB7F;AAiED,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GAAG,IAAI,CAK9F"}
@@ -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.initModulePathMap = exports.findArkExportInFile = exports.findArkExport = exports.findExportInfo = exports.getArkFile = exports.ModelUtils = void 0;
43
+ exports.initModulePathMap = exports.findArkExportInFile = exports.findArkExport = exports.findExportInfo = exports.getArkFile = exports.sdkImportMap = exports.ModelUtils = void 0;
44
44
  const Local_1 = require("../base/Local");
45
45
  const ArkClass_1 = require("../model/ArkClass");
46
46
  const ArkMethod_1 = require("../model/ArkMethod");
@@ -457,6 +457,7 @@ ModelUtils.implicitArkUIBuilderMethods = new Set();
457
457
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
458
458
  let moduleMap;
459
459
  const fileSuffixArray = ['.ets', '.ts', '.d.ets', '.d.ts'];
460
+ exports.sdkImportMap = new Map();
460
461
  /**
461
462
  * find arkFile by from info
462
463
  * export xx from '../xx'
@@ -482,6 +483,10 @@ function getArkFile(im) {
482
483
  }
483
484
  }
484
485
  //sdk path
486
+ const file = exports.sdkImportMap.get(from);
487
+ if (file) {
488
+ return file;
489
+ }
485
490
  const scene = im.getDeclaringArkFile().getScene();
486
491
  for (const sdk of scene.getProjectSdkMap().values()) {
487
492
  const arkFile = getArkFileFormMap(sdk.name, processSdkPath(sdk, from), scene);
@@ -576,24 +581,11 @@ function findArkExportInFile(name, declaringArkFile) {
576
581
  }
577
582
  exports.findArkExportInFile = findArkExportInFile;
578
583
  function processSdkPath(sdk, formPath) {
579
- let dir;
580
- if (formPath.startsWith('@ohos.') || formPath.startsWith('@hms.') || formPath.startsWith('@system.')) {
581
- dir = 'api';
582
- }
583
- else if (formPath.startsWith('@kit.')) {
584
- dir = 'kits';
585
- }
586
- else if (formPath.startsWith('@arkts.')) {
587
- dir = 'arkts';
588
- }
589
- else {
590
- let originPath = path_1.default.join(sdk.path, formPath);
591
- if (FileUtils_1.FileUtils.isDirectory(originPath)) {
592
- formPath = path_1.default.join(formPath, FileUtils_1.FileUtils.getIndexFileName(originPath));
593
- }
594
- return `${formPath}`;
584
+ let originPath = path_1.default.join(sdk.path, formPath);
585
+ if (FileUtils_1.FileUtils.isDirectory(originPath)) {
586
+ formPath = path_1.default.join(formPath, FileUtils_1.FileUtils.getIndexFileName(originPath));
595
587
  }
596
- return `${dir}/${formPath}`;
588
+ return `${formPath}`;
597
589
  }
598
590
  function getArkFileFromScene(im, originPath) {
599
591
  if (FileUtils_1.FileUtils.isDirectory(originPath)) {
@@ -626,7 +618,7 @@ function findExportInfoInfile(fromInfo, file) {
626
618
  if (exportInfo) {
627
619
  return exportInfo;
628
620
  }
629
- if (fromInfo.isDefault()) {
621
+ if (exportName === TSConst_1.DEFAULT) {
630
622
  exportInfo = file.getExportInfos().find(p => p.isDefault());
631
623
  if (exportInfo) {
632
624
  file.addExportInfo(exportInfo, TSConst_1.DEFAULT);
@@ -638,10 +630,9 @@ function findExportInfoInfile(fromInfo, file) {
638
630
  file.addExportInfo(exportInfo, TSConst_1.ALL);
639
631
  }
640
632
  else if (/\.d\.e?ts$/.test(file.getName())) {
641
- const declare = findArkExportInFile(fromInfo.getOriginName(), file);
642
- if (declare) {
643
- exportInfo = (0, ArkExportBuilder_1.buildDefaultExportInfo)(fromInfo, file, declare);
644
- }
633
+ let declare = exportName === TSConst_1.DEFAULT ? undefined
634
+ : findArkExportInFile(fromInfo.getOriginName(), file) || undefined;
635
+ exportInfo = (0, ArkExportBuilder_1.buildDefaultExportInfo)(fromInfo, file, declare);
645
636
  }
646
637
  return exportInfo;
647
638
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAU/C,qBAAa,QAAQ;WAEH,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IA2BpF,OAAO,CAAC,MAAM,CAAC,SAAS;IAexB,OAAO,CAAC,MAAM,CAAC,eAAe;IAmB9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAW5B"}
1
+ {"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C,qBAAa,QAAQ;WAEH,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAgCpF,OAAO,CAAC,MAAM,CAAC,SAAS;IAexB,OAAO,CAAC,MAAM,CAAC,eAAe;IAmB9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAW5B"}
@@ -13,6 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
17
20
  exports.SdkUtils = void 0;
18
21
  const EtsConst_1 = require("./EtsConst");
@@ -21,11 +24,15 @@ const Const_1 = require("./Const");
21
24
  const ArkClass_1 = require("../model/ArkClass");
22
25
  const ArkSignature_1 = require("../model/ArkSignature");
23
26
  const ModelUtils_1 = require("./ModelUtils");
27
+ const path_1 = __importDefault(require("path"));
24
28
  class SdkUtils {
25
29
  static buildGlobalMap(file, globalMap) {
26
- var _a, _b, _c;
27
- const isGlobalPath = file.getFilePath().includes(EtsConst_1.COMPONENT_PATH) ||
28
- file.getFilePath().includes(EtsConst_1.API_INTERNAL) || file.getFilePath().includes(EtsConst_1.API_COMMON);
30
+ var _a, _b, _c, _d;
31
+ const fileName = path_1.default.basename(file.getName());
32
+ if (fileName.startsWith('@')) {
33
+ ModelUtils_1.sdkImportMap.set(fileName.replace(/\.d\.e?ts$/, ''), file);
34
+ }
35
+ const isGlobalPath = (_a = file.getScene().getOptions().sdkGlobalFolders) === null || _a === void 0 ? void 0 : _a.find(x => file.getFilePath().includes(path_1.default.sep + x + path_1.default.sep));
29
36
  if (!isGlobalPath) {
30
37
  return;
31
38
  }
@@ -40,13 +47,13 @@ class SdkUtils {
40
47
  }
41
48
  });
42
49
  const defaultArkMethod = file.getDefaultClass().getDefaultArkMethod();
43
- (_a = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().forEach(local => {
50
+ (_b = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => {
44
51
  const name = local.getName();
45
52
  if (name !== TSConst_1.THIS_NAME && !name.startsWith(Const_1.TEMP_LOCAL_PREFIX) && !name.endsWith(EtsConst_1.COMPONENT_INSTANCE)) {
46
53
  this.loadGlobalLocal(local, defaultArkMethod, globalMap);
47
54
  }
48
55
  });
49
- (_c = (_b = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _b === void 0 ? void 0 : _b.getAliasTypeMap()) === null || _c === void 0 ? void 0 : _c.forEach(a => globalMap.set(a[0].getName(), a[0]));
56
+ (_d = (_c = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeMap()) === null || _d === void 0 ? void 0 : _d.forEach(a => globalMap.set(a[0].getName(), a[0]));
50
57
  }
51
58
  static loadClass(globalMap, cls) {
52
59
  const old = globalMap.get(cls.getName());
@@ -1 +1 @@
1
- {"version":3,"file":"TypeInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/TypeInference.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAyC,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAOH,YAAY,EACZ,WAAW,EAKX,IAAI,EACJ,oBAAoB,EAKvB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