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
|
@@ -17,19 +17,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.ArkMethod = exports.arkMethodNodeKind = void 0;
|
|
18
18
|
const Ref_1 = require("../base/Ref");
|
|
19
19
|
const Stmt_1 = require("../base/Stmt");
|
|
20
|
-
const
|
|
20
|
+
const Type_1 = require("../base/Type");
|
|
21
|
+
const ArkClass_1 = require("./ArkClass");
|
|
21
22
|
const ArkExport_1 = require("./ArkExport");
|
|
22
23
|
const Const_1 = require("../common/Const");
|
|
23
24
|
const Position_1 = require("../base/Position");
|
|
25
|
+
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
26
|
+
const ArkError_1 = require("../common/ArkError");
|
|
27
|
+
const EtsConst_1 = require("../common/EtsConst");
|
|
24
28
|
exports.arkMethodNodeKind = ['MethodDeclaration', 'Constructor', 'FunctionDeclaration', 'GetAccessor',
|
|
25
29
|
'SetAccessor', 'ArrowFunction', 'FunctionExpression', 'MethodSignature', 'ConstructSignature', 'CallSignature'];
|
|
26
30
|
/**
|
|
27
31
|
* @category core/model
|
|
28
32
|
*/
|
|
29
|
-
class ArkMethod {
|
|
33
|
+
class ArkMethod extends ArkBaseModel_1.ArkBaseModel {
|
|
30
34
|
constructor() {
|
|
31
|
-
|
|
32
|
-
this.modifiers = new Set();
|
|
35
|
+
super();
|
|
33
36
|
this.isGeneratedFlag = false;
|
|
34
37
|
this.asteriskToken = false;
|
|
35
38
|
}
|
|
@@ -37,26 +40,145 @@ class ArkMethod {
|
|
|
37
40
|
return ArkExport_1.ExportType.METHOD;
|
|
38
41
|
}
|
|
39
42
|
getName() {
|
|
40
|
-
return this.
|
|
43
|
+
return this.getSignature().getMethodSubSignature().getMethodName();
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the codes of method as a **string.**
|
|
47
|
+
* @returns the codes of method.
|
|
48
|
+
*/
|
|
42
49
|
getCode() {
|
|
43
50
|
return this.code;
|
|
44
51
|
}
|
|
45
52
|
setCode(code) {
|
|
46
53
|
this.code = code;
|
|
47
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all lines of the method's declarations or null if the method has no seperated declaration.
|
|
57
|
+
* @returns null or the lines of the method's declarations with number type.
|
|
58
|
+
*/
|
|
59
|
+
getDeclareLines() {
|
|
60
|
+
if (this.methodDeclareLineCols === undefined) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
let lines = [];
|
|
64
|
+
this.methodDeclareLineCols.forEach(lineCol => {
|
|
65
|
+
lines.push((0, Position_1.getLineNo)(lineCol));
|
|
66
|
+
});
|
|
67
|
+
return lines;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all columns of the method's declarations or null if the method has no seperated declaration.
|
|
71
|
+
* @returns null or the columns of the method's declarations with number type.
|
|
72
|
+
*/
|
|
73
|
+
getDeclareColumns() {
|
|
74
|
+
if (this.methodDeclareLineCols === undefined) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
let columns = [];
|
|
78
|
+
this.methodDeclareLineCols.forEach(lineCol => {
|
|
79
|
+
columns.push((0, Position_1.getColNo)(lineCol));
|
|
80
|
+
});
|
|
81
|
+
return columns;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Set lines and columns of the declarations with number type inputs and then encoded them to LineCol type.
|
|
85
|
+
* The length of lines and columns should be the same otherwise they cannot be encoded together.
|
|
86
|
+
* @param lines - the number of lines.
|
|
87
|
+
* @param columns - the number of columns.
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
setDeclareLinesAndCols(lines, columns) {
|
|
91
|
+
if ((lines === null || lines === void 0 ? void 0 : lines.length) !== (columns === null || columns === void 0 ? void 0 : columns.length)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.methodDeclareLineCols = [];
|
|
95
|
+
lines.forEach((line, index) => {
|
|
96
|
+
let lineCol = 0;
|
|
97
|
+
lineCol = (0, Position_1.setLine)(lineCol, line);
|
|
98
|
+
lineCol = (0, Position_1.setCol)(lineCol, columns[index]);
|
|
99
|
+
this.methodDeclareLineCols.push(lineCol);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Set lineCols of the declarations directly with LineCol type input.
|
|
104
|
+
* @param lineCols - the encoded lines and columns with LineCol type.
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
setDeclareLineCols(lineCols) {
|
|
108
|
+
this.methodDeclareLineCols = lineCols;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get encoded lines and columns of the method's declarations or null if the method has no seperated declaration.
|
|
112
|
+
* @returns null or the encoded lines and columns of the method's declarations with LineCol type.
|
|
113
|
+
*/
|
|
114
|
+
getDeclareLineCols() {
|
|
115
|
+
var _a;
|
|
116
|
+
return (_a = this.methodDeclareLineCols) !== null && _a !== void 0 ? _a : null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get line of the method's implementation or null if the method has no implementation.
|
|
120
|
+
* @returns null or the number of the line.
|
|
121
|
+
*/
|
|
48
122
|
getLine() {
|
|
123
|
+
if (this.lineCol === undefined) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
49
126
|
return (0, Position_1.getLineNo)(this.lineCol);
|
|
50
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Set line of the implementation with line number input.
|
|
130
|
+
* The line number will be encoded together with the original column number.
|
|
131
|
+
* @param line - the line number of the method implementation.
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
51
134
|
setLine(line) {
|
|
135
|
+
if (this.lineCol === undefined) {
|
|
136
|
+
this.lineCol = 0;
|
|
137
|
+
}
|
|
52
138
|
this.lineCol = (0, Position_1.setLine)(this.lineCol, line);
|
|
53
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Get column of the method's implementation or null if the method has no implementation.
|
|
142
|
+
* @returns null or the number of the column.
|
|
143
|
+
*/
|
|
54
144
|
getColumn() {
|
|
145
|
+
if (this.lineCol === undefined) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
55
148
|
return (0, Position_1.getColNo)(this.lineCol);
|
|
56
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Set column of the implementation with column number input.
|
|
152
|
+
* The column number will be encoded together with the original line number.
|
|
153
|
+
* @param column - the column number of the method implementation.
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
57
156
|
setColumn(column) {
|
|
157
|
+
if (this.lineCol === undefined) {
|
|
158
|
+
this.lineCol = 0;
|
|
159
|
+
}
|
|
58
160
|
this.lineCol = (0, Position_1.setCol)(this.lineCol, column);
|
|
59
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Get encoded line and column of the method's implementation or null if the method has no implementation.
|
|
164
|
+
* @returns null or the encoded line and column of the method's implementation with LineCol type.
|
|
165
|
+
*/
|
|
166
|
+
getLineCol() {
|
|
167
|
+
var _a;
|
|
168
|
+
return (_a = this.lineCol) !== null && _a !== void 0 ? _a : null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set lineCol of the implementation directly with LineCol type input.
|
|
172
|
+
* @param lineCol - the encoded line and column with LineCol type.
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
setLineCol(lineCol) {
|
|
176
|
+
this.lineCol = lineCol;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Returns the declaring class of the method.
|
|
180
|
+
* @returns The declaring class of the method.
|
|
181
|
+
*/
|
|
60
182
|
getDeclaringArkClass() {
|
|
61
183
|
return this.declaringArkClass;
|
|
62
184
|
}
|
|
@@ -66,15 +188,6 @@ class ArkMethod {
|
|
|
66
188
|
getDeclaringArkFile() {
|
|
67
189
|
return this.declaringArkClass.getDeclaringArkFile();
|
|
68
190
|
}
|
|
69
|
-
isExported() {
|
|
70
|
-
return this.modifiers.has('ExportKeyword');
|
|
71
|
-
}
|
|
72
|
-
isStatic() {
|
|
73
|
-
if (this.modifiers.has('StaticKeyword')) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
191
|
isDefaultArkMethod() {
|
|
79
192
|
return this.getName() === Const_1.DEFAULT_ARK_METHOD_NAME;
|
|
80
193
|
}
|
|
@@ -82,51 +195,185 @@ class ArkMethod {
|
|
|
82
195
|
return this.getName().startsWith(Const_1.ANONYMOUS_METHOD_PREFIX);
|
|
83
196
|
}
|
|
84
197
|
getParameters() {
|
|
85
|
-
return this.
|
|
198
|
+
return this.getSignature().getMethodSubSignature().getParameters();
|
|
86
199
|
}
|
|
87
200
|
getReturnType() {
|
|
88
|
-
return this.
|
|
89
|
-
}
|
|
201
|
+
return this.getSignature().getType();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get all declare signatures.
|
|
205
|
+
* The results could be null if there is no seperated declaration of the method.
|
|
206
|
+
* @returns null or the method declare signatures.
|
|
207
|
+
*/
|
|
208
|
+
getDeclareSignatures() {
|
|
209
|
+
var _a;
|
|
210
|
+
return (_a = this.methodDeclareSignatures) !== null && _a !== void 0 ? _a : null;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get the index of the matched method declare signature among all declare signatures.
|
|
214
|
+
* The index will be -1 if there is no matched signature found.
|
|
215
|
+
* @param targetSignature - the target declare signature want to search.
|
|
216
|
+
* @returns -1 or the index of the matched signature.
|
|
217
|
+
*/
|
|
218
|
+
getDeclareSignatureIndex(targetSignature) {
|
|
219
|
+
let declareSignatures = this.methodDeclareSignatures;
|
|
220
|
+
if (declareSignatures === undefined) {
|
|
221
|
+
return -1;
|
|
222
|
+
}
|
|
223
|
+
for (let i = 0; i < declareSignatures.length; i++) {
|
|
224
|
+
if (declareSignatures[i].isMatch(targetSignature)) {
|
|
225
|
+
return i;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return -1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the method signature of the implementation.
|
|
232
|
+
* The signature could be null if the method is only a declaration which body is undefined.
|
|
233
|
+
* @returns null or the method implementation signature.
|
|
234
|
+
*/
|
|
235
|
+
getImplementationSignature() {
|
|
236
|
+
var _a;
|
|
237
|
+
return (_a = this.methodSignature) !== null && _a !== void 0 ? _a : null;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get the method signature of the implementation or the first declaration if there is no implementation.
|
|
241
|
+
* For a method, the implementation and declaration signatures must not be undefined at the same time.
|
|
242
|
+
* A {@link MethodSignature} includes:
|
|
243
|
+
* - Class Signature: indicates which class this method belong to.
|
|
244
|
+
* - Method SubSignature: indicates the detail info of this method such as method name, parameters, returnType, etc.
|
|
245
|
+
* @returns The method signature.
|
|
246
|
+
* @example
|
|
247
|
+
* 1. Get the signature of method mtd.
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
let signature = mtd.getSignature();
|
|
251
|
+
// ... ...
|
|
252
|
+
```
|
|
253
|
+
*/
|
|
90
254
|
getSignature() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
255
|
+
var _a;
|
|
256
|
+
return (_a = this.methodSignature) !== null && _a !== void 0 ? _a : this.methodDeclareSignatures[0];
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Set signatures of all declarations.
|
|
260
|
+
* It will reset the declaration signatures if they are already defined before.
|
|
261
|
+
* @param signatures - one signature or a list of signatures.
|
|
262
|
+
* @returns
|
|
263
|
+
*/
|
|
264
|
+
setDeclareSignatures(signatures) {
|
|
265
|
+
if (Array.isArray(signatures)) {
|
|
266
|
+
this.methodDeclareSignatures = signatures;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.methodDeclareSignatures = [signatures];
|
|
270
|
+
}
|
|
95
271
|
}
|
|
96
|
-
|
|
97
|
-
|
|
272
|
+
/**
|
|
273
|
+
* Reset signature of one declaration with the specified index.
|
|
274
|
+
* Will do nothing if the index doesn't exist.
|
|
275
|
+
* @param signature - new signature want to set.
|
|
276
|
+
* @param index - index of signature want to set.
|
|
277
|
+
* @returns
|
|
278
|
+
*/
|
|
279
|
+
setDeclareSignatureWithIndex(signature, index) {
|
|
280
|
+
if (this.methodDeclareSignatures === undefined || this.methodDeclareSignatures.length <= index) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.methodDeclareSignatures[index] = signature;
|
|
98
284
|
}
|
|
99
|
-
|
|
100
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Set signature of implementation.
|
|
287
|
+
* It will reset the implementation signature if it is already defined before.
|
|
288
|
+
* @param signature - signature of implementation.
|
|
289
|
+
* @returns
|
|
290
|
+
*/
|
|
291
|
+
setImplementationSignature(signature) {
|
|
292
|
+
this.methodSignature = signature;
|
|
101
293
|
}
|
|
102
|
-
|
|
103
|
-
this.
|
|
294
|
+
getSubSignature() {
|
|
295
|
+
return this.getSignature().getMethodSubSignature();
|
|
104
296
|
}
|
|
105
297
|
getGenericTypes() {
|
|
106
298
|
return this.genericTypes;
|
|
107
299
|
}
|
|
108
300
|
isGenericsMethod() {
|
|
109
|
-
return this.genericTypes
|
|
301
|
+
return this.genericTypes !== undefined;
|
|
110
302
|
}
|
|
111
303
|
setGenericTypes(genericTypes) {
|
|
112
304
|
this.genericTypes = genericTypes;
|
|
113
305
|
}
|
|
114
|
-
|
|
115
|
-
return this.
|
|
116
|
-
}
|
|
306
|
+
getBodyBuilder() {
|
|
307
|
+
return this.bodyBuilder;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get {@link ArkBody} of a Method.
|
|
311
|
+
* A {@link ArkBody} contains the CFG and actual instructions or operations to be executed for a method.
|
|
312
|
+
* It is analogous to the body of a function or method in high-level programming languages,
|
|
313
|
+
* which contains the statements and expressions that define what the function does.
|
|
314
|
+
* @returns The {@link ArkBody} of a method.
|
|
315
|
+
* @example
|
|
316
|
+
* 1. Get cfg or stmt through ArkBody.
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
let cfg = this.scene.getMethod()?.getBody().getCfg();
|
|
320
|
+
const body = arkMethod.getBody()
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
2. Get local variable through ArkBody.
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
arkClass.getDefaultArkMethod()?.getBody().getLocals.forEach(local=>{...})
|
|
327
|
+
let locals = arkFile().getDefaultClass().getDefaultArkMethod()?.getBody()?.getLocals();
|
|
328
|
+
```
|
|
329
|
+
*/
|
|
117
330
|
getBody() {
|
|
118
331
|
return this.body;
|
|
119
332
|
}
|
|
120
333
|
setBody(body) {
|
|
121
334
|
this.body = body;
|
|
122
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Get the CFG (i.e., control flow graph) of a method.
|
|
338
|
+
* The CFG is a graphical representation of all possible control flow paths within a method's body.
|
|
339
|
+
* A CFG consists of blocks, statements and goto control jumps.
|
|
340
|
+
* @returns The CFG (i.e., control flow graph) of a method.
|
|
341
|
+
* @example
|
|
342
|
+
* 1. get stmt through ArkBody cfg.
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
body = arkMethod.getBody();
|
|
346
|
+
const cfg = body.getCfg();
|
|
347
|
+
for (const threeAddressStmt of cfg.getStmts()) {
|
|
348
|
+
... ...
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
2. get blocks through ArkBody cfg.
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
const body = arkMethod.getBody();
|
|
356
|
+
const blocks = [...body.getCfg().getBlocks()];
|
|
357
|
+
for (let i=0; i<blocks.length; i++) {
|
|
358
|
+
const block = blocks[i];
|
|
359
|
+
... ...
|
|
360
|
+
for (const stmt of block.getStmts()) {
|
|
361
|
+
... ...
|
|
362
|
+
}
|
|
363
|
+
let text = "next;"
|
|
364
|
+
for (const next of block.getSuccessors()) {
|
|
365
|
+
text += blocks.indexOf(next) + ' ';
|
|
366
|
+
}
|
|
367
|
+
// ... ...
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
*/
|
|
123
371
|
getCfg() {
|
|
124
372
|
var _a;
|
|
125
373
|
return (_a = this.body) === null || _a === void 0 ? void 0 : _a.getCfg();
|
|
126
374
|
}
|
|
127
375
|
getOriginalCfg() {
|
|
128
|
-
|
|
129
|
-
return (_a = this.body) === null || _a === void 0 ? void 0 : _a.getOriginalCfg();
|
|
376
|
+
return undefined;
|
|
130
377
|
}
|
|
131
378
|
getParameterInstances() {
|
|
132
379
|
// 获取方法体中参数Local实例
|
|
@@ -142,7 +389,7 @@ class ArkMethod {
|
|
|
142
389
|
results.push(stmt.getLeftOp());
|
|
143
390
|
}
|
|
144
391
|
}
|
|
145
|
-
if (results.length
|
|
392
|
+
if (results.length === this.getParameters().length) {
|
|
146
393
|
return results;
|
|
147
394
|
}
|
|
148
395
|
}
|
|
@@ -182,17 +429,6 @@ class ArkMethod {
|
|
|
182
429
|
getReturnStmt() {
|
|
183
430
|
return this.getCfg().getStmts().filter(stmt => stmt instanceof Stmt_1.ArkReturnStmt);
|
|
184
431
|
}
|
|
185
|
-
getDecorators() {
|
|
186
|
-
return Array.from(this.modifiers).filter((item) => {
|
|
187
|
-
return item instanceof Decorator_1.Decorator;
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
hasBuilderDecorator() {
|
|
191
|
-
let decorators = this.getDecorators();
|
|
192
|
-
return decorators.filter((value) => {
|
|
193
|
-
return value.getKind() == 'Builder';
|
|
194
|
-
}).length != 0;
|
|
195
|
-
}
|
|
196
432
|
setViewTree(viewTree) {
|
|
197
433
|
this.viewTree = viewTree;
|
|
198
434
|
}
|
|
@@ -200,7 +436,7 @@ class ArkMethod {
|
|
|
200
436
|
return this.viewTree;
|
|
201
437
|
}
|
|
202
438
|
hasViewTree() {
|
|
203
|
-
return this.viewTree
|
|
439
|
+
return this.viewTree !== undefined;
|
|
204
440
|
}
|
|
205
441
|
setBodyBuilder(bodyBuilder) {
|
|
206
442
|
this.bodyBuilder = bodyBuilder;
|
|
@@ -230,5 +466,86 @@ class ArkMethod {
|
|
|
230
466
|
setAsteriskToken(asteriskToken) {
|
|
231
467
|
this.asteriskToken = asteriskToken;
|
|
232
468
|
}
|
|
469
|
+
validate() {
|
|
470
|
+
const declareSignatures = this.getDeclareSignatures();
|
|
471
|
+
const declareLineCols = this.getDeclareLineCols();
|
|
472
|
+
const signature = this.getImplementationSignature();
|
|
473
|
+
const lineCol = this.getLineCol();
|
|
474
|
+
if (declareSignatures === null && signature === null) {
|
|
475
|
+
return {
|
|
476
|
+
errCode: ArkError_1.ArkErrorCode.METHOD_SIGNATURE_UNDEFINED,
|
|
477
|
+
errMsg: 'methodDeclareSignatures and methodSignature are both undefined.'
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
if ((declareSignatures === null) !== (declareLineCols === null)) {
|
|
481
|
+
return {
|
|
482
|
+
errCode: ArkError_1.ArkErrorCode.METHOD_SIGNATURE_LINE_UNMATCHED,
|
|
483
|
+
errMsg: 'methodDeclareSignatures and methodDeclareLineCols are not matched.'
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
if (declareSignatures !== null && declareLineCols !== null && declareSignatures.length !== declareLineCols.length) {
|
|
487
|
+
return {
|
|
488
|
+
errCode: ArkError_1.ArkErrorCode.METHOD_SIGNATURE_LINE_UNMATCHED,
|
|
489
|
+
errMsg: 'methodDeclareSignatures and methodDeclareLineCols are not matched.'
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
if ((signature === null) !== (lineCol === null)) {
|
|
493
|
+
return {
|
|
494
|
+
errCode: ArkError_1.ArkErrorCode.METHOD_SIGNATURE_LINE_UNMATCHED,
|
|
495
|
+
errMsg: 'methodSignature and lineCol are not matched.'
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
return this.validateFields(['declaringArkClass']);
|
|
499
|
+
}
|
|
500
|
+
matchMethodSignature(args) {
|
|
501
|
+
var _a, _b, _c;
|
|
502
|
+
const signatures = (_a = this.methodDeclareSignatures) === null || _a === void 0 ? void 0 : _a.filter(f => {
|
|
503
|
+
const parameters = f.getMethodSubSignature().getParameters();
|
|
504
|
+
const max = parameters.length;
|
|
505
|
+
let min = 0;
|
|
506
|
+
while (min < max && !parameters[min].isOptional()) {
|
|
507
|
+
min++;
|
|
508
|
+
}
|
|
509
|
+
return args.length >= min && args.length <= max;
|
|
510
|
+
});
|
|
511
|
+
function match(paramType, argType, scene) {
|
|
512
|
+
var _a;
|
|
513
|
+
if (paramType instanceof Type_1.UnionType) {
|
|
514
|
+
let matched = false;
|
|
515
|
+
for (const e of paramType.getTypes()) {
|
|
516
|
+
if (argType.constructor === e.constructor) {
|
|
517
|
+
matched = true;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return matched;
|
|
522
|
+
}
|
|
523
|
+
else if (argType instanceof Type_1.FunctionType && paramType instanceof Type_1.ClassType &&
|
|
524
|
+
paramType.getClassSignature().getClassName().includes(EtsConst_1.CALL_BACK)) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
else if (paramType instanceof Type_1.NumberType && argType instanceof Type_1.ClassType && ArkClass_1.ClassCategory.ENUM ===
|
|
528
|
+
((_a = scene.getClass(argType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getCategory())) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
return argType.constructor === paramType.constructor;
|
|
532
|
+
}
|
|
533
|
+
const scene = this.getDeclaringArkFile().getScene();
|
|
534
|
+
return (_c = (_b = signatures === null || signatures === void 0 ? void 0 : signatures.find(p => {
|
|
535
|
+
const parameters = p.getMethodSubSignature().getParameters();
|
|
536
|
+
for (let i = 0; i < parameters.length; i++) {
|
|
537
|
+
if (!args[i]) {
|
|
538
|
+
return parameters[i].isOptional();
|
|
539
|
+
}
|
|
540
|
+
const paramType = parameters[i].getType();
|
|
541
|
+
const argType = args[i];
|
|
542
|
+
const isMatched = match(paramType, argType, scene);
|
|
543
|
+
if (!isMatched) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return true;
|
|
548
|
+
})) !== null && _b !== void 0 ? _b : signatures === null || signatures === void 0 ? void 0 : signatures[0]) !== null && _c !== void 0 ? _c : this.getSignature();
|
|
549
|
+
}
|
|
233
550
|
}
|
|
234
551
|
exports.ArkMethod = ArkMethod;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Decorator } from '../base/Decorator';
|
|
2
1
|
import { ArkExport, ExportInfo, ExportType } from './ArkExport';
|
|
3
2
|
import { ArkClass } from './ArkClass';
|
|
4
3
|
import { ArkFile } from './ArkFile';
|
|
5
4
|
import { ArkMethod } from './ArkMethod';
|
|
6
5
|
import { ClassSignature, NamespaceSignature } from './ArkSignature';
|
|
6
|
+
import { ArkBaseModel } from './ArkBaseModel';
|
|
7
|
+
import { ArkError } from '../common/ArkError';
|
|
7
8
|
/**
|
|
8
9
|
* @category core/model
|
|
9
10
|
*/
|
|
10
|
-
export declare class ArkNamespace implements ArkExport {
|
|
11
|
+
export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
|
|
11
12
|
private code;
|
|
12
13
|
private lineCol;
|
|
13
14
|
private declaringArkFile;
|
|
14
15
|
private declaringArkNamespace;
|
|
15
16
|
private declaringInstance;
|
|
16
|
-
private modifiers;
|
|
17
17
|
private exportInfos;
|
|
18
18
|
private defaultClass;
|
|
19
19
|
private namespaces;
|
|
@@ -41,14 +41,10 @@ export declare class ArkNamespace implements ArkExport {
|
|
|
41
41
|
setDeclaringArkFile(declaringArkFile: ArkFile): void;
|
|
42
42
|
getDeclaringArkNamespace(): ArkNamespace | null;
|
|
43
43
|
setDeclaringArkNamespace(declaringArkNamespace: ArkNamespace): void;
|
|
44
|
-
getModifiers(): Set<string | Decorator>;
|
|
45
|
-
addModifier(name: string | Decorator): void;
|
|
46
|
-
containsModifier(name: string): boolean;
|
|
47
44
|
getClass(classSignature: ClassSignature): ArkClass | null;
|
|
48
45
|
getClassWithName(Class: string): ArkClass | null;
|
|
49
46
|
getClasses(): ArkClass[];
|
|
50
47
|
addArkClass(arkClass: ArkClass): void;
|
|
51
|
-
isExported(): boolean;
|
|
52
48
|
getExportInfos(): ExportInfo[];
|
|
53
49
|
getExportInfoBy(name: string): ExportInfo | undefined;
|
|
54
50
|
addExportInfo(exportInfo: ExportInfo): void;
|
|
@@ -57,8 +53,10 @@ export declare class ArkNamespace implements ArkExport {
|
|
|
57
53
|
getAllMethodsUnderThisNamespace(): ArkMethod[];
|
|
58
54
|
getAllClassesUnderThisNamespace(): ArkClass[];
|
|
59
55
|
getAllNamespacesUnderThisNamespace(): ArkNamespace[];
|
|
60
|
-
getDecorators(): Decorator[];
|
|
61
56
|
getAnonymousClassNumber(): number;
|
|
62
57
|
getExportType(): ExportType;
|
|
58
|
+
removeArkClass(arkClass: ArkClass): boolean;
|
|
59
|
+
removeNamespace(namespace: ArkNamespace): boolean;
|
|
60
|
+
validate(): ArkError;
|
|
63
61
|
}
|
|
64
62
|
//# sourceMappingURL=ArkNamespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAa,YAAW,SAAS;IAC/D,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,qBAAqB,CAA6B;IAE1D,OAAO,CAAC,iBAAiB,CAA0B;IAEnD,OAAO,CAAC,WAAW,CAA0D;IAE7E,OAAO,CAAC,YAAY,CAAY;IAGhC,OAAO,CAAC,UAAU,CAA8D;IAChF,OAAO,CAAC,OAAO,CAAsD;IAErE,OAAO,CAAC,kBAAkB,CAAsB;IAEhD,OAAO,CAAC,oBAAoB,CAAa;;IAMlC,YAAY,CAAC,SAAS,EAAE,YAAY;IAIpC,YAAY,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI;IAKzE,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAIhE,aAAa,IAAI,YAAY,EAAE;IAI/B,YAAY,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI;IAI1D,YAAY;IAIZ,qBAAqB;IAIrB,OAAO;IAIP,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,OAAO;IAIP,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,oBAAoB;IAIpB,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,GAAG,YAAY;IAI9D,mBAAmB;IAInB,mBAAmB,CAAC,gBAAgB,EAAE,OAAO;IAI7C,wBAAwB;IAIxB,wBAAwB,CAAC,qBAAqB,EAAE,YAAY;IAI5D,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAKzD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAIhD,UAAU,IAAI,QAAQ,EAAE;IAIxB,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAI9B,cAAc,IAAI,UAAU,EAAE;IAU9B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIrD,aAAa,CAAC,UAAU,EAAE,UAAU;IAIpC,eAAe;IAIf,eAAe,CAAC,YAAY,EAAE,QAAQ;IAItC,+BAA+B,IAAI,SAAS,EAAE;IAW9C,+BAA+B,IAAI,QAAQ,EAAE;IAS7C,kCAAkC,IAAI,YAAY,EAAE;IASpD,uBAAuB;IAI9B,aAAa,IAAI,UAAU;IAIpB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAM3C,eAAe,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO;IAMjD,QAAQ,IAAI,QAAQ;CAG9B"}
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ArkNamespace = void 0;
|
|
18
|
-
const Decorator_1 = require("../base/Decorator");
|
|
19
18
|
const ArkExport_1 = require("./ArkExport");
|
|
20
19
|
const TSConst_1 = require("../common/TSConst");
|
|
21
20
|
const Position_1 = require("../base/Position");
|
|
21
|
+
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
22
22
|
/**
|
|
23
23
|
* @category core/model
|
|
24
24
|
*/
|
|
25
|
-
class ArkNamespace {
|
|
25
|
+
class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
26
26
|
constructor() {
|
|
27
|
+
super();
|
|
27
28
|
this.code = '';
|
|
28
29
|
this.lineCol = 0;
|
|
29
30
|
this.declaringArkNamespace = null;
|
|
30
|
-
this.modifiers = new Set();
|
|
31
31
|
this.exportInfos = new Map();
|
|
32
32
|
// name to model
|
|
33
33
|
this.namespaces = new Map(); // don't contain nested namespace
|
|
@@ -95,15 +95,6 @@ class ArkNamespace {
|
|
|
95
95
|
setDeclaringArkNamespace(declaringArkNamespace) {
|
|
96
96
|
this.declaringArkNamespace = declaringArkNamespace;
|
|
97
97
|
}
|
|
98
|
-
getModifiers() {
|
|
99
|
-
return this.modifiers;
|
|
100
|
-
}
|
|
101
|
-
addModifier(name) {
|
|
102
|
-
this.modifiers.add(name);
|
|
103
|
-
}
|
|
104
|
-
containsModifier(name) {
|
|
105
|
-
return this.modifiers.has(name);
|
|
106
|
-
}
|
|
107
98
|
getClass(classSignature) {
|
|
108
99
|
const className = classSignature.getClassName();
|
|
109
100
|
return this.getClassWithName(className);
|
|
@@ -117,9 +108,6 @@ class ArkNamespace {
|
|
|
117
108
|
addArkClass(arkClass) {
|
|
118
109
|
this.classes.set(arkClass.getName(), arkClass);
|
|
119
110
|
}
|
|
120
|
-
isExported() {
|
|
121
|
-
return this.containsModifier('ExportKeyword');
|
|
122
|
-
}
|
|
123
111
|
getExportInfos() {
|
|
124
112
|
const exportInfos = [];
|
|
125
113
|
this.exportInfos.forEach((value, key) => {
|
|
@@ -167,16 +155,24 @@ class ArkNamespace {
|
|
|
167
155
|
});
|
|
168
156
|
return namespaces;
|
|
169
157
|
}
|
|
170
|
-
getDecorators() {
|
|
171
|
-
return Array.from(this.modifiers).filter((item) => {
|
|
172
|
-
return item instanceof Decorator_1.Decorator;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
158
|
getAnonymousClassNumber() {
|
|
176
159
|
return this.anonymousClassNumber++;
|
|
177
160
|
}
|
|
178
161
|
getExportType() {
|
|
179
162
|
return ArkExport_1.ExportType.NAME_SPACE;
|
|
180
163
|
}
|
|
164
|
+
removeArkClass(arkClass) {
|
|
165
|
+
let rtn = this.classes.delete(arkClass.getName());
|
|
166
|
+
rtn && (rtn = this.getDeclaringArkFile().getScene().removeClass(arkClass));
|
|
167
|
+
return rtn;
|
|
168
|
+
}
|
|
169
|
+
removeNamespace(namespace) {
|
|
170
|
+
let rtn = this.namespaces.delete(namespace.getName());
|
|
171
|
+
rtn && (rtn = this.getDeclaringArkFile().getScene().removeNamespace(namespace));
|
|
172
|
+
return rtn;
|
|
173
|
+
}
|
|
174
|
+
validate() {
|
|
175
|
+
return this.validateFields(['declaringArkFile', 'declaringInstance', 'namespaceSignature', 'defaultClass']);
|
|
176
|
+
}
|
|
181
177
|
}
|
|
182
178
|
exports.ArkNamespace = ArkNamespace;
|