arkanalyzer 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.en.md +88 -0
- package/README.md +98 -0
- package/docs/HowToCreatePR.md +55 -0
- package/docs/HowToHandleIssues.md +155 -0
- package/docs/quickstart.pdf +0 -0
- package/lib/Config.d.ts +26 -0
- package/lib/Config.d.ts.map +1 -0
- package/lib/Config.js +128 -0
- package/lib/Scene.d.ts +125 -0
- package/lib/Scene.d.ts.map +1 -0
- package/lib/Scene.js +762 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +28 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/AbstractAnalysis.js +137 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts +11 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +71 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts +16 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -0
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +147 -0
- package/lib/callgraph/common/Statistics.d.ts +58 -0
- package/lib/callgraph/common/Statistics.d.ts.map +1 -0
- package/lib/callgraph/common/Statistics.js +203 -0
- package/lib/callgraph/model/BaseGraph.d.ts +62 -0
- package/lib/callgraph/model/BaseGraph.d.ts.map +1 -0
- package/lib/callgraph/model/BaseGraph.js +158 -0
- package/lib/callgraph/model/CallGraph.d.ts +94 -0
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -0
- package/lib/callgraph/model/CallGraph.js +339 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +16 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts.map +1 -0
- package/lib/callgraph/model/builder/CallGraphBuilder.js +106 -0
- package/lib/callgraph/pointerAnalysis/Context.d.ts +38 -0
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/Context.js +156 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts +23 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/DummyCallCreator.js +104 -0
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +209 -0
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/Pag.js +774 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +88 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +821 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +64 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +502 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts +9 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysisConfig.js +57 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts +58 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -0
- package/lib/callgraph/pointerAnalysis/PtsDS.js +234 -0
- package/lib/core/base/Constant.d.ts +17 -0
- package/lib/core/base/Constant.d.ts.map +1 -0
- package/lib/core/base/Constant.js +53 -0
- package/lib/core/base/Decorator.d.ts +15 -0
- package/lib/core/base/Decorator.d.ts.map +1 -0
- package/lib/core/base/Decorator.js +43 -0
- package/lib/core/base/DefUseChain.d.ts +9 -0
- package/lib/core/base/DefUseChain.d.ts.map +1 -0
- package/lib/core/base/DefUseChain.js +25 -0
- package/lib/core/base/Expr.d.ts +219 -0
- package/lib/core/base/Expr.d.ts.map +1 -0
- package/lib/core/base/Expr.js +896 -0
- package/lib/core/base/Local.d.ts +40 -0
- package/lib/core/base/Local.d.ts.map +1 -0
- package/lib/core/base/Local.js +101 -0
- package/lib/core/base/Position.d.ts +39 -0
- package/lib/core/base/Position.d.ts.map +1 -0
- package/lib/core/base/Position.js +86 -0
- package/lib/core/base/Ref.d.ts +75 -0
- package/lib/core/base/Ref.d.ts.map +1 -0
- package/lib/core/base/Ref.js +286 -0
- package/lib/core/base/Stmt.d.ts +109 -0
- package/lib/core/base/Stmt.d.ts.map +1 -0
- package/lib/core/base/Stmt.js +374 -0
- package/lib/core/base/Type.d.ts +220 -0
- package/lib/core/base/Type.d.ts.map +1 -0
- package/lib/core/base/Type.js +477 -0
- package/lib/core/base/Value.d.ts +11 -0
- package/lib/core/base/Value.d.ts.map +1 -0
- package/lib/core/base/Value.js +16 -0
- package/lib/core/common/ArkIRTransformer.d.ts +101 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -0
- package/lib/core/common/ArkIRTransformer.js +1674 -0
- package/lib/core/common/BodyBuilder.d.ts +10 -0
- package/lib/core/common/BodyBuilder.d.ts.map +1 -0
- package/lib/core/common/BodyBuilder.js +34 -0
- package/lib/core/common/Builtin.d.ts +35 -0
- package/lib/core/common/Builtin.d.ts.map +1 -0
- package/lib/core/common/Builtin.js +78 -0
- package/lib/core/common/CfgBuilder.d.ts +136 -0
- package/lib/core/common/CfgBuilder.d.ts.map +1 -0
- package/lib/core/common/CfgBuilder.js +1241 -0
- package/lib/core/common/Const.d.ts +15 -0
- package/lib/core/common/Const.d.ts.map +1 -0
- package/lib/core/common/Const.js +34 -0
- package/lib/core/common/DummyMainCreater.d.ts +48 -0
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -0
- package/lib/core/common/DummyMainCreater.js +433 -0
- package/lib/core/common/EtsConst.d.ts +65 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -0
- package/lib/core/common/EtsConst.js +918 -0
- package/lib/core/common/ExprUseReplacer.d.ts +18 -0
- package/lib/core/common/ExprUseReplacer.d.ts.map +1 -0
- package/lib/core/common/ExprUseReplacer.js +88 -0
- package/lib/core/common/IRUtils.d.ts +7 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -0
- package/lib/core/common/IRUtils.js +39 -0
- package/lib/core/common/ModelUtils.d.ts +61 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -0
- package/lib/core/common/ModelUtils.js +628 -0
- package/lib/core/common/RefUseReplacer.d.ts +14 -0
- package/lib/core/common/RefUseReplacer.d.ts.map +1 -0
- package/lib/core/common/RefUseReplacer.js +50 -0
- package/lib/core/common/StmtUseReplacer.d.ts +16 -0
- package/lib/core/common/StmtUseReplacer.d.ts.map +1 -0
- package/lib/core/common/StmtUseReplacer.js +88 -0
- package/lib/core/common/TSConst.d.ts +11 -0
- package/lib/core/common/TSConst.d.ts.map +1 -0
- package/lib/core/common/TSConst.js +28 -0
- package/lib/core/common/TypeInference.d.ts +44 -0
- package/lib/core/common/TypeInference.d.ts.map +1 -0
- package/lib/core/common/TypeInference.js +519 -0
- package/lib/core/common/ValueUtil.d.ts +17 -0
- package/lib/core/common/ValueUtil.d.ts.map +1 -0
- package/lib/core/common/ValueUtil.js +71 -0
- package/lib/core/common/VisibleValue.d.ts +37 -0
- package/lib/core/common/VisibleValue.d.ts.map +1 -0
- package/lib/core/common/VisibleValue.js +212 -0
- package/lib/core/dataflow/DataflowProblem.d.ts +21 -0
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowProblem.js +33 -0
- package/lib/core/dataflow/DataflowResult.d.ts +8 -0
- package/lib/core/dataflow/DataflowResult.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowResult.js +26 -0
- package/lib/core/dataflow/DataflowSolver.d.ts +40 -0
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -0
- package/lib/core/dataflow/DataflowSolver.js +318 -0
- package/lib/core/dataflow/Edge.d.ts +16 -0
- package/lib/core/dataflow/Edge.d.ts.map +1 -0
- package/lib/core/dataflow/Edge.js +40 -0
- package/lib/core/dataflow/Fact.d.ts +7 -0
- package/lib/core/dataflow/Fact.d.ts.map +1 -0
- package/lib/core/dataflow/Fact.js +24 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts +37 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -0
- package/lib/core/dataflow/TiantAnalysis.js +326 -0
- package/lib/core/dataflow/UndefinedVariable.d.ts +32 -0
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -0
- package/lib/core/dataflow/UndefinedVariable.js +235 -0
- package/lib/core/dataflow/Util.d.ts +8 -0
- package/lib/core/dataflow/Util.d.ts.map +1 -0
- package/lib/core/dataflow/Util.js +137 -0
- package/lib/core/graph/BasicBlock.d.ts +26 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -0
- package/lib/core/graph/BasicBlock.js +92 -0
- package/lib/core/graph/Cfg.d.ts +29 -0
- package/lib/core/graph/Cfg.d.ts.map +1 -0
- package/lib/core/graph/Cfg.js +154 -0
- package/lib/core/graph/DominanceFinder.d.ts +16 -0
- package/lib/core/graph/DominanceFinder.d.ts.map +1 -0
- package/lib/core/graph/DominanceFinder.js +121 -0
- package/lib/core/graph/DominanceTree.d.ts +13 -0
- package/lib/core/graph/DominanceTree.d.ts.map +1 -0
- package/lib/core/graph/DominanceTree.js +70 -0
- package/lib/core/graph/ViewTree.d.ts +115 -0
- package/lib/core/graph/ViewTree.d.ts.map +1 -0
- package/lib/core/graph/ViewTree.js +16 -0
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts +204 -0
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/ViewTreeBuilder.js +1046 -0
- package/lib/core/model/ArkBody.d.ts +22 -0
- package/lib/core/model/ArkBody.d.ts.map +1 -0
- package/lib/core/model/ArkBody.js +63 -0
- package/lib/core/model/ArkClass.d.ts +110 -0
- package/lib/core/model/ArkClass.d.ts.map +1 -0
- package/lib/core/model/ArkClass.js +315 -0
- package/lib/core/model/ArkExport.d.ts +70 -0
- package/lib/core/model/ArkExport.d.ts.map +1 -0
- package/lib/core/model/ArkExport.js +143 -0
- package/lib/core/model/ArkField.d.ts +60 -0
- package/lib/core/model/ArkField.d.ts.map +1 -0
- package/lib/core/model/ArkField.js +157 -0
- package/lib/core/model/ArkFile.d.ts +62 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -0
- package/lib/core/model/ArkFile.js +160 -0
- package/lib/core/model/ArkImport.d.ts +43 -0
- package/lib/core/model/ArkImport.d.ts.map +1 -0
- package/lib/core/model/ArkImport.js +109 -0
- package/lib/core/model/ArkMethod.d.ts +76 -0
- package/lib/core/model/ArkMethod.d.ts.map +1 -0
- package/lib/core/model/ArkMethod.js +235 -0
- package/lib/core/model/ArkNamespace.d.ts +65 -0
- package/lib/core/model/ArkNamespace.d.ts.map +1 -0
- package/lib/core/model/ArkNamespace.js +182 -0
- package/lib/core/model/ArkSignature.d.ts +98 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -0
- package/lib/core/model/ArkSignature.js +281 -0
- package/lib/core/model/builder/ArkClassBuilder.d.ts +13 -0
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkClassBuilder.js +422 -0
- package/lib/core/model/builder/ArkExportBuilder.d.ts +25 -0
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkExportBuilder.js +207 -0
- package/lib/core/model/builder/ArkFieldBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkFieldBuilder.js +189 -0
- package/lib/core/model/builder/ArkFileBuilder.d.ts +10 -0
- package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkFileBuilder.js +164 -0
- package/lib/core/model/builder/ArkImportBuilder.d.ts +4 -0
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkImportBuilder.js +125 -0
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +60 -0
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkMethodBuilder.js +419 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +5 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkNamespaceBuilder.js +171 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
- package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -0
- package/lib/core/model/builder/ArkSignatureBuilder.js +40 -0
- package/lib/core/model/builder/builderUtils.d.ts +18 -0
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -0
- package/lib/core/model/builder/builderUtils.js +449 -0
- package/lib/index.d.ts +77 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +190 -0
- package/lib/save/ArkStream.d.ts +24 -0
- package/lib/save/ArkStream.d.ts.map +1 -0
- package/lib/save/ArkStream.js +83 -0
- package/lib/save/DotPrinter.d.ts +48 -0
- package/lib/save/DotPrinter.d.ts.map +1 -0
- package/lib/save/DotPrinter.js +229 -0
- package/lib/save/GraphPrinter.d.ts +17 -0
- package/lib/save/GraphPrinter.d.ts.map +1 -0
- package/lib/save/GraphPrinter.js +135 -0
- package/lib/save/JsonPrinter.d.ts +28 -0
- package/lib/save/JsonPrinter.d.ts.map +1 -0
- package/lib/save/JsonPrinter.js +511 -0
- package/lib/save/Printer.d.ts +17 -0
- package/lib/save/Printer.d.ts.map +1 -0
- package/lib/save/Printer.js +27 -0
- package/lib/save/PrinterBuilder.d.ts +38 -0
- package/lib/save/PrinterBuilder.d.ts.map +1 -0
- package/lib/save/PrinterBuilder.js +102 -0
- package/lib/save/serializeArkIR.d.ts +3 -0
- package/lib/save/serializeArkIR.d.ts.map +1 -0
- package/lib/save/serializeArkIR.js +166 -0
- package/lib/save/source/SourceBase.d.ts +32 -0
- package/lib/save/source/SourceBase.d.ts.map +1 -0
- package/lib/save/source/SourceBase.js +93 -0
- package/lib/save/source/SourceBody.d.ts +60 -0
- package/lib/save/source/SourceBody.d.ts.map +1 -0
- package/lib/save/source/SourceBody.js +292 -0
- package/lib/save/source/SourceClass.d.ts +27 -0
- package/lib/save/source/SourceClass.d.ts.map +1 -0
- package/lib/save/source/SourceClass.js +202 -0
- package/lib/save/source/SourceField.d.ts +15 -0
- package/lib/save/source/SourceField.d.ts.map +1 -0
- package/lib/save/source/SourceField.js +68 -0
- package/lib/save/source/SourceFilePrinter.d.ts +14 -0
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -0
- package/lib/save/source/SourceFilePrinter.js +73 -0
- package/lib/save/source/SourceMethod.d.ts +24 -0
- package/lib/save/source/SourceMethod.d.ts.map +1 -0
- package/lib/save/source/SourceMethod.js +170 -0
- package/lib/save/source/SourceModule.d.ts +18 -0
- package/lib/save/source/SourceModule.d.ts.map +1 -0
- package/lib/save/source/SourceModule.js +120 -0
- package/lib/save/source/SourceNamespace.d.ts +13 -0
- package/lib/save/source/SourceNamespace.d.ts.map +1 -0
- package/lib/save/source/SourceNamespace.js +80 -0
- package/lib/save/source/SourceStmt.d.ts +172 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -0
- package/lib/save/source/SourceStmt.js +757 -0
- package/lib/save/source/SourceTransformer.d.ts +37 -0
- package/lib/save/source/SourceTransformer.d.ts.map +1 -0
- package/lib/save/source/SourceTransformer.js +338 -0
- package/lib/save/source/SourceUtils.d.ts +25 -0
- package/lib/save/source/SourceUtils.d.ts.map +1 -0
- package/lib/save/source/SourceUtils.js +201 -0
- package/lib/transformer/FunctionTransformer.d.ts +3 -0
- package/lib/transformer/FunctionTransformer.d.ts.map +1 -0
- package/lib/transformer/FunctionTransformer.js +17 -0
- package/lib/transformer/SceneTransformer.d.ts +3 -0
- package/lib/transformer/SceneTransformer.d.ts.map +1 -0
- package/lib/transformer/SceneTransformer.js +17 -0
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts +13 -0
- package/lib/transformer/StaticSingleAssignmentFormer.d.ts.map +1 -0
- package/lib/transformer/StaticSingleAssignmentFormer.js +259 -0
- package/lib/transformer/Transformer.d.ts +7 -0
- package/lib/transformer/Transformer.d.ts.map +1 -0
- package/lib/transformer/Transformer.js +22 -0
- package/lib/utils/CfgStructualAnalysis.d.ts +93 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -0
- package/lib/utils/CfgStructualAnalysis.js +955 -0
- package/lib/utils/FileUtils.d.ts +18 -0
- package/lib/utils/FileUtils.d.ts.map +1 -0
- package/lib/utils/FileUtils.js +131 -0
- package/lib/utils/callGraphUtils.d.ts +31 -0
- package/lib/utils/callGraphUtils.d.ts.map +1 -0
- package/lib/utils/callGraphUtils.js +208 -0
- package/lib/utils/entryMethodUtils.d.ts +16 -0
- package/lib/utils/entryMethodUtils.d.ts.map +1 -0
- package/lib/utils/entryMethodUtils.js +139 -0
- package/lib/utils/getAllFiles.d.ts +10 -0
- package/lib/utils/getAllFiles.d.ts.map +1 -0
- package/lib/utils/getAllFiles.js +91 -0
- package/lib/utils/json5parser.d.ts +7 -0
- package/lib/utils/json5parser.d.ts.map +1 -0
- package/lib/utils/json5parser.js +146 -0
- package/lib/utils/logger.d.ts +19 -0
- package/lib/utils/logger.d.ts.map +1 -0
- package/lib/utils/logger.js +90 -0
- package/lib/utils/pathTransfer.d.ts +2 -0
- package/lib/utils/pathTransfer.d.ts.map +1 -0
- package/lib/utils/pathTransfer.js +25 -0
- package/package.json +29 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.buildGetAccessor2ArkField = exports.buildIndexSignature2ArkField = exports.buildProperty2ArkField = void 0;
|
|
44
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
45
|
+
const ArkField_1 = require("../ArkField");
|
|
46
|
+
const logger_1 = __importStar(require("../../../utils/logger"));
|
|
47
|
+
const builderUtils_1 = require("./builderUtils");
|
|
48
|
+
const ArkSignature_1 = require("../ArkSignature");
|
|
49
|
+
const Type_1 = require("../../base/Type");
|
|
50
|
+
const Position_1 = require("../../base/Position");
|
|
51
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkFieldBuilder');
|
|
52
|
+
function buildProperty2ArkField(member, sourceFile, cls) {
|
|
53
|
+
let field = new ArkField_1.ArkField();
|
|
54
|
+
field.setCategory(mapSyntaxKindToFieldOriginType(member.kind));
|
|
55
|
+
field.setCode(member.getText(sourceFile));
|
|
56
|
+
field.setDeclaringArkClass(cls);
|
|
57
|
+
field.setOriginPosition(Position_1.LineColPosition.buildFromNode(member, sourceFile));
|
|
58
|
+
let fieldName = member.getText(sourceFile);
|
|
59
|
+
if (member.name && ohos_typescript_1.default.isComputedPropertyName(member.name)) {
|
|
60
|
+
if (ohos_typescript_1.default.isIdentifier(member.name.expression)) {
|
|
61
|
+
fieldName = member.name.expression.text;
|
|
62
|
+
}
|
|
63
|
+
else if (ohos_typescript_1.default.isPropertyAccessExpression(member.name.expression)) {
|
|
64
|
+
fieldName = (0, builderUtils_1.handlePropertyAccessExpression)(member.name.expression);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
logger.warn("Other property expression type found!");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (member.name && (ohos_typescript_1.default.isIdentifier(member.name) || ohos_typescript_1.default.isLiteralExpression(member.name))) {
|
|
71
|
+
fieldName = member.name.text;
|
|
72
|
+
}
|
|
73
|
+
else if (member.name && ohos_typescript_1.default.isPrivateIdentifier(member.name)) {
|
|
74
|
+
let propertyName = member.name.text;
|
|
75
|
+
fieldName = propertyName.substring(1);
|
|
76
|
+
field.addModifier(ohos_typescript_1.default.ScriptElementKindModifier.privateMemberModifier);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
logger.warn("Other type of property name found!");
|
|
80
|
+
}
|
|
81
|
+
if ((ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) && member.modifiers) {
|
|
82
|
+
let modifiers = (0, builderUtils_1.buildModifiers)(member, sourceFile);
|
|
83
|
+
modifiers.forEach((modifier) => {
|
|
84
|
+
field.addModifier(modifier);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
let fieldType = Type_1.UnknownType.getInstance();
|
|
88
|
+
if ((ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) && member.type) {
|
|
89
|
+
fieldType = (0, builderUtils_1.buildGenericType)((0, builderUtils_1.tsNode2Type)(member.type, sourceFile, cls), field);
|
|
90
|
+
}
|
|
91
|
+
if (ohos_typescript_1.default.isEnumMember(member)) {
|
|
92
|
+
field.addModifier('StaticKeyword');
|
|
93
|
+
fieldType = new Type_1.ClassType(cls.getSignature());
|
|
94
|
+
}
|
|
95
|
+
const fieldSignature = new ArkSignature_1.FieldSignature(fieldName, cls.getSignature(), fieldType, field.isStatic());
|
|
96
|
+
field.setSignature(fieldSignature);
|
|
97
|
+
if ((ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) && member.questionToken) {
|
|
98
|
+
field.setQuestionToken(true);
|
|
99
|
+
}
|
|
100
|
+
if (ohos_typescript_1.default.isPropertyDeclaration(member) && member.exclamationToken) {
|
|
101
|
+
field.setExclamationToken(true);
|
|
102
|
+
}
|
|
103
|
+
cls.addField(field);
|
|
104
|
+
return field;
|
|
105
|
+
}
|
|
106
|
+
exports.buildProperty2ArkField = buildProperty2ArkField;
|
|
107
|
+
function buildIndexSignature2ArkField(member, sourceFile, cls) {
|
|
108
|
+
const field = new ArkField_1.ArkField();
|
|
109
|
+
field.setCode(member.getText(sourceFile));
|
|
110
|
+
field.setCategory(mapSyntaxKindToFieldOriginType(member.kind));
|
|
111
|
+
field.setDeclaringArkClass(cls);
|
|
112
|
+
field.setOriginPosition(Position_1.LineColPosition.buildFromNode(member, sourceFile));
|
|
113
|
+
if (member.modifiers) {
|
|
114
|
+
(0, builderUtils_1.buildModifiers)(member, sourceFile).forEach((modifier) => {
|
|
115
|
+
field.addModifier(modifier);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const fieldName = '[' + member.parameters[0].getText(sourceFile) + ']';
|
|
119
|
+
const fieldType = (0, builderUtils_1.buildGenericType)((0, builderUtils_1.tsNode2Type)(member.type, sourceFile, field), field);
|
|
120
|
+
const fieldSignature = new ArkSignature_1.FieldSignature(fieldName, cls.getSignature(), fieldType, true);
|
|
121
|
+
field.setSignature(fieldSignature);
|
|
122
|
+
cls.addField(field);
|
|
123
|
+
}
|
|
124
|
+
exports.buildIndexSignature2ArkField = buildIndexSignature2ArkField;
|
|
125
|
+
function buildGetAccessor2ArkField(member, mthd, sourceFile) {
|
|
126
|
+
let cls = mthd.getDeclaringArkClass();
|
|
127
|
+
let field = new ArkField_1.ArkField();
|
|
128
|
+
field.setDeclaringArkClass(cls);
|
|
129
|
+
field.setCode(member.getText(sourceFile));
|
|
130
|
+
field.setCategory(mapSyntaxKindToFieldOriginType(member.kind));
|
|
131
|
+
field.setOriginPosition(Position_1.LineColPosition.buildFromNode(member, sourceFile));
|
|
132
|
+
let fieldName = member.getText(sourceFile);
|
|
133
|
+
if (ohos_typescript_1.default.isIdentifier(member.name) || ohos_typescript_1.default.isLiteralExpression(member.name)) {
|
|
134
|
+
fieldName = member.name.text;
|
|
135
|
+
}
|
|
136
|
+
else if (ohos_typescript_1.default.isComputedPropertyName(member.name)) {
|
|
137
|
+
if (ohos_typescript_1.default.isIdentifier(member.name.expression)) {
|
|
138
|
+
let propertyName = member.name.expression.text;
|
|
139
|
+
fieldName = propertyName;
|
|
140
|
+
}
|
|
141
|
+
else if (ohos_typescript_1.default.isPropertyAccessExpression(member.name.expression)) {
|
|
142
|
+
fieldName = (0, builderUtils_1.handlePropertyAccessExpression)(member.name.expression);
|
|
143
|
+
}
|
|
144
|
+
else if (ohos_typescript_1.default.isLiteralExpression(member.name.expression)) {
|
|
145
|
+
fieldName = member.name.expression.text;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
logger.warn("Other type of computed property name found!");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
logger.warn("Please contact developers to support new type of GetAccessor name!");
|
|
153
|
+
}
|
|
154
|
+
const fieldType = mthd.getReturnType();
|
|
155
|
+
const fieldSignature = new ArkSignature_1.FieldSignature(fieldName, cls.getSignature(), fieldType, false);
|
|
156
|
+
field.setSignature(fieldSignature);
|
|
157
|
+
cls.addField(field);
|
|
158
|
+
}
|
|
159
|
+
exports.buildGetAccessor2ArkField = buildGetAccessor2ArkField;
|
|
160
|
+
function mapSyntaxKindToFieldOriginType(syntaxKind) {
|
|
161
|
+
let fieldOriginType = null;
|
|
162
|
+
switch (syntaxKind) {
|
|
163
|
+
case ohos_typescript_1.default.SyntaxKind.PropertyDeclaration:
|
|
164
|
+
fieldOriginType = ArkField_1.FieldCategory.PROPERTY_DECLARATION;
|
|
165
|
+
break;
|
|
166
|
+
case ohos_typescript_1.default.SyntaxKind.PropertyAssignment:
|
|
167
|
+
fieldOriginType = ArkField_1.FieldCategory.PROPERTY_ASSIGNMENT;
|
|
168
|
+
break;
|
|
169
|
+
case ohos_typescript_1.default.SyntaxKind.ShorthandPropertyAssignment:
|
|
170
|
+
fieldOriginType = ArkField_1.FieldCategory.SHORT_HAND_PROPERTY_ASSIGNMENT;
|
|
171
|
+
break;
|
|
172
|
+
case ohos_typescript_1.default.SyntaxKind.SpreadAssignment:
|
|
173
|
+
fieldOriginType = ArkField_1.FieldCategory.SPREAD_ASSIGNMENT;
|
|
174
|
+
break;
|
|
175
|
+
case ohos_typescript_1.default.SyntaxKind.PropertySignature:
|
|
176
|
+
fieldOriginType = ArkField_1.FieldCategory.PROPERTY_SIGNATURE;
|
|
177
|
+
break;
|
|
178
|
+
case ohos_typescript_1.default.SyntaxKind.EnumMember:
|
|
179
|
+
fieldOriginType = ArkField_1.FieldCategory.ENUM_MEMBER;
|
|
180
|
+
break;
|
|
181
|
+
case ohos_typescript_1.default.SyntaxKind.IndexSignature:
|
|
182
|
+
fieldOriginType = ArkField_1.FieldCategory.INDEX_SIGNATURE;
|
|
183
|
+
break;
|
|
184
|
+
case ohos_typescript_1.default.SyntaxKind.GetAccessor:
|
|
185
|
+
fieldOriginType = ArkField_1.FieldCategory.GET_ACCESSOR;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
return fieldOriginType;
|
|
189
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArkFile } from '../ArkFile';
|
|
2
|
+
export declare const notStmtOrExprKind: string[];
|
|
3
|
+
/**
|
|
4
|
+
* Entry of building ArkFile instance
|
|
5
|
+
*
|
|
6
|
+
* @param arkFile
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildArkFileFromFile(absoluteFilePath: string, projectDir: string, arkFile: ArkFile, projectName: string): void;
|
|
10
|
+
//# sourceMappingURL=ArkFileBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArkFileBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkFileBuilder.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAuBrC,eAAO,MAAM,iBAAiB,UAEqD,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAC9D,WAAW,EAAE,MAAM,QAkBvD"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.buildArkFileFromFile = exports.notStmtOrExprKind = void 0;
|
|
44
|
+
const fs_1 = __importDefault(require("fs"));
|
|
45
|
+
const path_1 = __importDefault(require("path"));
|
|
46
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
47
|
+
const ArkNamespace_1 = require("../ArkNamespace");
|
|
48
|
+
const logger_1 = __importStar(require("../../../utils/logger"));
|
|
49
|
+
const ArkClassBuilder_1 = require("./ArkClassBuilder");
|
|
50
|
+
const ArkMethodBuilder_1 = require("./ArkMethodBuilder");
|
|
51
|
+
const ArkImportBuilder_1 = require("./ArkImportBuilder");
|
|
52
|
+
const ArkExportBuilder_1 = require("./ArkExportBuilder");
|
|
53
|
+
const ArkNamespaceBuilder_1 = require("./ArkNamespaceBuilder");
|
|
54
|
+
const ArkClass_1 = require("../ArkClass");
|
|
55
|
+
const ArkMethod_1 = require("../ArkMethod");
|
|
56
|
+
const Position_1 = require("../../base/Position");
|
|
57
|
+
const EtsConst_1 = require("../../common/EtsConst");
|
|
58
|
+
const ArkSignature_1 = require("../ArkSignature");
|
|
59
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkFileBuilder');
|
|
60
|
+
exports.notStmtOrExprKind = ['ModuleDeclaration', 'ClassDeclaration', 'InterfaceDeclaration', 'EnumDeclaration', 'ExportDeclaration',
|
|
61
|
+
'ExportAssignment', 'MethodDeclaration', 'Constructor', 'FunctionDeclaration', 'GetAccessor', 'SetAccessor', 'ArrowFunction',
|
|
62
|
+
'FunctionExpression', 'MethodSignature', 'ConstructSignature', 'CallSignature'];
|
|
63
|
+
/**
|
|
64
|
+
* Entry of building ArkFile instance
|
|
65
|
+
*
|
|
66
|
+
* @param arkFile
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function buildArkFileFromFile(absoluteFilePath, projectDir, arkFile, projectName) {
|
|
70
|
+
arkFile.setFilePath(absoluteFilePath);
|
|
71
|
+
arkFile.setProjectDir(projectDir);
|
|
72
|
+
const fileSignature = new ArkSignature_1.FileSignature(projectName, path_1.default.relative(projectDir, absoluteFilePath));
|
|
73
|
+
arkFile.setFileSignature(fileSignature);
|
|
74
|
+
arkFile.setCode(fs_1.default.readFileSync(arkFile.getFilePath(), 'utf8'));
|
|
75
|
+
const sourceFile = ohos_typescript_1.default.createSourceFile(arkFile.getName(), arkFile.getCode(), ohos_typescript_1.default.ScriptTarget.Latest, true, undefined, EtsConst_1.ETS_COMPILER_OPTIONS);
|
|
76
|
+
genDefaultArkClass(arkFile, sourceFile);
|
|
77
|
+
buildArkFile(arkFile, sourceFile);
|
|
78
|
+
}
|
|
79
|
+
exports.buildArkFileFromFile = buildArkFileFromFile;
|
|
80
|
+
/**
|
|
81
|
+
* Building ArkFile instance
|
|
82
|
+
*
|
|
83
|
+
* @param arkFile
|
|
84
|
+
* @param astRoot
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
function buildArkFile(arkFile, astRoot) {
|
|
88
|
+
const statements = astRoot.statements;
|
|
89
|
+
statements.forEach((child) => {
|
|
90
|
+
if (ohos_typescript_1.default.isModuleDeclaration(child)
|
|
91
|
+
//child.kind === ts.SyntaxKind.ModuleDeclaration
|
|
92
|
+
) {
|
|
93
|
+
let ns = new ArkNamespace_1.ArkNamespace();
|
|
94
|
+
ns.setDeclaringArkFile(arkFile);
|
|
95
|
+
(0, ArkNamespaceBuilder_1.buildArkNamespace)(child, arkFile, ns, astRoot);
|
|
96
|
+
arkFile.addNamespace(ns);
|
|
97
|
+
if (ns.isExported()) {
|
|
98
|
+
arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(ns, arkFile, Position_1.LineColPosition.buildFromNode(child, astRoot)));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (ohos_typescript_1.default.isClassDeclaration(child) ||
|
|
102
|
+
ohos_typescript_1.default.isInterfaceDeclaration(child) ||
|
|
103
|
+
ohos_typescript_1.default.isEnumDeclaration(child) ||
|
|
104
|
+
ohos_typescript_1.default.isStructDeclaration(child)
|
|
105
|
+
//child.kind === ts.SyntaxKind.ClassDeclaration
|
|
106
|
+
//child.kind === ts.SyntaxKind.InterfaceDeclaration
|
|
107
|
+
//child.kind === ts.SyntaxKind.EnumDeclaration
|
|
108
|
+
) {
|
|
109
|
+
let cls = new ArkClass_1.ArkClass();
|
|
110
|
+
(0, ArkClassBuilder_1.buildNormalArkClassFromArkFile)(child, arkFile, cls, astRoot);
|
|
111
|
+
arkFile.addArkClass(cls);
|
|
112
|
+
if (cls.isExported()) {
|
|
113
|
+
arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(cls, arkFile, Position_1.LineColPosition.buildFromNode(child, astRoot)));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// TODO: Check
|
|
117
|
+
else if (ohos_typescript_1.default.isMethodDeclaration(child)) {
|
|
118
|
+
logger.warn("This is a MethodDeclaration in ArkFile.");
|
|
119
|
+
let mthd = new ArkMethod_1.ArkMethod();
|
|
120
|
+
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, arkFile.getDefaultClass(), mthd, astRoot);
|
|
121
|
+
arkFile.getDefaultClass().addMethod(mthd);
|
|
122
|
+
if (mthd.isExported()) {
|
|
123
|
+
arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(mthd, arkFile, Position_1.LineColPosition.buildFromNode(child, astRoot)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (ohos_typescript_1.default.isFunctionDeclaration(child)) {
|
|
127
|
+
let mthd = new ArkMethod_1.ArkMethod();
|
|
128
|
+
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, arkFile.getDefaultClass(), mthd, astRoot);
|
|
129
|
+
arkFile.getDefaultClass().addMethod(mthd);
|
|
130
|
+
if (mthd.isExported()) {
|
|
131
|
+
arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(mthd, arkFile, Position_1.LineColPosition.buildFromNode(child, astRoot)));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (ohos_typescript_1.default.isImportEqualsDeclaration(child) ||
|
|
135
|
+
ohos_typescript_1.default.isImportDeclaration(child)) {
|
|
136
|
+
let importInfos = (0, ArkImportBuilder_1.buildImportInfo)(child, astRoot);
|
|
137
|
+
importInfos === null || importInfos === void 0 ? void 0 : importInfos.forEach((element) => {
|
|
138
|
+
element.setDeclaringArkFile(arkFile);
|
|
139
|
+
arkFile.addImportInfo(element);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else if (ohos_typescript_1.default.isExportDeclaration(child)) {
|
|
143
|
+
(0, ArkExportBuilder_1.buildExportDeclaration)(child, astRoot, arkFile).forEach(item => arkFile.addExportInfo(item));
|
|
144
|
+
}
|
|
145
|
+
else if (ohos_typescript_1.default.isExportAssignment(child)) {
|
|
146
|
+
(0, ArkExportBuilder_1.buildExportAssignment)(child, astRoot, arkFile).forEach(item => arkFile.addExportInfo(item));
|
|
147
|
+
}
|
|
148
|
+
else if (ohos_typescript_1.default.isVariableStatement(child) && (0, ArkExportBuilder_1.isExported)(child.modifiers)) {
|
|
149
|
+
(0, ArkExportBuilder_1.buildExportVariableStatement)(child, astRoot, arkFile).forEach(item => arkFile.addExportInfo(item));
|
|
150
|
+
}
|
|
151
|
+
else if (ohos_typescript_1.default.isTypeAliasDeclaration(child) && (0, ArkExportBuilder_1.isExported)(child.modifiers)) {
|
|
152
|
+
(0, ArkExportBuilder_1.buildExportTypeAliasDeclaration)(child, astRoot, arkFile).forEach(item => arkFile.addExportInfo(item));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
logger.info('Child joined default method of arkFile: ', ohos_typescript_1.default.SyntaxKind[child.kind]);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function genDefaultArkClass(arkFile, astRoot) {
|
|
160
|
+
let defaultClass = new ArkClass_1.ArkClass();
|
|
161
|
+
(0, ArkClassBuilder_1.buildDefaultArkClassFromArkFile)(arkFile, defaultClass, astRoot);
|
|
162
|
+
arkFile.setDefaultClass(defaultClass);
|
|
163
|
+
arkFile.addArkClass(defaultClass);
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArkImportBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkImportBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,wBAAgB,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,uBAAuB,GAAG,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,UAAU,EAAE,CAOhI"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.buildImportInfo = void 0;
|
|
21
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
22
|
+
const Position_1 = require("../../base/Position");
|
|
23
|
+
const ArkImport_1 = require("../ArkImport");
|
|
24
|
+
const builderUtils_1 = require("./builderUtils");
|
|
25
|
+
function buildImportInfo(node, sourceFile) {
|
|
26
|
+
if (ohos_typescript_1.default.isImportDeclaration(node)) {
|
|
27
|
+
return buildImportDeclarationNode(node, sourceFile);
|
|
28
|
+
}
|
|
29
|
+
else if (ohos_typescript_1.default.isImportEqualsDeclaration(node)) {
|
|
30
|
+
return buildImportEqualsDeclarationNode(node, sourceFile);
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
exports.buildImportInfo = buildImportInfo;
|
|
35
|
+
function buildImportDeclarationNode(node, sourceFile) {
|
|
36
|
+
const originTsPosition = Position_1.LineColPosition.buildFromNode(node, sourceFile);
|
|
37
|
+
const tsSourceCode = node.getText(sourceFile);
|
|
38
|
+
let importInfos = [];
|
|
39
|
+
let importFrom = '';
|
|
40
|
+
if (ohos_typescript_1.default.isStringLiteral(node.moduleSpecifier)) {
|
|
41
|
+
importFrom = node.moduleSpecifier.text;
|
|
42
|
+
}
|
|
43
|
+
const modifiers = new Set();
|
|
44
|
+
if (node.modifiers) {
|
|
45
|
+
(0, builderUtils_1.buildModifiers)(node, sourceFile).forEach((modifier) => {
|
|
46
|
+
modifiers.add(modifier);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// just like: import '../xxx'
|
|
50
|
+
if (!node.importClause) {
|
|
51
|
+
let importClauseName = '';
|
|
52
|
+
let importType = '';
|
|
53
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
54
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
55
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
56
|
+
importInfos.push(importInfo);
|
|
57
|
+
}
|
|
58
|
+
//just like: import fs from 'fs'
|
|
59
|
+
if (node.importClause && node.importClause.name && ohos_typescript_1.default.isIdentifier(node.importClause.name)) {
|
|
60
|
+
let importClauseName = node.importClause.name.text;
|
|
61
|
+
let importType = 'Identifier';
|
|
62
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
63
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
64
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
65
|
+
importInfos.push(importInfo);
|
|
66
|
+
}
|
|
67
|
+
// just like: import {xxx} from './yyy'
|
|
68
|
+
if (node.importClause && node.importClause.namedBindings && ohos_typescript_1.default.isNamedImports(node.importClause.namedBindings)) {
|
|
69
|
+
let importType = 'NamedImports';
|
|
70
|
+
if (node.importClause.namedBindings.elements) {
|
|
71
|
+
node.importClause.namedBindings.elements.forEach((element) => {
|
|
72
|
+
if (element.name && ohos_typescript_1.default.isIdentifier(element.name)) {
|
|
73
|
+
let importClauseName = element.name.text;
|
|
74
|
+
if (element.propertyName && ohos_typescript_1.default.isIdentifier(element.propertyName)) {
|
|
75
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
76
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers, element.propertyName.text);
|
|
77
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
78
|
+
importInfos.push(importInfo);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
82
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
83
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
84
|
+
importInfos.push(importInfo);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// just like: import * as ts from 'ohos-typescript'
|
|
91
|
+
if (node.importClause && node.importClause.namedBindings && ohos_typescript_1.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
92
|
+
let importType = 'NamespaceImport';
|
|
93
|
+
if (node.importClause.namedBindings.name && ohos_typescript_1.default.isIdentifier(node.importClause.namedBindings.name)) {
|
|
94
|
+
let importClauseName = node.importClause.namedBindings.name.text;
|
|
95
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
96
|
+
let nameBeforeAs = '*';
|
|
97
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers, nameBeforeAs);
|
|
98
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
99
|
+
importInfos.push(importInfo);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return importInfos;
|
|
103
|
+
}
|
|
104
|
+
function buildImportEqualsDeclarationNode(node, sourceFile) {
|
|
105
|
+
const originTsPosition = Position_1.LineColPosition.buildFromNode(node, sourceFile);
|
|
106
|
+
const tsSourceCode = node.getText(sourceFile);
|
|
107
|
+
let importInfos = [];
|
|
108
|
+
let importType = 'EqualsImport';
|
|
109
|
+
const modifiers = new Set();
|
|
110
|
+
if (node.modifiers) {
|
|
111
|
+
(0, builderUtils_1.buildModifiers)(node, sourceFile).forEach((modifier) => {
|
|
112
|
+
modifiers.add(modifier);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (node.moduleReference && ohos_typescript_1.default.isExternalModuleReference(node.moduleReference) &&
|
|
116
|
+
node.moduleReference.expression && ohos_typescript_1.default.isStringLiteral(node.moduleReference.expression)) {
|
|
117
|
+
let importFrom = node.moduleReference.expression.text;
|
|
118
|
+
let importClauseName = node.name.text;
|
|
119
|
+
let importInfo = new ArkImport_1.ImportInfo();
|
|
120
|
+
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
121
|
+
importInfo.setTsSourceCode(tsSourceCode);
|
|
122
|
+
importInfos.push(importInfo);
|
|
123
|
+
}
|
|
124
|
+
return importInfos;
|
|
125
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Type } from '../../base/Type';
|
|
2
|
+
import { ArkClass } from '../ArkClass';
|
|
3
|
+
import { ArkMethod } from '../ArkMethod';
|
|
4
|
+
import ts from 'ohos-typescript';
|
|
5
|
+
import { Stmt } from '../../base/Stmt';
|
|
6
|
+
import { Local } from '../../base/Local';
|
|
7
|
+
export type MethodLikeNode = ts.FunctionDeclaration | ts.MethodDeclaration | ts.ConstructorDeclaration | ts.ArrowFunction | ts.AccessorDeclaration | ts.FunctionExpression | ts.MethodSignature | ts.ConstructSignatureDeclaration | ts.CallSignatureDeclaration | ts.FunctionTypeNode;
|
|
8
|
+
export declare function buildDefaultArkMethodFromArkClass(declaringClass: ArkClass, mtd: ArkMethod, sourceFile: ts.SourceFile, node?: ts.ModuleDeclaration): void;
|
|
9
|
+
export declare function buildArkMethodFromArkClass(methodNode: MethodLikeNode, declaringClass: ArkClass, mtd: ArkMethod, sourceFile: ts.SourceFile, declaringMethod?: ArkMethod): void;
|
|
10
|
+
export declare class ObjectBindingPatternParameter {
|
|
11
|
+
private propertyName;
|
|
12
|
+
private name;
|
|
13
|
+
private optional;
|
|
14
|
+
constructor();
|
|
15
|
+
getName(): string;
|
|
16
|
+
setName(name: string): void;
|
|
17
|
+
getPropertyName(): string;
|
|
18
|
+
setPropertyName(propertyName: string): void;
|
|
19
|
+
isOptional(): boolean;
|
|
20
|
+
setOptional(optional: boolean): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class ArrayBindingPatternParameter {
|
|
23
|
+
private propertyName;
|
|
24
|
+
private name;
|
|
25
|
+
private optional;
|
|
26
|
+
constructor();
|
|
27
|
+
getName(): string;
|
|
28
|
+
setName(name: string): void;
|
|
29
|
+
getPropertyName(): string;
|
|
30
|
+
setPropertyName(propertyName: string): void;
|
|
31
|
+
isOptional(): boolean;
|
|
32
|
+
setOptional(optional: boolean): void;
|
|
33
|
+
}
|
|
34
|
+
export declare class MethodParameter {
|
|
35
|
+
private name;
|
|
36
|
+
private type;
|
|
37
|
+
private optional;
|
|
38
|
+
private dotDotDotToken;
|
|
39
|
+
private objElements;
|
|
40
|
+
private arrayElements;
|
|
41
|
+
constructor();
|
|
42
|
+
getName(): string;
|
|
43
|
+
setName(name: string): void;
|
|
44
|
+
getType(): Type;
|
|
45
|
+
setType(type: Type): void;
|
|
46
|
+
isOptional(): boolean;
|
|
47
|
+
setOptional(optional: boolean): void;
|
|
48
|
+
hasDotDotDotToken(): boolean;
|
|
49
|
+
setDotDotDotToken(dotDotDotToken: boolean): void;
|
|
50
|
+
addObjElement(element: ObjectBindingPatternParameter): void;
|
|
51
|
+
getObjElements(): ObjectBindingPatternParameter[];
|
|
52
|
+
setObjElements(objElements: ObjectBindingPatternParameter[]): void;
|
|
53
|
+
addArrayElement(element: ArrayBindingPatternParameter): void;
|
|
54
|
+
getArrayElements(): ArrayBindingPatternParameter[];
|
|
55
|
+
setArrayElements(arrayElements: ArrayBindingPatternParameter[]): void;
|
|
56
|
+
}
|
|
57
|
+
export declare function buildDefaultConstructor(arkClass: ArkClass): boolean;
|
|
58
|
+
export declare function buildInitMethod(initMethod: ArkMethod, stmtMap: Map<Stmt, Stmt>, thisLocal: Local): void;
|
|
59
|
+
export declare function addInitInConstructor(arkClass: ArkClass): void;
|
|
60
|
+
//# sourceMappingURL=ArkMethodBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArkMethodBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkMethodBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAejC,OAAO,EAAmD,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQzC,MAAM,MAAM,cAAc,GACtB,EAAE,CAAC,mBAAmB,GACtB,EAAE,CAAC,iBAAiB,GACpB,EAAE,CAAC,sBAAsB,GACzB,EAAE,CAAC,aAAa,GAChB,EAAE,CAAC,mBAAmB,GACtB,EAAE,CAAC,kBAAkB,GACrB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,6BAA6B,GAChC,EAAE,CAAC,wBAAwB,GAC3B,EAAE,CAAC,gBAAgB,CAAC;AAExB,wBAAgB,iCAAiC,CAAC,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EACxC,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,QAWvG;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,QAkDtK;AA0DD,qBAAa,6BAA6B;IACtC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,QAAQ,CAAkB;;IAK3B,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,eAAe;IAIf,eAAe,CAAC,YAAY,EAAE,MAAM;IAIpC,UAAU;IAIV,WAAW,CAAC,QAAQ,EAAE,OAAO;CAGvC;AAED,qBAAa,4BAA4B;IACrC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,QAAQ,CAAkB;;IAK3B,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,eAAe;IAIf,eAAe,CAAC,YAAY,EAAE,MAAM;IAIpC,UAAU;IAIV,WAAW,CAAC,QAAQ,EAAE,OAAO;CAGvC;AAED,qBAAa,eAAe;IACxB,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,aAAa,CAAsC;;IAKpD,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,IAAI;IAIlB,UAAU;IAIV,WAAW,CAAC,QAAQ,EAAE,OAAO;IAI7B,iBAAiB;IAIjB,iBAAiB,CAAC,cAAc,EAAE,OAAO;IAIzC,aAAa,CAAC,OAAO,EAAE,6BAA6B;IAIpD,cAAc;IAId,cAAc,CAAC,WAAW,EAAE,6BAA6B,EAAE;IAI3D,eAAe,CAAC,OAAO,EAAE,4BAA4B;IAIrD,gBAAgB;IAIhB,gBAAgB,CAAC,aAAa,EAAE,4BAA4B,EAAE;CAGxE;AAUD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CA0FnE;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAsBvG;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,QAoBtD"}
|