arkanalyzer 1.0.32 → 1.0.34
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.
- package/config/arkanalyzer.json +1 -0
- package/lib/Config.d.ts +1 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +26 -18
- package/lib/Scene.d.ts +5 -5
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +21 -19
- package/lib/VFG/DVFG.d.ts.map +1 -1
- package/lib/VFG/builder/DVFGBuilder.d.ts +2 -2
- package/lib/VFG/builder/DVFGBuilder.d.ts.map +1 -1
- package/lib/VFG/builder/DVFGBuilder.js +15 -7
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +1 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +24 -8
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +3 -2
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +4 -3
- package/lib/callgraph/common/Statistics.d.ts +9 -7
- package/lib/callgraph/common/Statistics.d.ts.map +1 -1
- package/lib/callgraph/common/Statistics.js +18 -6
- package/lib/callgraph/model/CallGraph.d.ts +2 -0
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +14 -8
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +1 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -1
- package/lib/callgraph/model/builder/CallGraphBuilder.js +9 -4
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Context.js +2 -2
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +4 -2
- package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PTAUtils.js +2 -3
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +27 -35
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +63 -46
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +12 -12
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +10 -6
- package/lib/core/base/Constant.js +2 -2
- package/lib/core/base/DefUseChain.d.ts.map +1 -1
- package/lib/core/base/DefUseChain.js +1 -1
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +3 -5
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +7 -2
- package/lib/core/base/Position.d.ts.map +1 -1
- package/lib/core/base/Position.js +1 -1
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +3 -1
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +1 -4
- package/lib/core/base/Trap.js +1 -1
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +2 -2
- package/lib/core/base/Value.d.ts +1 -1
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/base/Value.js +1 -1
- package/lib/core/common/ArkError.js +1 -1
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +46 -36
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +295 -109
- package/lib/core/common/Builtin.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +10 -4
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +3 -12
- package/lib/core/common/ExprUseReplacer.js +1 -1
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +40 -20
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +5 -4
- package/lib/core/common/ModelUtils.d.ts +1 -1
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +40 -29
- package/lib/core/common/RefUseReplacer.js +1 -1
- package/lib/core/common/SdkUtils.d.ts +3 -0
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +29 -10
- package/lib/core/common/StmtDefReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtDefReplacer.js +1 -1
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
- package/lib/core/common/StmtUseReplacer.js +1 -1
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +25 -17
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +1 -1
- package/lib/core/common/VisibleValue.d.ts.map +1 -1
- package/lib/core/common/VisibleValue.js +5 -5
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +1 -1
- package/lib/core/dataflow/DataflowResult.js +1 -1
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +5 -3
- package/lib/core/dataflow/Edge.d.ts.map +1 -1
- package/lib/core/dataflow/Edge.js +1 -1
- package/lib/core/dataflow/Fact.js +1 -1
- package/lib/core/dataflow/GenericDataFlow.js +5 -5
- package/lib/core/dataflow/ReachingDef.js +4 -4
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +17 -13
- package/lib/core/dataflow/Util.d.ts +4 -4
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +3 -5
- package/lib/core/graph/BaseExplicitGraph.d.ts.map +1 -1
- package/lib/core/graph/BaseExplicitGraph.js +1 -1
- package/lib/core/graph/BaseImplicitGraph.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +11 -7
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +10 -4
- package/lib/core/graph/DependsGraph.d.ts.map +1 -1
- package/lib/core/graph/DependsGraph.js +1 -1
- package/lib/core/graph/DominanceFinder.d.ts.map +1 -1
- package/lib/core/graph/DominanceFinder.js +4 -4
- package/lib/core/graph/DominanceTree.js +1 -1
- package/lib/core/graph/GraphTraits.js +1 -1
- package/lib/core/graph/Scc.js +2 -2
- package/lib/core/graph/ViewTree.js +1 -1
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/CfgBuilder.js +22 -13
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ConditionBuilder.js +21 -22
- package/lib/core/graph/builder/LoopBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/LoopBuilder.js +13 -10
- package/lib/core/graph/builder/SwitchBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/SwitchBuilder.js +7 -4
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/TrapBuilder.js +4 -3
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +18 -19
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -1
- package/lib/core/model/ArkBaseModel.js +8 -5
- package/lib/core/model/ArkBody.d.ts +1 -0
- package/lib/core/model/ArkBody.d.ts.map +1 -1
- package/lib/core/model/ArkBody.js +11 -1
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +3 -5
- package/lib/core/model/ArkExport.d.ts +4 -0
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +8 -1
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +2 -2
- package/lib/core/model/ArkFile.d.ts +1 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +21 -6
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +1 -1
- package/lib/core/model/ArkMetadata.d.ts.map +1 -1
- package/lib/core/model/ArkMetadata.js +1 -1
- package/lib/core/model/ArkMethod.d.ts +6 -5
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +27 -13
- package/lib/core/model/ArkNamespace.d.ts +1 -1
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +5 -6
- package/lib/core/model/ArkSignature.d.ts +4 -2
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +17 -17
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +15 -16
- package/lib/core/model/builder/ArkExportBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +17 -11
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +6 -7
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFileBuilder.js +22 -11
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkImportBuilder.js +13 -8
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +3 -3
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +7 -9
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkSignatureBuilder.js +1 -1
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/BodyBuilder.js +8 -5
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +15 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/save/ArkStream.d.ts.map +1 -1
- package/lib/save/ArkStream.js +1 -1
- package/lib/save/DotPrinter.d.ts.map +1 -1
- package/lib/save/DotPrinter.js +2 -4
- package/lib/save/GraphPrinter.d.ts.map +1 -1
- package/lib/save/GraphPrinter.js +2 -3
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +29 -29
- package/lib/save/Printer.js +1 -1
- package/lib/save/PrinterBuilder.d.ts.map +1 -1
- package/lib/save/PrinterBuilder.js +1 -1
- package/lib/save/ViewTreePrinter.d.ts.map +1 -1
- package/lib/save/ViewTreePrinter.js +3 -3
- package/lib/save/arkir/ArkIRClassPrinter.js +1 -1
- package/lib/save/arkir/ArkIRMethodPrinter.js +5 -5
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts.map +1 -1
- package/lib/save/arkir/ArkIRNamespacePrinter.js +2 -3
- package/lib/save/base/BasePrinter.js +2 -2
- package/lib/save/base/ExportPrinter.d.ts.map +1 -1
- package/lib/save/base/ExportPrinter.js +3 -6
- package/lib/save/base/ImportPrinter.d.ts.map +1 -1
- package/lib/save/base/ImportPrinter.js +2 -6
- package/lib/save/base/PrinterUtils.d.ts.map +1 -1
- package/lib/save/base/PrinterUtils.js +2 -4
- package/lib/save/serializeArkIR.d.ts.map +1 -1
- package/lib/save/serializeArkIR.js +2 -2
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +1 -3
- package/lib/save/source/SourceBody.d.ts.map +1 -1
- package/lib/save/source/SourceBody.js +1 -5
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +2 -3
- package/lib/save/source/SourceField.js +2 -2
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +5 -6
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +2 -3
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +9 -14
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +6 -10
- package/lib/transformer/FunctionTransformer.d.ts.map +1 -1
- package/lib/transformer/FunctionTransformer.js +1 -1
- package/lib/transformer/SceneTransformer.d.ts.map +1 -1
- package/lib/transformer/SceneTransformer.js +1 -1
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -1
- package/lib/transformer/StaticSingleAssignmentFormer.js +1 -1
- package/lib/transformer/Transformer.d.ts.map +1 -1
- package/lib/transformer/Transformer.js +2 -3
- package/lib/utils/AstTreeUtils.d.ts.map +1 -1
- package/lib/utils/AstTreeUtils.js +1 -1
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +6 -18
- package/lib/utils/FileUtils.d.ts.map +1 -1
- package/lib/utils/FileUtils.js +7 -7
- package/lib/utils/SparseBitVector.d.ts.map +1 -1
- package/lib/utils/SparseBitVector.js +6 -5
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +9 -7
- package/lib/utils/crypto_utils.d.ts.map +1 -1
- package/lib/utils/crypto_utils.js +2 -2
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +18 -18
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/json5parser.d.ts.map +1 -1
- package/lib/utils/json5parser.js +1 -1
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/pathTransfer.d.ts +0 -1
- package/lib/utils/pathTransfer.d.ts.map +1 -1
- package/lib/utils/pathTransfer.js +2 -11
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Builtin.d.ts","sourceRoot":"","sources":["../../../src/core/common/Builtin.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAsB,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,SAAS,EAA2B,MAAM,cAAc,CAAC;AAElE,qBAAa,OAAO;IAGhB,OAAc,MAAM,SAAY;IAChC,OAAc,KAAK,SAAW;IAC9B,OAAc,GAAG,SAAS;IAC1B,OAAc,GAAG,SAAS;IAC1B,OAAc,MAAM,SAAY;IAEhC,OAAc,gBAAgB,cAA8B;IAG5D,OAAc,kBAAkB,SAAY;IAC5C,OAAc,eAAe,SAAkB;IAE/C,OAAc,+BAA+B,gBAA8C;IAC3F,OAAc,sBAAsB,iBAAgD;IACpF,OAAc,iBAAiB,YAA8C;IAC7E,OAAc,qBAAqB,iBAA+C;IAClF,OAAc,mBAAmB,iBAA6C;IAC9E,OAAc,mBAAmB,iBAA6C;IAC9E,OAAc,sBAAsB,iBAAgD;IACpF,OAAc,iBAAiB,YAA8C;IAC7E,OAAc,4BAA4B,8BAAwC;IAGlF,OAAc,iBAAiB,SAAc;IAC7C,OAAc,QAAQ,SAAc;IACpC,OAAc,aAAa,SAAU;IACrC,OAAc,eAAe,SAAoB;IACjD,OAAc,oBAAoB,SAAU;IAC5C,OAAc,qBAAqB,SAAW;IAE9C,OAAc,wBAAwB,iBAAkD;IACxF,OAAc,+BAA+B,iBAAyD;IACtG,OAAc,mBAAmB,YAAwE;IACzG,OAA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,OAAO,CAAC,MAAM,CAAC,6BAA6B;WAU9B,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DummyMainCreater.d.ts","sourceRoot":"","sources":["../../../src/core/common/DummyMainCreater.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DummyMainCreater.d.ts","sourceRoot":"","sources":["../../../src/core/common/DummyMainCreater.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAYpC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,aAAa,CAA2C;IAChE,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,cAAc,CAAa;gBAEvB,KAAK,EAAE,KAAK;IASjB,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI;IAI3C,eAAe,IAAI,IAAI;IAuD9B,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,WAAW;IAqCnB,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,WAAW;IAYZ,YAAY,IAAI,SAAS;IAIhC,OAAO,CAAC,6BAA6B;IAoBrC,OAAO,CAAC,oBAAoB;IAerB,0BAA0B,IAAI,SAAS,EAAE;IAWzC,kBAAkB,IAAI,SAAS,EAAE;CAkB3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 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
|
|
@@ -171,6 +171,7 @@ class DummyMainCreater {
|
|
|
171
171
|
paramLocals.push(paramLocal);
|
|
172
172
|
if (paramType instanceof Type_1.ClassType) {
|
|
173
173
|
const assStmt = new Stmt_1.ArkAssignStmt(paramLocal, new Expr_1.ArkNewExpr(paramType));
|
|
174
|
+
paramLocal.setDeclaringStmt(assStmt);
|
|
174
175
|
invokeBlock.addStmt(assStmt);
|
|
175
176
|
}
|
|
176
177
|
paramIdx++;
|
|
@@ -259,7 +260,8 @@ class DummyMainCreater {
|
|
|
259
260
|
getEntryMethodsFromComponents() {
|
|
260
261
|
const COMPONENT_BASE_CLASSES = ['CustomComponent', 'ViewPU'];
|
|
261
262
|
let methods = [];
|
|
262
|
-
this.scene
|
|
263
|
+
this.scene
|
|
264
|
+
.getClasses()
|
|
263
265
|
.filter(cls => {
|
|
264
266
|
if (COMPONENT_BASE_CLASSES.includes(cls.getSuperClassName())) {
|
|
265
267
|
return true;
|
|
@@ -290,7 +292,8 @@ class DummyMainCreater {
|
|
|
290
292
|
}
|
|
291
293
|
getMethodsFromAllAbilities() {
|
|
292
294
|
let methods = [];
|
|
293
|
-
this.scene
|
|
295
|
+
this.scene
|
|
296
|
+
.getClasses()
|
|
294
297
|
.filter(cls => this.classInheritsAbility(cls))
|
|
295
298
|
.forEach(cls => {
|
|
296
299
|
methods.push(...cls.getMethods().filter(mtd => entryMethodUtils_1.LIFECYCLE_METHOD_NAME.includes(mtd.getName())));
|
|
@@ -303,7 +306,10 @@ class DummyMainCreater {
|
|
|
303
306
|
if (!method.getCfg()) {
|
|
304
307
|
return;
|
|
305
308
|
}
|
|
306
|
-
method
|
|
309
|
+
method
|
|
310
|
+
.getCfg()
|
|
311
|
+
.getStmts()
|
|
312
|
+
.forEach(stmt => {
|
|
307
313
|
const cbMethod = (0, entryMethodUtils_1.getCallbackMethodFromStmt)(stmt, this.scene);
|
|
308
314
|
if (cbMethod && !callbackMethods.includes(cbMethod)) {
|
|
309
315
|
callbackMethods.push(cbMethod);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAeA,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,
|
|
1
|
+
{"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAeA,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,CAAkG,CAAC;AAEpJ,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,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,CAAwF,CAAC;AAE7I,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 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
|
|
@@ -923,11 +923,7 @@ exports.ETS_COMPILER_OPTIONS = {
|
|
|
923
923
|
};
|
|
924
924
|
exports.COMPONENT_FOR_EACH = 'ForEach';
|
|
925
925
|
exports.COMPONENT_LAZY_FOR_EACH = 'LazyForEach';
|
|
926
|
-
exports.BUILDIN_SYSTEM_COMPONENT = new Set([
|
|
927
|
-
...exports.ETS_COMPILER_OPTIONS.ets.components,
|
|
928
|
-
exports.COMPONENT_FOR_EACH,
|
|
929
|
-
exports.COMPONENT_LAZY_FOR_EACH,
|
|
930
|
-
]);
|
|
926
|
+
exports.BUILDIN_SYSTEM_COMPONENT = new Set([...exports.ETS_COMPILER_OPTIONS.ets.components, exports.COMPONENT_FOR_EACH, exports.COMPONENT_LAZY_FOR_EACH]);
|
|
931
927
|
exports.BUILDIN_ATOMIC_COMPONENT = new Set([
|
|
932
928
|
'AbilityComponent',
|
|
933
929
|
'AlphabetIndexer',
|
|
@@ -1006,12 +1002,7 @@ exports.COMPONENT_IF = 'If';
|
|
|
1006
1002
|
exports.COMPONENT_IF_BRANCH = 'IfBranch';
|
|
1007
1003
|
exports.COMPONENT_BRANCH_FUNCTION = 'branch';
|
|
1008
1004
|
exports.COMPONENT_BUILD_FUNCTION = 'build';
|
|
1009
|
-
exports.SPECIAL_CONTAINER_COMPONENT = new Set([
|
|
1010
|
-
exports.COMPONENT_IF,
|
|
1011
|
-
exports.COMPONENT_IF_BRANCH,
|
|
1012
|
-
exports.COMPONENT_CUSTOMVIEW,
|
|
1013
|
-
exports.COMPONENT_REPEAT,
|
|
1014
|
-
]);
|
|
1005
|
+
exports.SPECIAL_CONTAINER_COMPONENT = new Set([exports.COMPONENT_IF, exports.COMPONENT_IF_BRANCH, exports.COMPONENT_CUSTOMVIEW, exports.COMPONENT_REPEAT]);
|
|
1015
1006
|
exports.COMPONENT_COMMON = 'Common';
|
|
1016
1007
|
exports.COMPONENT_INSTANCE = 'Instance';
|
|
1017
1008
|
exports.COMPONENT_ATTRIBUTE = 'Attribute';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 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
|
|
@@ -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,EAKT,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EAErB,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,EACnB,eAAe,
|
|
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,EAKT,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EAErB,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,mBAAm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B,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe;IAavG,OAAO,CAAC,MAAM,CAAC,cAAc;WAsBf,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAgBjE,OAAO,CAAC,MAAM,CAAC,yBAAyB;WAiD1B,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI;IAkC/H,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,eAAe;WAgChB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY;WAiC3E,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WA2CnE,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WAcnE,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,GAAG,WAAW;CAqB3F"}
|
|
@@ -70,6 +70,15 @@ class IRInference {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
file.getNamespaces().forEach(namespace => {
|
|
74
|
+
namespace.getExportInfos().forEach(exportInfo => {
|
|
75
|
+
if (exportInfo.getArkExport() === undefined) {
|
|
76
|
+
let arkExport = (0, ModelUtils_1.findArkExport)(exportInfo);
|
|
77
|
+
exportInfo.setArkExport(arkExport);
|
|
78
|
+
arkExport !== null ? exportInfo.setExportClauseType(arkExport.getExportType()) : true;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
73
82
|
}
|
|
74
83
|
static inferImportInfos(file) {
|
|
75
84
|
file.getImportInfos().forEach(importInfo => {
|
|
@@ -150,7 +159,7 @@ class IRInference {
|
|
|
150
159
|
method = arkExport.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
|
|
151
160
|
}
|
|
152
161
|
else if (arkExport instanceof Local_1.Local) {
|
|
153
|
-
const type = arkExport.getType();
|
|
162
|
+
const type = TypeInference_1.TypeInference.replaceAliasType(arkExport.getType());
|
|
154
163
|
if (type instanceof Type_1.ClassType) {
|
|
155
164
|
const cls = arkClass.getDeclaringArkFile().getScene().getClass(type.getClassSignature());
|
|
156
165
|
method = (_e = cls === null || cls === void 0 ? void 0 : cls.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME)) !== null && _e !== void 0 ? _e : cls === null || cls === void 0 ? void 0 : cls.getMethodWithName(Const_1.CALL_SIGNATURE_NAME);
|
|
@@ -192,7 +201,7 @@ class IRInference {
|
|
|
192
201
|
}
|
|
193
202
|
}
|
|
194
203
|
const scene = arkClass.getDeclaringArkFile().getScene();
|
|
195
|
-
if (
|
|
204
|
+
if (methodName === 'forEach' && baseType instanceof Type_1.ArrayType) {
|
|
196
205
|
this.processForEach(expr.getArg(0), baseType, scene);
|
|
197
206
|
return expr;
|
|
198
207
|
}
|
|
@@ -243,6 +252,7 @@ class IRInference {
|
|
|
243
252
|
return ref;
|
|
244
253
|
}
|
|
245
254
|
static inferBase(instance, arkMethod) {
|
|
255
|
+
var _a, _b;
|
|
246
256
|
const base = instance.getBase();
|
|
247
257
|
if (base.getName() === TSConst_1.THIS_NAME) {
|
|
248
258
|
const declaringArkClass = arkMethod.getDeclaringArkClass();
|
|
@@ -257,6 +267,14 @@ class IRInference {
|
|
|
257
267
|
}
|
|
258
268
|
}
|
|
259
269
|
else {
|
|
270
|
+
const value = (_b = (_a = arkMethod.getBody()) === null || _a === void 0 ? void 0 : _a.getUsedGlobals()) === null || _b === void 0 ? void 0 : _b.get(base.getName());
|
|
271
|
+
if (value instanceof Ref_1.GlobalRef && !value.getRef()) {
|
|
272
|
+
const arkExport = ModelUtils_1.ModelUtils.findGlobalRef(base.getName(), arkMethod);
|
|
273
|
+
if (arkExport instanceof Local_1.Local) {
|
|
274
|
+
arkExport.getUsedStmts().push(...base.getUsedStmts());
|
|
275
|
+
value.setRef(arkExport);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
260
278
|
this.inferLocal(instance.getBase(), arkMethod);
|
|
261
279
|
}
|
|
262
280
|
}
|
|
@@ -318,8 +336,7 @@ class IRInference {
|
|
|
318
336
|
this.inferArg(expr, argType, expr.getBase().getType().getBaseType(), scene, realTypes);
|
|
319
337
|
}
|
|
320
338
|
}
|
|
321
|
-
if (paramType instanceof Type_1.ClassType && scene.getProjectSdkMap().has(paramType.getClassSignature()
|
|
322
|
-
.getDeclaringFileSignature().getProjectName())) {
|
|
339
|
+
if (paramType instanceof Type_1.ClassType && scene.getProjectSdkMap().has(paramType.getClassSignature().getDeclaringFileSignature().getProjectName())) {
|
|
323
340
|
this.inferArgTypeWithSdk(paramType, scene, argType);
|
|
324
341
|
}
|
|
325
342
|
else if (paramType instanceof Type_1.GenericType || paramType instanceof Type_1.AnyType) {
|
|
@@ -397,8 +414,7 @@ class IRInference {
|
|
|
397
414
|
let signature = foundMethod.matchMethodSignature(expr.getArgs());
|
|
398
415
|
TypeInference_1.TypeInference.inferSignatureReturnType(signature, foundMethod);
|
|
399
416
|
expr.setMethodSignature(signature);
|
|
400
|
-
return expr instanceof Expr_1.ArkInstanceInvokeExpr ?
|
|
401
|
-
new Expr_1.ArkStaticInvokeExpr(signature, expr.getArgs(), expr.getRealGenericTypes()) : expr;
|
|
417
|
+
return expr instanceof Expr_1.ArkInstanceInvokeExpr ? new Expr_1.ArkStaticInvokeExpr(signature, expr.getArgs(), expr.getRealGenericTypes()) : expr;
|
|
402
418
|
}
|
|
403
419
|
}
|
|
404
420
|
}
|
|
@@ -413,8 +429,7 @@ class IRInference {
|
|
|
413
429
|
static inferInvokeExprWithArray(methodName, expr, baseType, scene) {
|
|
414
430
|
if (methodName === Builtin_1.Builtin.ITERATOR_FUNCTION) {
|
|
415
431
|
const returnType = expr.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
416
|
-
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
417
|
-
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
432
|
+
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
418
433
|
expr.setRealGenericTypes([baseType.getBaseType()]);
|
|
419
434
|
return expr;
|
|
420
435
|
}
|
|
@@ -479,18 +494,21 @@ class IRInference {
|
|
|
479
494
|
}
|
|
480
495
|
}
|
|
481
496
|
if (methodSignature) {
|
|
482
|
-
const ptr = expr instanceof Expr_1.ArkInstanceInvokeExpr
|
|
483
|
-
new Ref_1.ArkInstanceFieldRef(expr.getBase(), method.getSignature())
|
|
497
|
+
const ptr = expr instanceof Expr_1.ArkInstanceInvokeExpr
|
|
498
|
+
? new Ref_1.ArkInstanceFieldRef(expr.getBase(), method.getSignature())
|
|
499
|
+
: new Ref_1.ArkStaticFieldRef(method.getSignature());
|
|
484
500
|
expr = new Expr_1.ArkPtrInvokeExpr(methodSignature, ptr, expr.getArgs(), expr.getRealGenericTypes());
|
|
485
501
|
}
|
|
486
502
|
return expr;
|
|
487
503
|
}
|
|
488
|
-
else if (methodName === TSConst_1.CONSTRUCTOR_NAME) {
|
|
504
|
+
else if (methodName === TSConst_1.CONSTRUCTOR_NAME) {
|
|
505
|
+
//sdk隐式构造
|
|
489
506
|
const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], new Type_1.ClassType(baseType.getClassSignature()));
|
|
490
507
|
expr.setMethodSignature(new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature));
|
|
491
508
|
return expr;
|
|
492
509
|
}
|
|
493
|
-
else if (methodName === Builtin_1.Builtin.ITERATOR_NEXT) {
|
|
510
|
+
else if (methodName === Builtin_1.Builtin.ITERATOR_NEXT) {
|
|
511
|
+
//sdk隐式构造
|
|
494
512
|
const returnType = expr.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
495
513
|
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
496
514
|
returnType.setRealGenericTypes(baseType.getRealGenericTypes());
|
|
@@ -532,7 +550,7 @@ class IRInference {
|
|
|
532
550
|
if (argMethod != null && argMethod.getBody()) {
|
|
533
551
|
const body = argMethod.getBody();
|
|
534
552
|
const firstStmt = body.getCfg().getStartingStmt();
|
|
535
|
-
if (
|
|
553
|
+
if (firstStmt instanceof Stmt_1.ArkAssignStmt && firstStmt.getRightOp() instanceof Ref_1.ArkParameterRef) {
|
|
536
554
|
const parameterRef = firstStmt.getRightOp();
|
|
537
555
|
parameterRef.setType(baseType.getBaseType());
|
|
538
556
|
const argMethodParams = argMethod.getSignature().getMethodSubSignature().getParameters();
|
|
@@ -582,8 +600,8 @@ class IRInference {
|
|
|
582
600
|
const fieldName = ref.getFieldName().replace(/[\"|\']/g, '');
|
|
583
601
|
const propertyAndType = TypeInference_1.TypeInference.inferFieldType(baseType, fieldName, arkClass);
|
|
584
602
|
let propertyType = propertyAndType === null || propertyAndType === void 0 ? void 0 : propertyAndType[1];
|
|
585
|
-
if (!propertyType) {
|
|
586
|
-
const newType = TypeInference_1.TypeInference.
|
|
603
|
+
if (!propertyType || propertyType instanceof Type_1.UnknownType) {
|
|
604
|
+
const newType = TypeInference_1.TypeInference.inferBaseType(fieldName, arkClass);
|
|
587
605
|
if (newType) {
|
|
588
606
|
propertyType = newType;
|
|
589
607
|
}
|
|
@@ -601,8 +619,9 @@ class IRInference {
|
|
|
601
619
|
if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER) {
|
|
602
620
|
return property.getSignature();
|
|
603
621
|
}
|
|
604
|
-
staticFlag =
|
|
605
|
-
((
|
|
622
|
+
staticFlag =
|
|
623
|
+
baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
|
|
624
|
+
((property instanceof ArkField_1.ArkField || property instanceof ArkMethod_1.ArkMethod) && property.isStatic());
|
|
606
625
|
signature = property instanceof ArkMethod_1.ArkMethod ? property.getSignature().getDeclaringClassSignature() : baseType.getClassSignature();
|
|
607
626
|
}
|
|
608
627
|
else if (baseType instanceof Type_1.AnnotationNamespaceType) {
|
|
@@ -665,8 +684,7 @@ class IRInference {
|
|
|
665
684
|
if (type instanceof Type_1.ClassType) {
|
|
666
685
|
deepInfer(rightType, type.getClassSignature());
|
|
667
686
|
}
|
|
668
|
-
else if (type instanceof Type_1.ArrayType && type.getBaseType() instanceof Type_1.ClassType &&
|
|
669
|
-
rightType instanceof Type_1.ArrayType) {
|
|
687
|
+
else if (type instanceof Type_1.ArrayType && type.getBaseType() instanceof Type_1.ClassType && rightType instanceof Type_1.ArrayType) {
|
|
670
688
|
const baseType = rightType.getBaseType();
|
|
671
689
|
const classSignature = type.getBaseType().getClassSignature();
|
|
672
690
|
if (baseType instanceof Type_1.UnionType) {
|
|
@@ -790,7 +808,9 @@ class IRInference {
|
|
|
790
808
|
}
|
|
791
809
|
}
|
|
792
810
|
else if (paramType instanceof Type_1.LexicalEnvType) {
|
|
793
|
-
paramType
|
|
811
|
+
paramType
|
|
812
|
+
.getClosures()
|
|
813
|
+
.filter(c => TypeInference_1.TypeInference.isUnclearType(c.getType()))
|
|
794
814
|
.forEach(e => this.inferLocal(e, arkMethod));
|
|
795
815
|
return ref;
|
|
796
816
|
}
|
|
@@ -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,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,YAAY,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,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,GAAG,gBAAgB;WA2B1H,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;WAqClF,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE;CAOxE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 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
|
|
@@ -62,8 +62,8 @@ class IRUtils {
|
|
|
62
62
|
if ((isLeading && !options.enableLeadingComments) || (!isLeading && !options.enableTrailingComments)) {
|
|
63
63
|
return new ArkMetadata_1.CommentsMetadata(comments);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// node.pos is the start position of
|
|
66
|
+
const commentRanges = (isLeading ? ohos_typescript_1.default.getLeadingCommentRanges(sourceFile.text, node.pos) : ohos_typescript_1.default.getTrailingCommentRanges(sourceFile.text, node.end)) || [];
|
|
67
67
|
// leading comment, while node.end is the
|
|
68
68
|
// end position of the statement
|
|
69
69
|
const getPosition = (pos, end) => {
|
|
@@ -113,7 +113,8 @@ class IRUtils {
|
|
|
113
113
|
operandOriginalPositions.splice(oldValueIdx + baseValueOffset, 0, ...IRUtils.generateDefaultPositions(newValueUseSize - oldValueUseSize));
|
|
114
114
|
}
|
|
115
115
|
if (oldValue instanceof Ref_1.ArkInstanceFieldRef && newValue instanceof Ref_1.ArkArrayRef) {
|
|
116
|
-
if (operandOriginalPositionSize === defUseSize) {
|
|
116
|
+
if (operandOriginalPositionSize === defUseSize) {
|
|
117
|
+
// may not reserve positions for field name
|
|
117
118
|
operandOriginalPositions.splice(oldValueIdx + fieldValueOffset, 0, ...IRUtils.generateDefaultPositions(newValueUseSize - oldValueUseSize));
|
|
118
119
|
}
|
|
119
120
|
}
|
|
@@ -45,11 +45,11 @@ export declare class ModelUtils {
|
|
|
45
45
|
static findPropertyInClass(name: string, arkClass: ArkClass): ArkExport | ArkField | null;
|
|
46
46
|
static findDeclaredLocal(local: Local, arkMethod: ArkMethod, times?: number): Local | null;
|
|
47
47
|
static findArkModel(baseName: string, arkClass: ArkClass): ArkExport | ArkField | null;
|
|
48
|
+
static findGlobalRef(refName: string, method: ArkMethod): ArkExport | null;
|
|
48
49
|
static findArkModelByRefName(refName: string, arkClass: ArkClass): ArkExport | ArkField | null;
|
|
49
50
|
static findArkModelBySignature(signature: Signature, scene: Scene): ArkExport | ArkField | null;
|
|
50
51
|
static parseArkBaseModel2Type(arkBaseModel: ArkBaseModel): Type | null;
|
|
51
52
|
}
|
|
52
|
-
export declare const sdkImportMap: Map<string, ArkFile>;
|
|
53
53
|
/**
|
|
54
54
|
* find arkFile by from info
|
|
55
55
|
* 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,EAEH,cAAc,EAKd,eAAe,EAEf,SAA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AAG,SAAS,GAAG,QAAQ,GAAG,IAAI;WA2BvF,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI;WAyBxF,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI;CAehF;AAKD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CA+BnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CA2BpE;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CA+BlF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAkB7F;AAmED,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.
|
|
43
|
+
exports.initModulePathMap = exports.findArkExportInFile = exports.findArkExport = exports.findExportInfo = exports.getArkFile = 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");
|
|
@@ -58,6 +58,7 @@ const Const_1 = require("./Const");
|
|
|
58
58
|
const ValueUtil_1 = require("./ValueUtil");
|
|
59
59
|
const Stmt_1 = require("../base/Stmt");
|
|
60
60
|
const Ref_1 = require("../base/Ref");
|
|
61
|
+
const SdkUtils_1 = require("./SdkUtils");
|
|
61
62
|
class ModelUtils {
|
|
62
63
|
static getMethodSignatureFromArkClass(arkClass, methodName) {
|
|
63
64
|
for (const arkMethod of arkClass.getMethods()) {
|
|
@@ -100,8 +101,9 @@ class ModelUtils {
|
|
|
100
101
|
const names = className.split('.');
|
|
101
102
|
let nameSpace = this.getNamespaceWithNameFromClass(names[0], startFrom);
|
|
102
103
|
for (let i = 1; i < names.length - 1; i++) {
|
|
103
|
-
if (nameSpace)
|
|
104
|
+
if (nameSpace) {
|
|
104
105
|
nameSpace = nameSpace.getNamespaceWithName(names[i]);
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
if (nameSpace) {
|
|
107
109
|
return nameSpace.getClassWithName(names[names.length - 1]);
|
|
@@ -263,24 +265,21 @@ class ModelUtils {
|
|
|
263
265
|
}
|
|
264
266
|
static getAllClassesInFile(arkFile) {
|
|
265
267
|
const allClasses = arkFile.getClasses();
|
|
266
|
-
this.getAllNamespacesInFile(arkFile).forEach(
|
|
268
|
+
this.getAllNamespacesInFile(arkFile).forEach(namespace => {
|
|
267
269
|
allClasses.push(...namespace.getClasses());
|
|
268
270
|
});
|
|
269
271
|
return allClasses;
|
|
270
272
|
}
|
|
271
273
|
static getAllMethodsInFile(arkFile) {
|
|
272
274
|
const allMethods = [];
|
|
273
|
-
this.getAllClassesInFile(arkFile).forEach(
|
|
275
|
+
this.getAllClassesInFile(arkFile).forEach(cls => {
|
|
274
276
|
allMethods.push(...cls.getMethods());
|
|
275
277
|
});
|
|
276
278
|
return allMethods;
|
|
277
279
|
}
|
|
278
280
|
static isArkUIBuilderMethod(arkMethod) {
|
|
279
281
|
let isArkUIBuilderMethod = arkMethod.hasBuilderDecorator() || this.implicitArkUIBuilderMethods.has(arkMethod);
|
|
280
|
-
if (!isArkUIBuilderMethod &&
|
|
281
|
-
arkMethod.getName() === 'build' &&
|
|
282
|
-
arkMethod.getDeclaringArkClass().hasComponentDecorator() &&
|
|
283
|
-
!arkMethod.isStatic()) {
|
|
282
|
+
if (!isArkUIBuilderMethod && arkMethod.getName() === 'build' && arkMethod.getDeclaringArkClass().hasComponentDecorator() && !arkMethod.isStatic()) {
|
|
284
283
|
const fileName = arkMethod.getDeclaringArkClass().getDeclaringArkFile().getName();
|
|
285
284
|
if (fileName.endsWith('.ets')) {
|
|
286
285
|
isArkUIBuilderMethod = true;
|
|
@@ -328,7 +327,7 @@ class ModelUtils {
|
|
|
328
327
|
}
|
|
329
328
|
static findPropertyInNamespace(name, namespace) {
|
|
330
329
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
331
|
-
return (_j = (_e = (_d = (_c = (_b = (_a = namespace.getDefaultClass()) === null || _a === void 0 ? void 0 : _a.getMethodWithName(name)) !== null && _b !== void 0 ? _b : findArkExport(namespace.getExportInfoBy(name))) !== null && _c !== void 0 ? _c : namespace.getClassWithName(name)) !== null && _d !== void 0 ? _d : namespace.getNamespaceWithName(name)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = namespace.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name)) !== null && _j !== void 0 ? _j : (_o = (_m = (_l = (_k = namespace.getDefaultClass()) === null || _k === void 0 ? void 0 : _k.getDefaultArkMethod()) === null || _l === void 0 ? void 0 : _l.getBody()) === null || _m === void 0 ? void 0 : _m.getLocals()) === null || _o === void 0 ? void 0 : _o.get(name);
|
|
330
|
+
return ((_j = (_e = (_d = (_c = (_b = (_a = namespace.getDefaultClass()) === null || _a === void 0 ? void 0 : _a.getMethodWithName(name)) !== null && _b !== void 0 ? _b : findArkExport(namespace.getExportInfoBy(name))) !== null && _c !== void 0 ? _c : namespace.getClassWithName(name)) !== null && _d !== void 0 ? _d : namespace.getNamespaceWithName(name)) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = namespace.getDefaultClass()) === null || _f === void 0 ? void 0 : _f.getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getAliasTypeByName(name)) !== null && _j !== void 0 ? _j : (_o = (_m = (_l = (_k = namespace.getDefaultClass()) === null || _k === void 0 ? void 0 : _k.getDefaultArkMethod()) === null || _l === void 0 ? void 0 : _l.getBody()) === null || _m === void 0 ? void 0 : _m.getLocals()) === null || _o === void 0 ? void 0 : _o.get(name));
|
|
332
331
|
}
|
|
333
332
|
static findPropertyInClass(name, arkClass) {
|
|
334
333
|
var _a, _b, _c;
|
|
@@ -362,7 +361,8 @@ class ModelUtils {
|
|
|
362
361
|
}
|
|
363
362
|
if (times > 0) {
|
|
364
363
|
const declaredLocal = (_a = arkMethod.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().get(name);
|
|
365
|
-
if (declaredLocal &&
|
|
364
|
+
if (declaredLocal &&
|
|
365
|
+
declaredLocal.getDeclaringStmt() instanceof Stmt_1.ArkAssignStmt &&
|
|
366
366
|
!(declaredLocal.getDeclaringStmt().getRightOp() instanceof Ref_1.ClosureFieldRef)) {
|
|
367
367
|
return declaredLocal;
|
|
368
368
|
}
|
|
@@ -377,7 +377,9 @@ class ModelUtils {
|
|
|
377
377
|
const outerStart = className.indexOf(Const_1.NAME_DELIMITER);
|
|
378
378
|
const outerEnd = className.lastIndexOf('.');
|
|
379
379
|
if (outerStart > -1 && outerEnd > -1) {
|
|
380
|
-
invokeMethod = (_b = arkMethod
|
|
380
|
+
invokeMethod = (_b = arkMethod
|
|
381
|
+
.getDeclaringArkFile()
|
|
382
|
+
.getClassWithName(className.substring(outerStart + 1, outerEnd))) === null || _b === void 0 ? void 0 : _b.getMethodWithName(className.substring(outerEnd + 1));
|
|
381
383
|
}
|
|
382
384
|
else {
|
|
383
385
|
const cls = arkMethod.getDeclaringArkClass();
|
|
@@ -395,12 +397,17 @@ class ModelUtils {
|
|
|
395
397
|
if (arkModel) {
|
|
396
398
|
return arkModel;
|
|
397
399
|
}
|
|
398
|
-
arkModel =
|
|
400
|
+
arkModel =
|
|
401
|
+
(_r = (_m = (_k = (_j = (_h = (_g = (_f = (_e = (_d = ModelUtils.getDefaultClass(arkClass)) === null || _d === void 0 ? void 0 : _d.getDefaultArkMethod()) === null || _e === void 0 ? void 0 : _e.getBody()) === null || _f === void 0 ? void 0 : _f.getLocals()) === null || _g === void 0 ? void 0 : _g.get(baseName)) !== null && _h !== void 0 ? _h : ModelUtils.getClassWithName(baseName, arkClass)) !== null && _j !== void 0 ? _j : ModelUtils.getNamespaceWithName(baseName, arkClass)) !== null && _k !== void 0 ? _k : (_l = ModelUtils.getDefaultClass(arkClass)) === null || _l === void 0 ? void 0 : _l.getMethodWithName(baseName)) !== null && _m !== void 0 ? _m : (_q = (_p = (_o = ModelUtils.getDefaultClass(arkClass)) === null || _o === void 0 ? void 0 : _o.getDefaultArkMethod()) === null || _p === void 0 ? void 0 : _p.getBody()) === null || _q === void 0 ? void 0 : _q.getAliasTypeByName(baseName)) !== null && _r !== void 0 ? _r : ModelUtils.getArkExportInImportInfoWithName(baseName, arkClass.getDeclaringArkFile());
|
|
399
402
|
if (!arkModel && !arkClass.getDeclaringArkFile().getImportInfoBy(baseName)) {
|
|
400
403
|
arkModel = arkClass.getDeclaringArkFile().getScene().getSdkGlobal(baseName);
|
|
401
404
|
}
|
|
402
405
|
return arkModel;
|
|
403
406
|
}
|
|
407
|
+
static findGlobalRef(refName, method) {
|
|
408
|
+
var _a, _b;
|
|
409
|
+
return ((_b = (_a = this.findDeclaredLocal(new Local_1.Local(refName), method, 1)) !== null && _a !== void 0 ? _a : this.getArkExportInImportInfoWithName(refName, method.getDeclaringArkFile())) !== null && _b !== void 0 ? _b : method.getDeclaringArkFile().getScene().getSdkGlobal(refName));
|
|
410
|
+
}
|
|
404
411
|
static findArkModelByRefName(refName, arkClass) {
|
|
405
412
|
const singleNames = refName.split('.');
|
|
406
413
|
let model = null;
|
|
@@ -484,7 +491,6 @@ exports.ModelUtils = ModelUtils;
|
|
|
484
491
|
ModelUtils.implicitArkUIBuilderMethods = new Set();
|
|
485
492
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
|
|
486
493
|
let moduleMap;
|
|
487
|
-
exports.sdkImportMap = new Map();
|
|
488
494
|
/**
|
|
489
495
|
* find arkFile by from info
|
|
490
496
|
* export xx from '../xx'
|
|
@@ -497,20 +503,21 @@ function getArkFile(im) {
|
|
|
497
503
|
if (!from) {
|
|
498
504
|
return null;
|
|
499
505
|
}
|
|
500
|
-
if (/^([^@]*\/)([^\/]*)$/.test(from)) {
|
|
501
|
-
|
|
502
|
-
|
|
506
|
+
if (/^([^@]*\/)([^\/]*)$/.test(from)) {
|
|
507
|
+
//relative path
|
|
508
|
+
const parentPath = /^\.{1,2}\//.test(from) ? path_1.default.dirname(im.getDeclaringArkFile().getFilePath()) : im.getDeclaringArkFile().getProjectDir();
|
|
503
509
|
const originPath = path_1.default.resolve(parentPath, from);
|
|
504
510
|
return getArkFileFromScene(im, originPath);
|
|
505
511
|
}
|
|
506
|
-
else if (/^@[a-z|\-]+?\//.test(from)) {
|
|
512
|
+
else if (/^@[a-z|\-]+?\//.test(from)) {
|
|
513
|
+
//module path
|
|
507
514
|
const arkFile = getArkFileFromOtherModule(im);
|
|
508
515
|
if (arkFile) {
|
|
509
516
|
return arkFile;
|
|
510
517
|
}
|
|
511
518
|
}
|
|
512
519
|
//sdk path
|
|
513
|
-
const file =
|
|
520
|
+
const file = SdkUtils_1.SdkUtils.getImportSdkFile(from);
|
|
514
521
|
if (file) {
|
|
515
522
|
return file;
|
|
516
523
|
}
|
|
@@ -521,6 +528,7 @@ function getArkFile(im) {
|
|
|
521
528
|
return arkFile;
|
|
522
529
|
}
|
|
523
530
|
}
|
|
531
|
+
return null;
|
|
524
532
|
}
|
|
525
533
|
exports.getArkFile = getArkFile;
|
|
526
534
|
/**
|
|
@@ -546,8 +554,7 @@ function findExportInfo(fromInfo) {
|
|
|
546
554
|
}
|
|
547
555
|
let exportInfo = findExportInfoInfile(fromInfo, file) || null;
|
|
548
556
|
if (exportInfo === null) {
|
|
549
|
-
logger.warn('export info not found, ' + fromInfo.getFrom() + ' in file: '
|
|
550
|
-
+ fromInfo.getDeclaringArkFile().getFileSignature().toString());
|
|
557
|
+
logger.warn('export info not found, ' + fromInfo.getFrom() + ' in file: ' + fromInfo.getDeclaringArkFile().getFileSignature().toString());
|
|
551
558
|
return null;
|
|
552
559
|
}
|
|
553
560
|
const arkExport = findArkExport(exportInfo);
|
|
@@ -559,7 +566,7 @@ function findExportInfo(fromInfo) {
|
|
|
559
566
|
}
|
|
560
567
|
exports.findExportInfo = findExportInfo;
|
|
561
568
|
function findArkExport(exportInfo) {
|
|
562
|
-
var _a, _b, _c, _d;
|
|
569
|
+
var _a, _b, _c, _d, _e, _f;
|
|
563
570
|
if (!exportInfo) {
|
|
564
571
|
return null;
|
|
565
572
|
}
|
|
@@ -569,11 +576,12 @@ function findArkExport(exportInfo) {
|
|
|
569
576
|
}
|
|
570
577
|
if (!exportInfo.getFrom()) {
|
|
571
578
|
const name = exportInfo.getOriginName();
|
|
579
|
+
const defaultClass = (_b = (_a = exportInfo.getDeclaringArkNamespace()) === null || _a === void 0 ? void 0 : _a.getDefaultClass()) !== null && _b !== void 0 ? _b : exportInfo.getDeclaringArkFile().getDefaultClass();
|
|
572
580
|
if (exportInfo.getExportClauseType() === ArkExport_1.ExportType.LOCAL) {
|
|
573
|
-
arkExport = (
|
|
581
|
+
arkExport = (_d = (_c = defaultClass.getDefaultArkMethod()) === null || _c === void 0 ? void 0 : _c.getBody()) === null || _d === void 0 ? void 0 : _d.getExportLocalByName(name);
|
|
574
582
|
}
|
|
575
583
|
else if (exportInfo.getExportClauseType() === ArkExport_1.ExportType.TYPE) {
|
|
576
|
-
arkExport = (
|
|
584
|
+
arkExport = (_f = (_e = defaultClass.getDefaultArkMethod()) === null || _e === void 0 ? void 0 : _e.getBody()) === null || _f === void 0 ? void 0 : _f.getAliasTypeByName(name);
|
|
577
585
|
}
|
|
578
586
|
else {
|
|
579
587
|
arkExport = findArkExportInFile(name, exportInfo.getDeclaringArkFile());
|
|
@@ -585,7 +593,10 @@ function findArkExport(exportInfo) {
|
|
|
585
593
|
arkExport = result.getArkExport() || null;
|
|
586
594
|
}
|
|
587
595
|
}
|
|
588
|
-
if (
|
|
596
|
+
if (arkExport) {
|
|
597
|
+
exportInfo.setArkExport(arkExport);
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
589
600
|
logger.warn(`${exportInfo.getExportClauseName()} get arkExport fail from ${exportInfo.getFrom()} at
|
|
590
601
|
${exportInfo.getDeclaringArkFile().getFileSignature().toString()}`);
|
|
591
602
|
}
|
|
@@ -594,7 +605,7 @@ function findArkExport(exportInfo) {
|
|
|
594
605
|
exports.findArkExport = findArkExport;
|
|
595
606
|
function findArkExportInFile(name, declaringArkFile) {
|
|
596
607
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
597
|
-
let arkExport = (_f = (_e = (_d = (_a = declaringArkFile.getNamespaceWithName(name)) !== null && _a !== void 0 ? _a : (_c = (_b = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _b === void 0 ? void 0 : _b.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeByName(name)) !== null && _d !== void 0 ? _d : declaringArkFile.getClassWithName(name)) !== null && _e !== void 0 ? _e : declaringArkFile.getDefaultClass().getMethodWithName(name)) !== null && _f !== void 0 ? _f : (_h = (_g = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.
|
|
608
|
+
let arkExport = (_f = (_e = (_d = (_a = declaringArkFile.getNamespaceWithName(name)) !== null && _a !== void 0 ? _a : (_c = (_b = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _b === void 0 ? void 0 : _b.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeByName(name)) !== null && _d !== void 0 ? _d : declaringArkFile.getClassWithName(name)) !== null && _e !== void 0 ? _e : declaringArkFile.getDefaultClass().getMethodWithName(name)) !== null && _f !== void 0 ? _f : (_h = (_g = declaringArkFile.getDefaultClass().getDefaultArkMethod()) === null || _g === void 0 ? void 0 : _g.getBody()) === null || _h === void 0 ? void 0 : _h.getExportLocalByName(name);
|
|
598
609
|
if (!arkExport) {
|
|
599
610
|
const importInfo = declaringArkFile.getImportInfoBy(name);
|
|
600
611
|
if (importInfo) {
|
|
@@ -661,8 +672,7 @@ function findExportInfoInfile(fromInfo, file) {
|
|
|
661
672
|
file.addExportInfo(exportInfo, TSConst_1.ALL);
|
|
662
673
|
}
|
|
663
674
|
else if (/\.d\.e?ts$/.test(file.getName())) {
|
|
664
|
-
let declare = exportName === TSConst_1.DEFAULT ? undefined
|
|
665
|
-
: findArkExportInFile(fromInfo.getOriginName(), file) || undefined;
|
|
675
|
+
let declare = exportName === TSConst_1.DEFAULT ? undefined : findArkExportInFile(fromInfo.getOriginName(), file) || undefined;
|
|
666
676
|
exportInfo = (0, ArkExportBuilder_1.buildDefaultExportInfo)(fromInfo, file, declare);
|
|
667
677
|
}
|
|
668
678
|
return exportInfo;
|
|
@@ -676,7 +686,7 @@ function initModulePathMap(ohPkgContentMap) {
|
|
|
676
686
|
exports.initModulePathMap = initModulePathMap;
|
|
677
687
|
function getArkFileFromOtherModule(fromInfo) {
|
|
678
688
|
if (!moduleMap || moduleMap.size === 0) {
|
|
679
|
-
return;
|
|
689
|
+
return undefined;
|
|
680
690
|
}
|
|
681
691
|
const from = fromInfo.getFrom();
|
|
682
692
|
let index;
|
|
@@ -710,7 +720,7 @@ function getArkFileFromOtherModule(fromInfo) {
|
|
|
710
720
|
}
|
|
711
721
|
function findFileInModule(fromInfo, modulePath, contentPath) {
|
|
712
722
|
if (!modulePath) {
|
|
713
|
-
return;
|
|
723
|
+
return undefined;
|
|
714
724
|
}
|
|
715
725
|
const originPath = path_1.default.join(modulePath.path, contentPath);
|
|
716
726
|
let file;
|
|
@@ -720,4 +730,5 @@ function findFileInModule(fromInfo, modulePath, contentPath) {
|
|
|
720
730
|
if (file && findExportInfoInfile(fromInfo, file)) {
|
|
721
731
|
return file;
|
|
722
732
|
}
|
|
733
|
+
return undefined;
|
|
723
734
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 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
|
|
@@ -3,6 +3,9 @@ import { ArkExport } from '../model/ArkExport';
|
|
|
3
3
|
import { ArkMethod } from '../model/ArkMethod';
|
|
4
4
|
import { AbstractFieldRef } from '../base/Ref';
|
|
5
5
|
export declare class SdkUtils {
|
|
6
|
+
private static sdkImportMap;
|
|
7
|
+
static buildSdkImportMap(file: ArkFile): void;
|
|
8
|
+
static getImportSdkFile(from: string): ArkFile | undefined;
|
|
6
9
|
static buildGlobalMap(file: ArkFile, globalMap: Map<string, ArkExport>): void;
|
|
7
10
|
private static loadClass;
|
|
8
11
|
private static loadGlobalLocal;
|
|
@@ -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,EAAc,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
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,EAAc,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,qBAAa,QAAQ;IAEjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoD;WAEjE,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;WAOtC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;WAInD,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAsCpF,OAAO,CAAC,MAAM,CAAC,SAAS;IAexB,OAAO,CAAC,MAAM,CAAC,eAAe;IA8B9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAYX,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;CAUxF"}
|