arkanalyzer 1.0.6 → 1.0.8
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 +8 -0
- package/docs/IR2ts-stmt.md +81 -0
- package/docs/IR2ts.md +82 -0
- package/lib/Config.d.ts +29 -1
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +44 -11
- package/lib/Scene.d.ts +152 -9
- package/lib/Scene.d.ts.map +1 -1
- package/lib/Scene.js +233 -66
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +2 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +14 -7
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +2 -4
- package/lib/callgraph/algorithm/RapidTypeAnalysis.d.ts.map +1 -1
- package/lib/callgraph/algorithm/RapidTypeAnalysis.js +2 -3
- package/lib/callgraph/common/Statistics.js +1 -1
- package/lib/callgraph/model/BaseGraph.js +2 -2
- package/lib/callgraph/model/CallGraph.d.ts +3 -2
- package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
- package/lib/callgraph/model/CallGraph.js +23 -14
- package/lib/callgraph/model/builder/CallGraphBuilder.d.ts +2 -2
- package/lib/callgraph/model/builder/CallGraphBuilder.js +3 -3
- package/lib/callgraph/pointerAnalysis/Context.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Context.js +0 -1
- package/lib/callgraph/pointerAnalysis/Pag.d.ts +36 -9
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +130 -37
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts +34 -5
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +479 -126
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts +6 -0
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +107 -45
- package/lib/callgraph/pointerAnalysis/PtsDS.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PtsDS.js +0 -2
- package/lib/core/base/Constant.d.ts +37 -5
- package/lib/core/base/Constant.d.ts.map +1 -1
- package/lib/core/base/Constant.js +58 -8
- package/lib/core/base/Expr.d.ts +98 -13
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +295 -127
- package/lib/core/base/Local.d.ts +70 -5
- package/lib/core/base/Local.d.ts.map +1 -1
- package/lib/core/base/Local.js +77 -4
- package/lib/core/base/Ref.d.ts +79 -5
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +143 -38
- package/lib/core/base/Stmt.d.ts +126 -12
- package/lib/core/base/Stmt.d.ts.map +1 -1
- package/lib/core/base/Stmt.js +135 -28
- package/lib/core/base/Type.d.ts +11 -2
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +47 -42
- package/lib/core/base/Value.d.ts +24 -2
- package/lib/core/base/Value.d.ts.map +1 -1
- package/lib/core/common/ArkError.d.ts +15 -0
- package/lib/core/common/ArkError.d.ts.map +1 -0
- package/lib/core/common/ArkError.js +28 -0
- package/lib/core/common/ArkIRTransformer.d.ts +12 -5
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +90 -45
- package/lib/core/common/BodyBuilder.d.ts +2 -0
- package/lib/core/common/BodyBuilder.d.ts.map +1 -1
- package/lib/core/common/BodyBuilder.js +5 -2
- package/lib/core/common/Builtin.js +1 -1
- package/lib/core/common/CfgBuilder.d.ts +12 -7
- package/lib/core/common/CfgBuilder.d.ts.map +1 -1
- package/lib/core/common/CfgBuilder.js +336 -140
- package/lib/core/common/Const.d.ts +15 -10
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +18 -11
- package/lib/core/common/DummyMainCreater.d.ts +5 -4
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +43 -28
- package/lib/core/common/EtsConst.d.ts +1 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +2 -1
- package/lib/core/common/ExprUseReplacer.js +8 -8
- package/lib/core/common/IRUtils.d.ts +7 -0
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +34 -2
- package/lib/core/common/ModelUtils.d.ts +1 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +39 -36
- package/lib/core/common/RefUseReplacer.js +3 -3
- package/lib/core/common/StmtUseReplacer.js +4 -4
- package/lib/core/common/TSConst.d.ts +10 -3
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TSConst.js +11 -4
- package/lib/core/common/TypeInference.d.ts +8 -2
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +222 -90
- package/lib/core/common/ValueUtil.d.ts +0 -4
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/common/ValueUtil.js +10 -27
- package/lib/core/common/VisibleValue.js +1 -1
- package/lib/core/dataflow/DataflowProblem.d.ts +1 -0
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +4 -4
- package/lib/core/dataflow/DataflowSolver.d.ts +20 -16
- package/lib/core/dataflow/DataflowSolver.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowSolver.js +67 -78
- package/lib/core/dataflow/TiantAnalysis.d.ts +1 -0
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +1 -1
- package/lib/core/dataflow/TiantAnalysis.js +42 -28
- package/lib/core/dataflow/UndefinedVariable.d.ts +15 -1
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +122 -76
- package/lib/core/dataflow/Util.d.ts +5 -1
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +43 -22
- package/lib/core/graph/BasicBlock.d.ts +72 -0
- package/lib/core/graph/BasicBlock.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +165 -3
- package/lib/core/graph/Cfg.d.ts +30 -1
- package/lib/core/graph/Cfg.d.ts.map +1 -1
- package/lib/core/graph/Cfg.js +131 -11
- package/lib/core/graph/DominanceFinder.js +7 -7
- package/lib/core/graph/DominanceTree.js +4 -4
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +6 -5
- package/lib/core/model/ArkBaseModel.d.ts +59 -0
- package/lib/core/model/ArkBaseModel.d.ts.map +1 -0
- package/lib/core/model/ArkBaseModel.js +271 -0
- package/lib/core/model/ArkBody.d.ts +3 -9
- package/lib/core/model/ArkBody.d.ts.map +1 -1
- package/lib/core/model/ArkBody.js +3 -14
- package/lib/core/model/ArkClass.d.ts +107 -13
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +152 -54
- package/lib/core/model/ArkExport.d.ts +8 -7
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +16 -18
- package/lib/core/model/ArkField.d.ts +16 -13
- package/lib/core/model/ArkField.d.ts.map +1 -1
- package/lib/core/model/ArkField.js +18 -62
- package/lib/core/model/ArkFile.d.ts +42 -0
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +58 -0
- package/lib/core/model/ArkImport.d.ts +9 -7
- package/lib/core/model/ArkImport.d.ts.map +1 -1
- package/lib/core/model/ArkImport.js +11 -12
- package/lib/core/model/ArkMetadata.d.ts +20 -0
- package/lib/core/model/ArkMetadata.d.ts.map +1 -0
- package/lib/core/model/ArkMetadata.js +44 -0
- package/lib/core/model/ArkMethod.d.ts +195 -17
- package/lib/core/model/ArkMethod.d.ts.map +1 -1
- package/lib/core/model/ArkMethod.js +363 -46
- package/lib/core/model/ArkNamespace.d.ts +6 -8
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +16 -20
- package/lib/core/model/ArkSignature.d.ts +41 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +76 -19
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +60 -49
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +12 -6
- package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkFieldBuilder.js +13 -9
- package/lib/core/model/builder/ArkFileBuilder.js +1 -3
- package/lib/core/model/builder/ArkImportBuilder.d.ts +2 -1
- package/lib/core/model/builder/ArkImportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkImportBuilder.js +16 -13
- package/lib/core/model/builder/ArkMethodBuilder.d.ts +3 -1
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +105 -45
- package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +4 -5
- package/lib/core/model/builder/builderUtils.d.ts +2 -1
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +63 -43
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/save/ArkStream.js +1 -1
- package/lib/save/DotPrinter.d.ts.map +1 -1
- package/lib/save/DotPrinter.js +1 -15
- package/lib/save/GraphPrinter.d.ts.map +1 -1
- package/lib/save/GraphPrinter.js +4 -2
- package/lib/save/JsonPrinter.js +5 -5
- package/lib/save/ViewTreePrinter.d.ts +16 -0
- package/lib/save/ViewTreePrinter.d.ts.map +1 -0
- package/lib/save/ViewTreePrinter.js +130 -0
- package/lib/save/source/SourceBase.d.ts +2 -2
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +6 -13
- package/lib/save/source/SourceBody.d.ts.map +1 -1
- package/lib/save/source/SourceBody.js +27 -14
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +12 -8
- package/lib/save/source/SourceField.d.ts.map +1 -1
- package/lib/save/source/SourceField.js +6 -2
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +10 -3
- package/lib/save/source/SourceModule.d.ts.map +1 -1
- package/lib/save/source/SourceModule.js +16 -10
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +4 -0
- package/lib/save/source/SourceStmt.d.ts +1 -1
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +37 -25
- package/lib/save/source/SourceTransformer.d.ts +6 -0
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +82 -51
- package/lib/save/source/SourceUtils.d.ts.map +1 -1
- package/lib/save/source/SourceUtils.js +12 -11
- package/lib/transformer/StaticSingleAssignmentFormer.js +3 -3
- package/lib/utils/CfgStructualAnalysis.d.ts +1 -0
- package/lib/utils/CfgStructualAnalysis.d.ts.map +1 -1
- package/lib/utils/CfgStructualAnalysis.js +103 -72
- package/lib/utils/callGraphUtils.d.ts.map +1 -1
- package/lib/utils/callGraphUtils.js +7 -10
- package/lib/utils/crypto_utils.d.ts +6 -0
- package/lib/utils/crypto_utils.d.ts.map +1 -0
- package/lib/utils/crypto_utils.js +57 -0
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +27 -26
- package/lib/utils/getAllFiles.d.ts +1 -1
- package/lib/utils/getAllFiles.d.ts.map +1 -1
- package/lib/utils/getAllFiles.js +4 -5
- package/lib/utils/logger.js +2 -2
- package/package.json +3 -2
|
@@ -15,15 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ArkField = exports.FieldCategory = void 0;
|
|
18
|
-
const Decorator_1 = require("../base/Decorator");
|
|
19
18
|
const Position_1 = require("../base/Position");
|
|
20
|
-
const
|
|
21
|
-
const COMPONENT_MEMBER_DECORATORS = new Set([
|
|
22
|
-
'State', 'Prop', 'Link', 'StorageProp', 'StorageLink',
|
|
23
|
-
'Provide', 'Consume', 'ObjectLink',
|
|
24
|
-
'LocalStorageLink', 'LocalStorageProp',
|
|
25
|
-
'Local', 'Param', 'Event', 'Provider', 'Consumer'
|
|
26
|
-
]);
|
|
19
|
+
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
27
20
|
var FieldCategory;
|
|
28
21
|
(function (FieldCategory) {
|
|
29
22
|
FieldCategory[FieldCategory["PROPERTY_DECLARATION"] = 0] = "PROPERTY_DECLARATION";
|
|
@@ -34,14 +27,14 @@ var FieldCategory;
|
|
|
34
27
|
FieldCategory[FieldCategory["ENUM_MEMBER"] = 5] = "ENUM_MEMBER";
|
|
35
28
|
FieldCategory[FieldCategory["INDEX_SIGNATURE"] = 6] = "INDEX_SIGNATURE";
|
|
36
29
|
FieldCategory[FieldCategory["GET_ACCESSOR"] = 7] = "GET_ACCESSOR";
|
|
37
|
-
})(FieldCategory
|
|
30
|
+
})(FieldCategory = exports.FieldCategory || (exports.FieldCategory = {}));
|
|
38
31
|
/**
|
|
39
32
|
* @category core/model
|
|
40
33
|
*/
|
|
41
|
-
class ArkField {
|
|
34
|
+
class ArkField extends ArkBaseModel_1.ArkBaseModel {
|
|
42
35
|
constructor() {
|
|
36
|
+
super();
|
|
43
37
|
this.code = "";
|
|
44
|
-
this.modifiers = new Set();
|
|
45
38
|
this.questionToken = false;
|
|
46
39
|
this.exclamationToken = false;
|
|
47
40
|
this.initializer = [];
|
|
@@ -52,6 +45,10 @@ class ArkField {
|
|
|
52
45
|
setDeclaringArkClass(declaringClass) {
|
|
53
46
|
this.declaringClass = declaringClass;
|
|
54
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the codes of field as a **string.**
|
|
50
|
+
* @returns the codes of field.
|
|
51
|
+
*/
|
|
55
52
|
getCode() {
|
|
56
53
|
return this.code;
|
|
57
54
|
}
|
|
@@ -70,54 +67,22 @@ class ArkField {
|
|
|
70
67
|
getType() {
|
|
71
68
|
return this.fieldSignature.getType();
|
|
72
69
|
}
|
|
73
|
-
getModifiers() {
|
|
74
|
-
return this.modifiers;
|
|
75
|
-
}
|
|
76
|
-
addModifier(modifier) {
|
|
77
|
-
this.modifiers.add(modifier);
|
|
78
|
-
}
|
|
79
70
|
getSignature() {
|
|
80
71
|
return this.fieldSignature;
|
|
81
72
|
}
|
|
82
73
|
setSignature(fieldSig) {
|
|
83
74
|
this.fieldSignature = fieldSig;
|
|
84
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns an array of statements used for initialization.
|
|
78
|
+
* @returns An array of statements used for initialization.
|
|
79
|
+
*/
|
|
85
80
|
getInitializer() {
|
|
86
81
|
return this.initializer;
|
|
87
82
|
}
|
|
88
83
|
setInitializer(initializer) {
|
|
89
84
|
this.initializer = initializer;
|
|
90
85
|
}
|
|
91
|
-
isStatic() {
|
|
92
|
-
if (this.modifiers.has("StaticKeyword")) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
isProtected() {
|
|
98
|
-
if (this.modifiers.has("ProtectedKeyword")) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
isPrivate() {
|
|
104
|
-
if (this.modifiers.has("PrivateKeyword")) {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
isPublic() {
|
|
110
|
-
if (this.modifiers.has("PublicKeyword")) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
isReadonly() {
|
|
116
|
-
if (this.modifiers.has("ReadonlyKeyword")) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
86
|
setQuestionToken(questionToken) {
|
|
122
87
|
this.questionToken = questionToken;
|
|
123
88
|
}
|
|
@@ -133,25 +98,16 @@ class ArkField {
|
|
|
133
98
|
setOriginPosition(position) {
|
|
134
99
|
this.originPosition = position;
|
|
135
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the original position of the field at source code.
|
|
103
|
+
* @returns The original position of the field at source code.
|
|
104
|
+
*/
|
|
136
105
|
getOriginPosition() {
|
|
137
106
|
var _a;
|
|
138
107
|
return (_a = this.originPosition) !== null && _a !== void 0 ? _a : Position_1.LineColPosition.DEFAULT;
|
|
139
108
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
return item instanceof Decorator_1.Decorator;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
getStateDecorators() {
|
|
146
|
-
return Array.from(this.modifiers).filter((item) => {
|
|
147
|
-
return (item instanceof Decorator_1.Decorator) && (COMPONENT_MEMBER_DECORATORS.has(item.getKind()));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
hasBuilderParamDecorator() {
|
|
151
|
-
let decorators = this.getDecorators();
|
|
152
|
-
return decorators.filter((value) => {
|
|
153
|
-
return value.getKind() == EtsConst_1.BUILDER_PARAM_DECORATOR;
|
|
154
|
-
}).length != 0;
|
|
109
|
+
validate() {
|
|
110
|
+
return this.validateFields(['category', 'declaringClass', 'fieldSignature']);
|
|
155
111
|
}
|
|
156
112
|
}
|
|
157
113
|
exports.ArkField = ArkField;
|
|
@@ -23,16 +23,40 @@ export declare class ArkFile {
|
|
|
23
23
|
private ohPackageJson5Path;
|
|
24
24
|
private anonymousClassNumber;
|
|
25
25
|
constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Returns the **string** name of the file, which also acts as the file's relative path.
|
|
28
|
+
* @returns The file's name (also means its relative path).
|
|
29
|
+
*/
|
|
26
30
|
getName(): string;
|
|
27
31
|
setScene(scene: Scene): void;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the scene (i.e., {@link Scene}) built for the project. The {@link Scene} is the core class of ArkAnalyzer,
|
|
34
|
+
* through which users can access all the information of the analyzed code (project),
|
|
35
|
+
* including file list, class list, method list, property list, etc.
|
|
36
|
+
* @returns The scene of the file.
|
|
37
|
+
*/
|
|
28
38
|
getScene(): Scene;
|
|
29
39
|
getModuleScene(): ModuleScene | undefined;
|
|
30
40
|
setModuleScene(moduleScene: ModuleScene): void;
|
|
31
41
|
setProjectDir(projectDir: string): void;
|
|
32
42
|
getProjectDir(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get a file path.
|
|
45
|
+
* @returns The absolute file path.
|
|
46
|
+
* @example
|
|
47
|
+
* 1. Read source code based on file path.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
let str = fs.readFileSync(arkFile.getFilePath(), 'utf8');
|
|
51
|
+
```
|
|
52
|
+
*/
|
|
33
53
|
getFilePath(): string;
|
|
34
54
|
setFilePath(absoluteFilePath: string): void;
|
|
35
55
|
setCode(code: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the codes of file as a **string.**
|
|
58
|
+
* @returns the codes of file.
|
|
59
|
+
*/
|
|
36
60
|
getCode(): string;
|
|
37
61
|
addArkClass(arkClass: ArkClass): void;
|
|
38
62
|
getDefaultClass(): ArkClass;
|
|
@@ -40,20 +64,38 @@ export declare class ArkFile {
|
|
|
40
64
|
getNamespace(namespaceSignature: NamespaceSignature): ArkNamespace | null;
|
|
41
65
|
getNamespaceWithName(namespaceName: string): ArkNamespace | null;
|
|
42
66
|
getNamespaces(): ArkNamespace[];
|
|
67
|
+
/**
|
|
68
|
+
* Returns the class based on its class signature. If the class could not be found, **null** will be returned.
|
|
69
|
+
* @param classSignature - the class signature.
|
|
70
|
+
* @returns A class. If there is no class, the return will be a **null**.
|
|
71
|
+
*/
|
|
43
72
|
getClass(classSignature: ClassSignature): ArkClass | null;
|
|
44
73
|
getClassWithName(Class: string): ArkClass | null;
|
|
45
74
|
getClasses(): ArkClass[];
|
|
46
75
|
addNamespace(namespace: ArkNamespace): void;
|
|
76
|
+
/**
|
|
77
|
+
* Returns an **array** of import information.
|
|
78
|
+
* The import information includes: clause's name, type, modifiers, location where it is imported from, etc.
|
|
79
|
+
* @returns An **array** of import information.
|
|
80
|
+
*/
|
|
47
81
|
getImportInfos(): ImportInfo[];
|
|
48
82
|
getImportInfoBy(name: string): ImportInfo | undefined;
|
|
49
83
|
addImportInfo(importInfo: ImportInfo): void;
|
|
84
|
+
removeImportInfo(importInfo: ImportInfo): boolean;
|
|
85
|
+
removeNamespace(namespace: ArkNamespace): boolean;
|
|
86
|
+
removeArkClass(arkClass: ArkClass): boolean;
|
|
50
87
|
getExportInfos(): ExportInfo[];
|
|
51
88
|
getExportInfoBy(name: string): ExportInfo | undefined;
|
|
52
89
|
addExportInfo(exportInfo: ExportInfo, key?: string): void;
|
|
90
|
+
removeExportInfo(exportInfo: ExportInfo, key?: string): void;
|
|
53
91
|
getProjectName(): string;
|
|
54
92
|
getModuleName(): string | undefined;
|
|
55
93
|
setOhPackageJson5Path(ohPackageJson5Path: string[]): void;
|
|
56
94
|
getOhPackageJson5Path(): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Returns the file signature of this file. A file signature consists of project's name and file's name.
|
|
97
|
+
* @returns The file signature of this file.
|
|
98
|
+
*/
|
|
57
99
|
getFileSignature(): FileSignature;
|
|
58
100
|
setFileSignature(fileSignature: FileSignature): void;
|
|
59
101
|
getAllNamespacesUnderThisFile(): ArkNamespace[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkFile.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkFile.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGnF,eAAO,MAAM,iBAAiB,UAEqD,CAAC;AAEpF;;GAEG;AACH,qBAAa,OAAO;IAChB,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,IAAI,CAAc;IAE1B,OAAO,CAAC,YAAY,CAAY;IAGhC,OAAO,CAAC,UAAU,CAA8D;IAChF,OAAO,CAAC,OAAO,CAAsD;IAErE,OAAO,CAAC,aAAa,CAA0D;IAC/E,OAAO,CAAC,aAAa,CAA0D;IAE/E,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAC,CAAc;IAElC,OAAO,CAAC,aAAa,CAAwC;IAE7D,OAAO,CAAC,kBAAkB,CAAgB;IAE1C,OAAO,CAAC,oBAAoB,CAAa;;
|
|
1
|
+
{"version":3,"file":"ArkFile.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkFile.ts"],"names":[],"mappings":"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"}
|
|
@@ -37,12 +37,22 @@ class ArkFile {
|
|
|
37
37
|
this.ohPackageJson5Path = [];
|
|
38
38
|
this.anonymousClassNumber = 0;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the **string** name of the file, which also acts as the file's relative path.
|
|
42
|
+
* @returns The file's name (also means its relative path).
|
|
43
|
+
*/
|
|
40
44
|
getName() {
|
|
41
45
|
return this.fileSignature.getFileName();
|
|
42
46
|
}
|
|
43
47
|
setScene(scene) {
|
|
44
48
|
this.scene = scene;
|
|
45
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the scene (i.e., {@link Scene}) built for the project. The {@link Scene} is the core class of ArkAnalyzer,
|
|
52
|
+
* through which users can access all the information of the analyzed code (project),
|
|
53
|
+
* including file list, class list, method list, property list, etc.
|
|
54
|
+
* @returns The scene of the file.
|
|
55
|
+
*/
|
|
46
56
|
getScene() {
|
|
47
57
|
return this.scene;
|
|
48
58
|
}
|
|
@@ -58,6 +68,16 @@ class ArkFile {
|
|
|
58
68
|
getProjectDir() {
|
|
59
69
|
return this.projectDir;
|
|
60
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Get a file path.
|
|
73
|
+
* @returns The absolute file path.
|
|
74
|
+
* @example
|
|
75
|
+
* 1. Read source code based on file path.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
let str = fs.readFileSync(arkFile.getFilePath(), 'utf8');
|
|
79
|
+
```
|
|
80
|
+
*/
|
|
61
81
|
getFilePath() {
|
|
62
82
|
return this.absoluteFilePath;
|
|
63
83
|
}
|
|
@@ -67,6 +87,10 @@ class ArkFile {
|
|
|
67
87
|
setCode(code) {
|
|
68
88
|
this.code = code;
|
|
69
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the codes of file as a **string.**
|
|
92
|
+
* @returns the codes of file.
|
|
93
|
+
*/
|
|
70
94
|
getCode() {
|
|
71
95
|
return this.code;
|
|
72
96
|
}
|
|
@@ -89,6 +113,11 @@ class ArkFile {
|
|
|
89
113
|
getNamespaces() {
|
|
90
114
|
return Array.from(this.namespaces.values());
|
|
91
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns the class based on its class signature. If the class could not be found, **null** will be returned.
|
|
118
|
+
* @param classSignature - the class signature.
|
|
119
|
+
* @returns A class. If there is no class, the return will be a **null**.
|
|
120
|
+
*/
|
|
92
121
|
getClass(classSignature) {
|
|
93
122
|
const className = classSignature.getClassName();
|
|
94
123
|
return this.getClassWithName(className);
|
|
@@ -102,6 +131,11 @@ class ArkFile {
|
|
|
102
131
|
addNamespace(namespace) {
|
|
103
132
|
this.namespaces.set(namespace.getName(), namespace);
|
|
104
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns an **array** of import information.
|
|
136
|
+
* The import information includes: clause's name, type, modifiers, location where it is imported from, etc.
|
|
137
|
+
* @returns An **array** of import information.
|
|
138
|
+
*/
|
|
105
139
|
getImportInfos() {
|
|
106
140
|
return Array.from(this.importInfoMap.values());
|
|
107
141
|
}
|
|
@@ -111,6 +145,19 @@ class ArkFile {
|
|
|
111
145
|
addImportInfo(importInfo) {
|
|
112
146
|
this.importInfoMap.set(importInfo.getImportClauseName(), importInfo);
|
|
113
147
|
}
|
|
148
|
+
removeImportInfo(importInfo) {
|
|
149
|
+
return this.importInfoMap.delete(importInfo.getImportClauseName());
|
|
150
|
+
}
|
|
151
|
+
removeNamespace(namespace) {
|
|
152
|
+
let rtn = this.namespaces.delete(namespace.getName());
|
|
153
|
+
rtn && (rtn = this.getScene().removeNamespace(namespace));
|
|
154
|
+
return rtn;
|
|
155
|
+
}
|
|
156
|
+
removeArkClass(arkClass) {
|
|
157
|
+
let rtn = this.classes.delete(arkClass.getName());
|
|
158
|
+
rtn && (rtn = this.getScene().removeClass(arkClass));
|
|
159
|
+
return rtn;
|
|
160
|
+
}
|
|
114
161
|
getExportInfos() {
|
|
115
162
|
const exportInfos = [];
|
|
116
163
|
this.exportInfoMap.forEach((value, key) => {
|
|
@@ -126,6 +173,13 @@ class ArkFile {
|
|
|
126
173
|
addExportInfo(exportInfo, key) {
|
|
127
174
|
this.exportInfoMap.set(key !== null && key !== void 0 ? key : exportInfo.getExportClauseName(), exportInfo);
|
|
128
175
|
}
|
|
176
|
+
removeExportInfo(exportInfo, key) {
|
|
177
|
+
if (key) {
|
|
178
|
+
this.exportInfoMap.delete(key);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.exportInfoMap.delete(exportInfo.getExportClauseName());
|
|
182
|
+
}
|
|
129
183
|
getProjectName() {
|
|
130
184
|
return this.fileSignature.getProjectName();
|
|
131
185
|
}
|
|
@@ -139,6 +193,10 @@ class ArkFile {
|
|
|
139
193
|
getOhPackageJson5Path() {
|
|
140
194
|
return this.ohPackageJson5Path;
|
|
141
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns the file signature of this file. A file signature consists of project's name and file's name.
|
|
198
|
+
* @returns The file signature of this file.
|
|
199
|
+
*/
|
|
142
200
|
getFileSignature() {
|
|
143
201
|
return this.fileSignature;
|
|
144
202
|
}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { ArkFile } from './ArkFile';
|
|
2
2
|
import { LineColPosition } from '../base/Position';
|
|
3
|
-
import { Decorator } from '../base/Decorator';
|
|
4
3
|
import { ExportInfo, FromInfo } from './ArkExport';
|
|
4
|
+
import { ArkBaseModel } from './ArkBaseModel';
|
|
5
|
+
import { ArkError } from '../common/ArkError';
|
|
5
6
|
/**
|
|
6
7
|
* @category core/model
|
|
7
8
|
*/
|
|
8
|
-
export declare class ImportInfo implements FromInfo {
|
|
9
|
+
export declare class ImportInfo extends ArkBaseModel implements FromInfo {
|
|
9
10
|
private importClauseName;
|
|
10
11
|
private importType;
|
|
11
12
|
private importFrom?;
|
|
12
13
|
private nameBeforeAs?;
|
|
13
|
-
private modifiers;
|
|
14
14
|
private declaringArkFile;
|
|
15
15
|
private originTsPosition?;
|
|
16
16
|
private tsSourceCode?;
|
|
17
17
|
private lazyExportInfo?;
|
|
18
18
|
constructor();
|
|
19
|
-
build(importClauseName: string, importType: string, importFrom: string, originTsPosition: LineColPosition, modifiers:
|
|
19
|
+
build(importClauseName: string, importType: string, importFrom: string, originTsPosition: LineColPosition, modifiers: number, nameBeforeAs?: string): void;
|
|
20
20
|
getOriginName(): string;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Returns the export information, i.e., the actual reference generated at the time of call.
|
|
23
|
+
* The export information includes: clause's name, clause's type, modifiers, location
|
|
24
|
+
* where it is exported from, etc. If the export information could not be found, **null** will be returned.
|
|
25
|
+
* @returns The export information. If there is no export information, the return will be a **null**.
|
|
23
26
|
*/
|
|
24
27
|
getLazyExportInfo(): ExportInfo | null;
|
|
25
28
|
setDeclaringArkFile(declaringArkFile: ArkFile): void;
|
|
@@ -31,13 +34,12 @@ export declare class ImportInfo implements FromInfo {
|
|
|
31
34
|
setImportFrom(importFrom: string): void;
|
|
32
35
|
getNameBeforeAs(): string | undefined;
|
|
33
36
|
setNameBeforeAs(nameBeforeAs: string | undefined): void;
|
|
34
|
-
getModifiers(): Set<string | Decorator>;
|
|
35
|
-
addModifier(name: string | Decorator): void;
|
|
36
37
|
setOriginTsPosition(originTsPosition: LineColPosition): void;
|
|
37
38
|
getOriginTsPosition(): LineColPosition;
|
|
38
39
|
setTsSourceCode(tsSourceCode: string): void;
|
|
39
40
|
getTsSourceCode(): string;
|
|
40
41
|
getFrom(): string | undefined;
|
|
41
42
|
isDefault(): boolean;
|
|
43
|
+
validate(): ArkError;
|
|
42
44
|
}
|
|
43
45
|
//# sourceMappingURL=ArkImport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkImport.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkImport.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ArkImport.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkImport.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAa,YAAW,QAAQ;IAC5D,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAW;IAEnC,OAAO,CAAC,gBAAgB,CAAC,CAAkB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAC,CAAoB;;IAMpC,KAAK,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EACnG,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IAS9C,aAAa,IAAI,MAAM;IAI9B;;;;;OAKG;IACI,iBAAiB,IAAI,UAAU,GAAG,IAAI;IAOtC,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI;IAIpD,mBAAmB,IAAI,OAAO;IAI9B,mBAAmB,IAAI,MAAM;IAI7B,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAInD,aAAa,IAAI,MAAM;IAIvB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIvC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIvC,eAAe,IAAI,MAAM,GAAG,SAAS;IAIrC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAIhD,mBAAmB,CAAC,gBAAgB,EAAE,eAAe,GAAG,IAAI;IAI5D,mBAAmB,IAAI,eAAe;IAItC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAI3C,eAAe,IAAI,MAAM;IAIzB,OAAO,IAAI,MAAM,GAAG,SAAS;IAI7B,SAAS,IAAI,OAAO;IAOpB,QAAQ,IAAI,QAAQ;CAG9B"}
|
|
@@ -17,23 +17,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.ImportInfo = void 0;
|
|
18
18
|
const Position_1 = require("../base/Position");
|
|
19
19
|
const ModelUtils_1 = require("../common/ModelUtils");
|
|
20
|
+
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
20
21
|
/**
|
|
21
22
|
* @category core/model
|
|
22
23
|
*/
|
|
23
|
-
class ImportInfo {
|
|
24
|
+
class ImportInfo extends ArkBaseModel_1.ArkBaseModel {
|
|
24
25
|
constructor() {
|
|
26
|
+
super();
|
|
25
27
|
this.importClauseName = '';
|
|
26
28
|
this.importType = '';
|
|
27
|
-
this.modifiers = new Set();
|
|
28
29
|
}
|
|
29
30
|
build(importClauseName, importType, importFrom, originTsPosition, modifiers, nameBeforeAs) {
|
|
30
31
|
this.setImportClauseName(importClauseName);
|
|
31
32
|
this.setImportType(importType);
|
|
32
33
|
this.setImportFrom(importFrom);
|
|
33
34
|
this.setOriginTsPosition(originTsPosition);
|
|
34
|
-
|
|
35
|
-
this.addModifier(modifier);
|
|
36
|
-
});
|
|
35
|
+
this.addModifier(modifiers);
|
|
37
36
|
this.setNameBeforeAs(nameBeforeAs);
|
|
38
37
|
}
|
|
39
38
|
getOriginName() {
|
|
@@ -41,7 +40,10 @@ class ImportInfo {
|
|
|
41
40
|
return (_a = this.nameBeforeAs) !== null && _a !== void 0 ? _a : this.importClauseName;
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* Returns the export information, i.e., the actual reference generated at the time of call.
|
|
44
|
+
* The export information includes: clause's name, clause's type, modifiers, location
|
|
45
|
+
* where it is exported from, etc. If the export information could not be found, **null** will be returned.
|
|
46
|
+
* @returns The export information. If there is no export information, the return will be a **null**.
|
|
45
47
|
*/
|
|
46
48
|
getLazyExportInfo() {
|
|
47
49
|
if (this.lazyExportInfo === undefined) {
|
|
@@ -76,12 +78,6 @@ class ImportInfo {
|
|
|
76
78
|
setNameBeforeAs(nameBeforeAs) {
|
|
77
79
|
this.nameBeforeAs = nameBeforeAs;
|
|
78
80
|
}
|
|
79
|
-
getModifiers() {
|
|
80
|
-
return this.modifiers;
|
|
81
|
-
}
|
|
82
|
-
addModifier(name) {
|
|
83
|
-
this.modifiers.add(name);
|
|
84
|
-
}
|
|
85
81
|
setOriginTsPosition(originTsPosition) {
|
|
86
82
|
this.originTsPosition = originTsPosition;
|
|
87
83
|
}
|
|
@@ -105,5 +101,8 @@ class ImportInfo {
|
|
|
105
101
|
}
|
|
106
102
|
return this.importType === 'Identifier';
|
|
107
103
|
}
|
|
104
|
+
validate() {
|
|
105
|
+
return this.validateFields(['declaringArkFile']);
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
exports.ImportInfo = ImportInfo;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum ArkMetadataKind {
|
|
2
|
+
LEADING_COMMENTS = 0
|
|
3
|
+
}
|
|
4
|
+
export type ArkMetadataType = string[];
|
|
5
|
+
/**
|
|
6
|
+
* ArkMetadata
|
|
7
|
+
* @example
|
|
8
|
+
* // get leading comments
|
|
9
|
+
* let stmt: Stmt = xxx;
|
|
10
|
+
* let comments = stmt.getMetadata(ArkMetadataKind.LEADING_COMMENTS) || [];
|
|
11
|
+
* comments.forEach((comment) => {
|
|
12
|
+
* logger.info(comment);
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
export declare class ArkMetadata {
|
|
16
|
+
protected metadata?: Map<ArkMetadataKind, ArkMetadataType>;
|
|
17
|
+
getMetadata(kind: ArkMetadataKind): ArkMetadataType | undefined;
|
|
18
|
+
setMetadata(kind: ArkMetadataKind, value: ArkMetadataType): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ArkMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArkMetadata.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkMetadata.ts"],"names":[],"mappings":"AAeA,oBAAY,eAAe;IACvB,gBAAgB,IAAA;CACnB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,EAAE,CAAC;AAEvC;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACpB,SAAS,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;IAEpD,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,SAAS;IAI/D,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI;CAM1E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ArkMetadata = exports.ArkMetadataKind = void 0;
|
|
18
|
+
var ArkMetadataKind;
|
|
19
|
+
(function (ArkMetadataKind) {
|
|
20
|
+
ArkMetadataKind[ArkMetadataKind["LEADING_COMMENTS"] = 0] = "LEADING_COMMENTS";
|
|
21
|
+
})(ArkMetadataKind = exports.ArkMetadataKind || (exports.ArkMetadataKind = {}));
|
|
22
|
+
/**
|
|
23
|
+
* ArkMetadata
|
|
24
|
+
* @example
|
|
25
|
+
* // get leading comments
|
|
26
|
+
* let stmt: Stmt = xxx;
|
|
27
|
+
* let comments = stmt.getMetadata(ArkMetadataKind.LEADING_COMMENTS) || [];
|
|
28
|
+
* comments.forEach((comment) => {
|
|
29
|
+
* logger.info(comment);
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
class ArkMetadata {
|
|
33
|
+
getMetadata(kind) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.get(kind);
|
|
36
|
+
}
|
|
37
|
+
setMetadata(kind, value) {
|
|
38
|
+
if (!this.metadata) {
|
|
39
|
+
this.metadata = new Map();
|
|
40
|
+
}
|
|
41
|
+
this.metadata.set(kind, value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ArkMetadata = ArkMetadata;
|