arkanalyzer 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/config/arkanalyzer.json +5 -0
- package/lib/Config.d.ts +2 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/core/base/Expr.d.ts +3 -0
- package/lib/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +22 -5
- package/lib/core/base/Ref.d.ts +1 -0
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +5 -2
- package/lib/core/base/Stmt.js +1 -1
- package/lib/core/base/Type.d.ts +25 -1
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +39 -2
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +33 -2
- package/lib/core/common/ArkValueTransformer.js +2 -2
- package/lib/core/common/CfgBuilder.d.ts.map +1 -1
- package/lib/core/common/CfgBuilder.js +3 -2
- package/lib/core/common/Const.d.ts +1 -0
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +3 -2
- package/lib/core/common/DummyMainCreater.d.ts +0 -6
- package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
- package/lib/core/common/DummyMainCreater.js +12 -160
- package/lib/core/common/EtsConst.d.ts +0 -3
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +1 -8
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +8 -2
- package/lib/core/common/IRUtils.d.ts +3 -2
- package/lib/core/common/IRUtils.d.ts.map +1 -1
- package/lib/core/common/IRUtils.js +27 -13
- 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 +14 -23
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +12 -5
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +21 -8
- package/lib/core/dataflow/DataflowProblem.d.ts +0 -1
- package/lib/core/dataflow/DataflowProblem.d.ts.map +1 -1
- package/lib/core/dataflow/DataflowProblem.js +0 -13
- package/lib/core/dataflow/Edge.d.ts +0 -4
- package/lib/core/dataflow/Edge.d.ts.map +1 -1
- package/lib/core/dataflow/Edge.js +1 -10
- package/lib/core/dataflow/UndefinedVariable.d.ts.map +1 -1
- package/lib/core/dataflow/UndefinedVariable.js +28 -21
- package/lib/core/dataflow/Util.d.ts +0 -2
- package/lib/core/dataflow/Util.d.ts.map +1 -1
- package/lib/core/dataflow/Util.js +1 -95
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +2 -2
- package/lib/core/model/ArkClass.d.ts +5 -0
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +10 -2
- package/lib/core/model/ArkExport.d.ts +3 -1
- package/lib/core/model/ArkExport.d.ts.map +1 -1
- package/lib/core/model/ArkExport.js +9 -3
- package/lib/core/model/ArkFile.d.ts +4 -4
- package/lib/core/model/ArkFile.d.ts.map +1 -1
- package/lib/core/model/ArkFile.js +7 -6
- package/lib/core/model/ArkMetadata.d.ts +14 -2
- package/lib/core/model/ArkMetadata.d.ts.map +1 -1
- package/lib/core/model/ArkMetadata.js +12 -1
- package/lib/core/model/ArkNamespace.d.ts.map +1 -1
- package/lib/core/model/ArkNamespace.js +4 -2
- package/lib/core/model/ArkSignature.d.ts +10 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +13 -1
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +44 -10
- package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkExportBuilder.js +6 -3
- package/lib/core/model/builder/ArkFieldBuilder.js +2 -2
- package/lib/core/model/builder/ArkImportBuilder.js +6 -6
- package/lib/core/model/builder/ArkMethodBuilder.js +3 -3
- package/lib/core/model/builder/ArkNamespaceBuilder.js +1 -1
- package/lib/core/model/builder/builderUtils.d.ts +2 -2
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +19 -5
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -6
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +7 -3
- package/lib/save/source/SourceField.d.ts.map +1 -1
- package/lib/save/source/SourceField.js +7 -3
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +7 -3
- package/lib/save/source/SourceModule.d.ts.map +1 -1
- package/lib/save/source/SourceModule.js +14 -6
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +8 -6
- package/lib/save/source/SourceStmt.d.ts +1 -0
- package/lib/save/source/SourceStmt.d.ts.map +1 -1
- package/lib/save/source/SourceStmt.js +39 -11
- package/lib/utils/AstTreeUtils.d.ts +5 -0
- package/lib/utils/AstTreeUtils.d.ts.map +1 -0
- package/lib/utils/AstTreeUtils.js +26 -0
- package/lib/utils/entryMethodUtils.d.ts +0 -2
- package/lib/utils/entryMethodUtils.d.ts.map +1 -1
- package/lib/utils/entryMethodUtils.js +1 -31
- package/package.json +3 -3
- package/lib/core/dataflow/TiantAnalysis.d.ts +0 -38
- package/lib/core/dataflow/TiantAnalysis.d.ts.map +0 -1
- package/lib/core/dataflow/TiantAnalysis.js +0 -340
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ArkMetadata = exports.ArkMetadataKind = void 0;
|
|
17
|
+
exports.CommentsMetadata = exports.ArkMetadata = exports.ArkMetadataKind = void 0;
|
|
18
18
|
var ArkMetadataKind;
|
|
19
19
|
(function (ArkMetadataKind) {
|
|
20
20
|
ArkMetadataKind[ArkMetadataKind["LEADING_COMMENTS"] = 0] = "LEADING_COMMENTS";
|
|
21
|
+
ArkMetadataKind[ArkMetadataKind["TRAILING_COMMENTS"] = 1] = "TRAILING_COMMENTS";
|
|
21
22
|
})(ArkMetadataKind = exports.ArkMetadataKind || (exports.ArkMetadataKind = {}));
|
|
22
23
|
/**
|
|
23
24
|
* ArkMetadata
|
|
@@ -42,3 +43,13 @@ class ArkMetadata {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
exports.ArkMetadata = ArkMetadata;
|
|
46
|
+
class CommentsMetadata {
|
|
47
|
+
constructor(comments) {
|
|
48
|
+
this.comments = [];
|
|
49
|
+
this.comments = comments;
|
|
50
|
+
}
|
|
51
|
+
getComments() {
|
|
52
|
+
return this.comments;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CommentsMetadata = CommentsMetadata;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,OAA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AI7C,wBAAwB;IAIxB,wBAAwB,CAAC,qBAAqB,EAAE,YAAY;IAI5D,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI;IAMzD,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ArkNamespace = void 0;
|
|
18
18
|
const ArkExport_1 = require("./ArkExport");
|
|
19
|
+
const ArkSignature_1 = require("./ArkSignature");
|
|
19
20
|
const TSConst_1 = require("../common/TSConst");
|
|
20
21
|
const Position_1 = require("../base/Position");
|
|
21
22
|
const ArkBaseModel_1 = require("./ArkBaseModel");
|
|
@@ -96,7 +97,8 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
|
|
|
96
97
|
this.declaringArkNamespace = declaringArkNamespace;
|
|
97
98
|
}
|
|
98
99
|
getClass(classSignature) {
|
|
99
|
-
const className = classSignature.
|
|
100
|
+
const className = classSignature instanceof ArkSignature_1.AliasClassSignature ? classSignature.getOriginName()
|
|
101
|
+
: classSignature.getClassName();
|
|
100
102
|
return this.getClassWithName(className);
|
|
101
103
|
}
|
|
102
104
|
getClassWithName(Class) {
|
|
@@ -56,10 +56,20 @@ export declare class ClassSignature {
|
|
|
56
56
|
toString(): string;
|
|
57
57
|
toMapKey(): string;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* `AliasClassSignature` is used to extend `ClassSignature`, preserving the actual name used during invocation.
|
|
61
|
+
*/
|
|
59
62
|
export declare class AliasClassSignature extends ClassSignature {
|
|
60
63
|
private readonly aliasName;
|
|
61
64
|
constructor(aliasName: string, signature: ClassSignature);
|
|
65
|
+
/**
|
|
66
|
+
* Returns the name used in the code.
|
|
67
|
+
*/
|
|
62
68
|
getClassName(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Return the original name of declared class
|
|
71
|
+
*/
|
|
72
|
+
getOriginName(): string;
|
|
63
73
|
}
|
|
64
74
|
export type BaseSignature = ClassSignature | NamespaceSignature;
|
|
65
75
|
export declare class FieldSignature {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkSignature.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkSignature.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,MAAM,MAAM,SAAS,GACjB,aAAa,GACX,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,cAAc,GACd,cAAc,CAAC;AAErB,MAAM,WAAW,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,GAAG,OAAO,CAMhG;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAK7F;AAcD,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAE/F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -133,14 +133,26 @@ class ClassSignature {
|
|
|
133
133
|
}
|
|
134
134
|
exports.ClassSignature = ClassSignature;
|
|
135
135
|
ClassSignature.DEFAULT = new ClassSignature(Const_1.UNKNOWN_CLASS_NAME, FileSignature.DEFAULT, null);
|
|
136
|
+
/**
|
|
137
|
+
* `AliasClassSignature` is used to extend `ClassSignature`, preserving the actual name used during invocation.
|
|
138
|
+
*/
|
|
136
139
|
class AliasClassSignature extends ClassSignature {
|
|
137
140
|
constructor(aliasName, signature) {
|
|
138
141
|
super(signature.getClassName(), signature.getDeclaringFileSignature(), signature.getDeclaringNamespaceSignature());
|
|
139
142
|
this.aliasName = aliasName;
|
|
140
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the name used in the code.
|
|
146
|
+
*/
|
|
141
147
|
getClassName() {
|
|
142
148
|
return this.aliasName;
|
|
143
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Return the original name of declared class
|
|
152
|
+
*/
|
|
153
|
+
getOriginName() {
|
|
154
|
+
return super.getClassName();
|
|
155
|
+
}
|
|
144
156
|
}
|
|
145
157
|
exports.AliasClassSignature = AliasClassSignature;
|
|
146
158
|
class FieldSignature {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkClassBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkClassBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ArkClassBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkClassBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AA8BtD,MAAM,MAAM,aAAa,GACrB,EAAE,CAAC,gBAAgB,GACnB,EAAE,CAAC,oBAAoB,GACvB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,iBAAiB,GACpB,EAAE,CAAC,uBAAuB,CAAC;AAU/B,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,QAG/G;AAED,wBAAgB,oCAAoC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAClD,MAAM,EAAE,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,QAI3G;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,EAC3B,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,QAOxF;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EACvD,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,QAYpG;AAED,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,QAAQ,EACjE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,QAazG;AAgBD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,QA2BhI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -56,6 +56,9 @@ const IRUtils_1 = require("../../common/IRUtils");
|
|
|
56
56
|
const ArkSignature_1 = require("../ArkSignature");
|
|
57
57
|
const ArkSignatureBuilder_1 = require("./ArkSignatureBuilder");
|
|
58
58
|
const Position_1 = require("../../base/Position");
|
|
59
|
+
const Type_1 = require("../../base/Type");
|
|
60
|
+
const BodyBuilder_1 = require("../../common/BodyBuilder");
|
|
61
|
+
const Expr_1 = require("../../base/Expr");
|
|
59
62
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ArkClassBuilder');
|
|
60
63
|
function buildDefaultArkClassFromArkFile(arkFile, defaultClass, astRoot) {
|
|
61
64
|
defaultClass.setDeclaringArkFile(arkFile);
|
|
@@ -136,7 +139,7 @@ function buildNormalArkClass(clsNode, cls, sourceFile, declaringMethod) {
|
|
|
136
139
|
default:
|
|
137
140
|
;
|
|
138
141
|
}
|
|
139
|
-
IRUtils_1.IRUtils.
|
|
142
|
+
IRUtils_1.IRUtils.setComments(cls, clsNode, sourceFile, cls.getDeclaringArkFile().getScene().getOptions());
|
|
140
143
|
}
|
|
141
144
|
exports.buildNormalArkClass = buildNormalArkClass;
|
|
142
145
|
function init4InstanceInitMethod(cls) {
|
|
@@ -327,6 +330,7 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
327
330
|
return;
|
|
328
331
|
}
|
|
329
332
|
buildMethodsForClass(clsNode, cls, sourceFile);
|
|
333
|
+
const staticBlockMethodSignatures = buildStaticBlocksForClass(clsNode, cls, sourceFile);
|
|
330
334
|
let instanceIRTransformer;
|
|
331
335
|
let staticIRTransformer;
|
|
332
336
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
@@ -336,32 +340,38 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
336
340
|
if (ohos_typescript_1.default.isEnumDeclaration(clsNode)) {
|
|
337
341
|
staticIRTransformer = new ArkIRTransformer_1.ArkIRTransformer(sourceFile, cls.getStaticInitMethod());
|
|
338
342
|
}
|
|
339
|
-
const
|
|
340
|
-
const
|
|
343
|
+
const staticInitStmts = [];
|
|
344
|
+
const instanceInitStmts = [];
|
|
345
|
+
let staticBlockId = 0;
|
|
341
346
|
clsNode.members.forEach((member) => {
|
|
342
347
|
if (ohos_typescript_1.default.isPropertyDeclaration(member) || ohos_typescript_1.default.isPropertySignature(member)) {
|
|
343
348
|
const arkField = (0, ArkFieldBuilder_1.buildProperty2ArkField)(member, sourceFile, cls);
|
|
344
349
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
345
350
|
if (arkField.isStatic()) {
|
|
346
351
|
getInitStmts(staticIRTransformer, arkField, member.initializer);
|
|
347
|
-
arkField.getInitializer().forEach(stmt =>
|
|
352
|
+
arkField.getInitializer().forEach(stmt => staticInitStmts.push(stmt));
|
|
348
353
|
}
|
|
349
354
|
else {
|
|
350
355
|
if (!instanceIRTransformer)
|
|
351
356
|
console.log(clsNode.getText(sourceFile));
|
|
352
357
|
getInitStmts(instanceIRTransformer, arkField, member.initializer);
|
|
353
|
-
arkField.getInitializer().forEach(stmt =>
|
|
358
|
+
arkField.getInitializer().forEach(stmt => instanceInitStmts.push(stmt));
|
|
354
359
|
}
|
|
355
360
|
}
|
|
356
361
|
}
|
|
357
362
|
else if (ohos_typescript_1.default.isEnumMember(member)) {
|
|
358
363
|
const arkField = (0, ArkFieldBuilder_1.buildProperty2ArkField)(member, sourceFile, cls);
|
|
359
364
|
getInitStmts(staticIRTransformer, arkField, member.initializer);
|
|
360
|
-
arkField.getInitializer().forEach(stmt =>
|
|
365
|
+
arkField.getInitializer().forEach(stmt => staticInitStmts.push(stmt));
|
|
361
366
|
}
|
|
362
367
|
else if (ohos_typescript_1.default.isIndexSignatureDeclaration(member)) {
|
|
363
368
|
(0, ArkFieldBuilder_1.buildIndexSignature2ArkField)(member, sourceFile, cls);
|
|
364
369
|
}
|
|
370
|
+
else if (ohos_typescript_1.default.isClassStaticBlockDeclaration(member)) {
|
|
371
|
+
const currStaticBlockMethodSig = staticBlockMethodSignatures[staticBlockId++];
|
|
372
|
+
const staticBlockInvokeExpr = new Expr_1.ArkStaticInvokeExpr(currStaticBlockMethodSig, []);
|
|
373
|
+
staticInitStmts.push(new Stmt_1.ArkInvokeStmt(staticBlockInvokeExpr));
|
|
374
|
+
}
|
|
365
375
|
else if (ohos_typescript_1.default.isSemicolonClassElement(member)) {
|
|
366
376
|
logger.debug('Skip these members.');
|
|
367
377
|
}
|
|
@@ -370,11 +380,11 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
370
380
|
}
|
|
371
381
|
});
|
|
372
382
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
373
|
-
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getInstanceInitMethod(),
|
|
374
|
-
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getStaticInitMethod(),
|
|
383
|
+
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getInstanceInitMethod(), instanceInitStmts, instanceIRTransformer.getThisLocal());
|
|
384
|
+
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getStaticInitMethod(), staticInitStmts, staticIRTransformer.getThisLocal());
|
|
375
385
|
}
|
|
376
386
|
if (ohos_typescript_1.default.isEnumDeclaration(clsNode)) {
|
|
377
|
-
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getStaticInitMethod(),
|
|
387
|
+
(0, ArkMethodBuilder_1.buildInitMethod)(cls.getStaticInitMethod(), staticInitStmts, staticIRTransformer.getThisLocal());
|
|
378
388
|
}
|
|
379
389
|
}
|
|
380
390
|
function buildMethodsForClass(clsNode, cls, sourceFile) {
|
|
@@ -393,6 +403,30 @@ function buildMethodsForClass(clsNode, cls, sourceFile) {
|
|
|
393
403
|
}
|
|
394
404
|
});
|
|
395
405
|
}
|
|
406
|
+
function buildStaticBlocksForClass(clsNode, cls, sourceFile) {
|
|
407
|
+
let staticInitBlockId = 0;
|
|
408
|
+
const staticBlockMethodSignatures = [];
|
|
409
|
+
clsNode.members.forEach((member) => {
|
|
410
|
+
if (ohos_typescript_1.default.isClassStaticBlockDeclaration(member)) {
|
|
411
|
+
const staticBlockMethod = new ArkMethod_1.ArkMethod();
|
|
412
|
+
staticBlockMethod.setDeclaringArkClass(cls);
|
|
413
|
+
staticBlockMethod.setIsGeneratedFlag(true);
|
|
414
|
+
staticBlockMethod.setCode(member.getText(sourceFile));
|
|
415
|
+
const methodName = Const_1.STATIC_BLOCK_METHOD_NAME_PREFIX + staticInitBlockId++;
|
|
416
|
+
const methodSubSignature = new ArkSignature_1.MethodSubSignature(methodName, [], Type_1.VoidType.getInstance(), true);
|
|
417
|
+
const methodSignature = new ArkSignature_1.MethodSignature(cls.getSignature(), methodSubSignature);
|
|
418
|
+
staticBlockMethodSignatures.push(methodSignature);
|
|
419
|
+
staticBlockMethod.setImplementationSignature(methodSignature);
|
|
420
|
+
const { line, character } = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, member.getStart(sourceFile));
|
|
421
|
+
staticBlockMethod.setLine(line + 1);
|
|
422
|
+
staticBlockMethod.setColumn(character + 1);
|
|
423
|
+
let bodyBuilder = new BodyBuilder_1.BodyBuilder(staticBlockMethod.getSignature(), member, staticBlockMethod, sourceFile);
|
|
424
|
+
staticBlockMethod.setBodyBuilder(bodyBuilder);
|
|
425
|
+
cls.addMethod(staticBlockMethod);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
return staticBlockMethodSignatures;
|
|
429
|
+
}
|
|
396
430
|
function getInitStmts(transformer, field, initNode) {
|
|
397
431
|
if (initNode) {
|
|
398
432
|
const stmts = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkExportBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkExportBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAOrC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC;AAE1E,iBAAS,eAAe,CAAC,WAAW,EAAE,SAAS,EAAE,OAA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B,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE,CAiBlI;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE,CAexI;AAED,wBAAgB,UAAU,CAAC,aAAa,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,SAAS,GAAG,OAAO,CAU5F"}
|
|
@@ -74,7 +74,8 @@ function buildExportDeclaration(node, sourceFile, arkFile) {
|
|
|
74
74
|
.exportFrom(exportFrom)
|
|
75
75
|
.originTsPosition(originTsPosition)
|
|
76
76
|
.declaringArkFile(arkFile)
|
|
77
|
-
.setLeadingComments(IRUtils_1.IRUtils.
|
|
77
|
+
.setLeadingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), true))
|
|
78
|
+
.setTrailingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), false))
|
|
78
79
|
.modifiers(modifiers);
|
|
79
80
|
if (element.propertyName && ohos_typescript_1.default.isIdentifier(element.propertyName)) {
|
|
80
81
|
builder.nameBeforeAs(element.propertyName.text);
|
|
@@ -90,7 +91,8 @@ function buildExportDeclaration(node, sourceFile, arkFile) {
|
|
|
90
91
|
.tsSourceCode(tsSourceCode)
|
|
91
92
|
.exportFrom(exportFrom)
|
|
92
93
|
.declaringArkFile(arkFile)
|
|
93
|
-
.setLeadingComments(IRUtils_1.IRUtils.
|
|
94
|
+
.setLeadingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), true))
|
|
95
|
+
.setTrailingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), false))
|
|
94
96
|
.originTsPosition(originTsPosition);
|
|
95
97
|
if (node.exportClause && ohos_typescript_1.default.isNamespaceExport(node.exportClause) && ohos_typescript_1.default.isIdentifier(node.exportClause.name)) { // just like: export * as xx from './yy'
|
|
96
98
|
exportInfos.push(builder1.exportClauseName(node.exportClause.name.text).build());
|
|
@@ -119,7 +121,8 @@ function buildExportAssignment(node, sourceFile, arkFile) {
|
|
|
119
121
|
.originTsPosition(originTsPosition)
|
|
120
122
|
.declaringArkFile(arkFile)
|
|
121
123
|
.exportClauseName(TSConst_1.DEFAULT)
|
|
122
|
-
.setLeadingComments(IRUtils_1.IRUtils.
|
|
124
|
+
.setLeadingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), true))
|
|
125
|
+
.setTrailingComments(IRUtils_1.IRUtils.getCommentsMetadata(node, sourceFile, arkFile.getScene().getOptions(), false));
|
|
123
126
|
if (ohos_typescript_1.default.isNewExpression(node.expression) && ohos_typescript_1.default.isClassExpression(node.expression.expression)) {
|
|
124
127
|
let cls = new ArkClass_1.ArkClass();
|
|
125
128
|
(0, ArkClassBuilder_1.buildNormalArkClassFromArkFile)(node.expression.expression, arkFile, cls, sourceFile);
|
|
@@ -101,7 +101,7 @@ function buildProperty2ArkField(member, sourceFile, cls) {
|
|
|
101
101
|
if (ohos_typescript_1.default.isPropertyDeclaration(member) && member.exclamationToken) {
|
|
102
102
|
field.setExclamationToken(true);
|
|
103
103
|
}
|
|
104
|
-
IRUtils_1.IRUtils.
|
|
104
|
+
IRUtils_1.IRUtils.setComments(field, member, sourceFile, cls.getDeclaringArkFile().getScene().getOptions());
|
|
105
105
|
cls.addField(field);
|
|
106
106
|
return field;
|
|
107
107
|
}
|
|
@@ -120,7 +120,7 @@ function buildIndexSignature2ArkField(member, sourceFile, cls) {
|
|
|
120
120
|
const fieldType = (0, builderUtils_1.buildGenericType)((0, builderUtils_1.tsNode2Type)(member.type, sourceFile, field), field);
|
|
121
121
|
const fieldSignature = new ArkSignature_1.FieldSignature(fieldName, cls.getSignature(), fieldType, true);
|
|
122
122
|
field.setSignature(fieldSignature);
|
|
123
|
-
IRUtils_1.IRUtils.
|
|
123
|
+
IRUtils_1.IRUtils.setComments(field, member, sourceFile, cls.getDeclaringArkFile().getScene().getOptions());
|
|
124
124
|
cls.addField(field);
|
|
125
125
|
}
|
|
126
126
|
exports.buildIndexSignature2ArkField = buildIndexSignature2ArkField;
|
|
@@ -52,7 +52,7 @@ function buildImportDeclarationNode(node, sourceFile, arkFile) {
|
|
|
52
52
|
let importInfo = new ArkImport_1.ImportInfo();
|
|
53
53
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
54
54
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
55
|
-
IRUtils_1.IRUtils.
|
|
55
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
56
56
|
importInfos.push(importInfo);
|
|
57
57
|
}
|
|
58
58
|
//just like: import fs from 'fs'
|
|
@@ -62,7 +62,7 @@ function buildImportDeclarationNode(node, sourceFile, arkFile) {
|
|
|
62
62
|
let importInfo = new ArkImport_1.ImportInfo();
|
|
63
63
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
64
64
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
65
|
-
IRUtils_1.IRUtils.
|
|
65
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
66
66
|
importInfos.push(importInfo);
|
|
67
67
|
}
|
|
68
68
|
// just like: import {xxx} from './yyy'
|
|
@@ -76,14 +76,14 @@ function buildImportDeclarationNode(node, sourceFile, arkFile) {
|
|
|
76
76
|
let importInfo = new ArkImport_1.ImportInfo();
|
|
77
77
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers, element.propertyName.text);
|
|
78
78
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
79
|
-
IRUtils_1.IRUtils.
|
|
79
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
80
80
|
importInfos.push(importInfo);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
let importInfo = new ArkImport_1.ImportInfo();
|
|
84
84
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
85
85
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
86
|
-
IRUtils_1.IRUtils.
|
|
86
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
87
87
|
importInfos.push(importInfo);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -99,7 +99,7 @@ function buildImportDeclarationNode(node, sourceFile, arkFile) {
|
|
|
99
99
|
let nameBeforeAs = '*';
|
|
100
100
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers, nameBeforeAs);
|
|
101
101
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
102
|
-
IRUtils_1.IRUtils.
|
|
102
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
103
103
|
importInfos.push(importInfo);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -121,7 +121,7 @@ function buildImportEqualsDeclarationNode(node, sourceFile, arkFile) {
|
|
|
121
121
|
let importInfo = new ArkImport_1.ImportInfo();
|
|
122
122
|
importInfo.build(importClauseName, importType, importFrom, originTsPosition, modifiers);
|
|
123
123
|
importInfo.setTsSourceCode(tsSourceCode);
|
|
124
|
-
IRUtils_1.IRUtils.
|
|
124
|
+
IRUtils_1.IRUtils.setComments(importInfo, node, sourceFile, arkFile.getScene().getOptions());
|
|
125
125
|
importInfos.push(importInfo);
|
|
126
126
|
}
|
|
127
127
|
return importInfos;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Copyright (c) 2024-2025 Huawei Device Co., Ltd.
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -122,7 +122,7 @@ function buildArkMethodFromArkClass(methodNode, declaringClass, mtd, sourceFile,
|
|
|
122
122
|
}
|
|
123
123
|
checkAndUpdateMethod(mtd, declaringClass);
|
|
124
124
|
declaringClass.addMethod(mtd);
|
|
125
|
-
IRUtils_1.IRUtils.
|
|
125
|
+
IRUtils_1.IRUtils.setComments(mtd, methodNode, sourceFile, mtd.getDeclaringArkFile().getScene().getOptions());
|
|
126
126
|
}
|
|
127
127
|
exports.buildArkMethodFromArkClass = buildArkMethodFromArkClass;
|
|
128
128
|
function buildMethodName(node, declaringClass, sourceFile, declaringMethod) {
|
|
@@ -387,7 +387,7 @@ function buildInitMethod(initMethod, fieldInitializerStmts, thisLocal) {
|
|
|
387
387
|
const assignStmt = new Stmt_1.ArkAssignStmt(thisLocal, new Ref_1.ArkThisRef(classType));
|
|
388
388
|
const block = new BasicBlock_1.BasicBlock();
|
|
389
389
|
block.addStmt(assignStmt);
|
|
390
|
-
const locals = new Set();
|
|
390
|
+
const locals = new Set([thisLocal]);
|
|
391
391
|
for (const stmt of fieldInitializerStmts) {
|
|
392
392
|
block.addStmt(stmt);
|
|
393
393
|
if (stmt.getDef() && stmt.getDef() instanceof Local_1.Local) {
|
|
@@ -102,7 +102,7 @@ function buildArkNamespace(node, declaringInstance, ns, sourceFile) {
|
|
|
102
102
|
else {
|
|
103
103
|
logger.warn("JSDocNamespaceDeclaration found.");
|
|
104
104
|
}
|
|
105
|
-
IRUtils_1.IRUtils.
|
|
105
|
+
IRUtils_1.IRUtils.setComments(ns, node, sourceFile, ns.getDeclaringArkFile().getScene().getOptions());
|
|
106
106
|
}
|
|
107
107
|
exports.buildArkNamespace = buildArkNamespace;
|
|
108
108
|
// TODO: check and update
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts, { HeritageClause, ParameterDeclaration, TypeNode, TypeParameterDeclaration } from 'ohos-typescript';
|
|
2
|
-
import { GenericType, Type } from '../../base/Type';
|
|
2
|
+
import { AliasType, GenericType, Type } from '../../base/Type';
|
|
3
3
|
import { ArkField } from '../ArkField';
|
|
4
4
|
import { ArkClass } from '../ArkClass';
|
|
5
5
|
import { ArkMethod } from '../ArkMethod';
|
|
@@ -12,7 +12,7 @@ export declare function buildModifiers(node: ts.Node): number;
|
|
|
12
12
|
export declare function buildHeritageClauses(heritageClauses?: ts.NodeArray<HeritageClause>): Map<string, string>;
|
|
13
13
|
export declare function buildTypeParameters(typeParameters: ts.NodeArray<TypeParameterDeclaration>, sourceFile: ts.SourceFile, arkInstance: ArkMethod | ArkClass): GenericType[];
|
|
14
14
|
export declare function buildParameters(params: ts.NodeArray<ParameterDeclaration>, arkInstance: ArkMethod | ArkField, sourceFile: ts.SourceFile): MethodParameter[];
|
|
15
|
-
export declare function buildGenericType(type: Type, arkInstance: ArkMethod | ArkField): Type;
|
|
15
|
+
export declare function buildGenericType(type: Type, arkInstance: ArkMethod | ArkField | AliasType): Type;
|
|
16
16
|
export declare function buildReturnType(node: TypeNode, sourceFile: ts.SourceFile, method: ArkMethod): Type;
|
|
17
17
|
export declare function tsNode2Type(typeNode: ts.TypeNode | ts.TypeParameterDeclaration, sourceFile: ts.SourceFile, arkInstance: ArkMethod | ArkClass | ArkField): Type;
|
|
18
18
|
export declare function buildTypeFromPreStr(preStr: string): Type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builderUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/builderUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,oBAAoB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC/G,OAAO,
|
|
1
|
+
{"version":3,"file":"builderUtils.d.ts","sourceRoot":"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E,WAAW,EAAE,SAAS,GAAG,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,qBA4GvI;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CA8ChG;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,QAM3F;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,wBAAwB,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAC9E,WAAW,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAkF9E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,QA8CjD"}
|
|
@@ -277,14 +277,19 @@ function buildParameters(params, arkInstance, sourceFile) {
|
|
|
277
277
|
exports.buildParameters = buildParameters;
|
|
278
278
|
function buildGenericType(type, arkInstance) {
|
|
279
279
|
function replace(urType) {
|
|
280
|
-
var _a, _b;
|
|
280
|
+
var _a, _b, _c;
|
|
281
281
|
const typeName = urType.getName();
|
|
282
282
|
let gType;
|
|
283
|
-
if (arkInstance instanceof
|
|
283
|
+
if (arkInstance instanceof Type_1.AliasType) {
|
|
284
284
|
gType = (_a = arkInstance.getGenericTypes()) === null || _a === void 0 ? void 0 : _a.find(f => f.getName() === typeName);
|
|
285
285
|
}
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
else {
|
|
287
|
+
if (arkInstance instanceof ArkMethod_1.ArkMethod) {
|
|
288
|
+
gType = (_b = arkInstance.getGenericTypes()) === null || _b === void 0 ? void 0 : _b.find(f => f.getName() === typeName);
|
|
289
|
+
}
|
|
290
|
+
if (!gType) {
|
|
291
|
+
gType = (_c = arkInstance.getDeclaringArkClass().getGenericsTypes()) === null || _c === void 0 ? void 0 : _c.find(f => f.getName() === typeName);
|
|
292
|
+
}
|
|
288
293
|
}
|
|
289
294
|
if (gType) {
|
|
290
295
|
return gType;
|
|
@@ -301,7 +306,10 @@ function buildGenericType(type, arkInstance) {
|
|
|
301
306
|
if (type instanceof Type_1.UnclearReferenceType) {
|
|
302
307
|
return replace(type);
|
|
303
308
|
}
|
|
304
|
-
else if (type instanceof Type_1.
|
|
309
|
+
else if (type instanceof Type_1.ClassType && arkInstance instanceof Type_1.AliasType) {
|
|
310
|
+
type.setRealGenericTypes(arkInstance.getGenericTypes());
|
|
311
|
+
}
|
|
312
|
+
else if (type instanceof Type_1.UnionType || type instanceof Type_1.TupleType) {
|
|
305
313
|
const types = type.getTypes();
|
|
306
314
|
for (let i = 0; i < types.length; i++) {
|
|
307
315
|
const mayType = types[i];
|
|
@@ -310,6 +318,12 @@ function buildGenericType(type, arkInstance) {
|
|
|
310
318
|
}
|
|
311
319
|
}
|
|
312
320
|
}
|
|
321
|
+
else if (type instanceof Type_1.ArrayType) {
|
|
322
|
+
const baseType = type.getBaseType();
|
|
323
|
+
if (baseType instanceof Type_1.UnclearReferenceType) {
|
|
324
|
+
type.setBaseType(replace(baseType));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
313
327
|
return type;
|
|
314
328
|
}
|
|
315
329
|
exports.buildGenericType = buildGenericType;
|
package/lib/index.d.ts
CHANGED
|
@@ -36,9 +36,8 @@ export { VisibleValue, Scope } from './core/common/VisibleValue';
|
|
|
36
36
|
export { DataflowProblem, FlowFunction } from './core/dataflow/DataflowProblem';
|
|
37
37
|
export { DataflowResult } from './core/dataflow/DataflowResult';
|
|
38
38
|
export { DataflowSolver } from './core/dataflow/DataflowSolver';
|
|
39
|
-
export {
|
|
39
|
+
export { PathEdgePoint, PathEdge } from './core/dataflow/Edge';
|
|
40
40
|
export { Fact } from './core/dataflow/Fact';
|
|
41
|
-
export { TiantAnalysisChecker, TiantAnalysisSolver } from './core/dataflow/TiantAnalysis';
|
|
42
41
|
export { UndefinedVariableChecker, UndefinedVariableSolver } from './core/dataflow/UndefinedVariable';
|
|
43
42
|
export { BasicBlock } from './core/graph/BasicBlock';
|
|
44
43
|
export { Cfg } from './core/graph/Cfg';
|
|
@@ -76,4 +75,7 @@ export * from './utils/FileUtils';
|
|
|
76
75
|
export * from './utils/getAllFiles';
|
|
77
76
|
export * from './utils/json5parser';
|
|
78
77
|
export * from './utils/pathTransfer';
|
|
78
|
+
export * from './utils/AstTreeUtils';
|
|
79
|
+
import ts from 'ohos-typescript';
|
|
80
|
+
export { ts };
|
|
79
81
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAG5E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGzE,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAG9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAGvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACh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Ac,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -27,9 +27,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
27
27
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
28
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
30
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
32
|
-
exports.ViewTreePrinter = exports.GraphPrinter = exports.JsonPrinter = exports.SourceFilePrinter = exports.SourceNamespacePrinter = exports.SourceClassPrinter = exports.SourceMethodPrinter = exports.DotFilePrinter = exports.DotNamespacePrinter = exports.DotClassPrinter = exports.DotMethodPrinter = exports.PrinterBuilder = exports.Printer = exports.Scene = exports.SceneConfig = exports.ArkBody = exports.ImportInfo = exports.ExportInfo = exports.ArkField = exports.ArkMethod =
|
|
34
|
+
exports.ArkClass = exports.ArkNamespace = exports.ArkFile = exports.SCCDetection = exports.BaseExplicitGraph = exports.BaseNode = exports.BaseEdge = exports.DominanceTree = exports.DominanceFinder = exports.Cfg = exports.BasicBlock = exports.UndefinedVariableSolver = exports.UndefinedVariableChecker = exports.Fact = exports.PathEdge = exports.PathEdgePoint = exports.DataflowSolver = exports.DataflowResult = exports.DataflowProblem = exports.Scope = exports.VisibleValue = exports.ValueUtil = exports.TypeInference = exports.StmtUseReplacer = exports.RefUseReplacer = exports.IRUtils = exports.ExprUseReplacer = exports.DummyMainCreater = exports.ModelUtils = exports.FullPosition = exports.LineColPosition = exports.Local = exports.DefUseChain = exports.Decorator = exports.Constant = exports.DiffPTData = exports.PtsSet = exports.PointerAnalysisConfig = exports.PointerAnalysis = exports.PagBuilder = exports.CSFuncID = exports.DummyCallCreator = exports.KLimitedContextSensitive = exports.CallGraphBuilder = exports.CGStat = exports.PAGStat = exports.PTAStat = exports.RapidTypeAnalysis = exports.ClassHierarchyAnalysis = exports.AbstractAnalysis = void 0;
|
|
35
|
+
exports.ts = exports.ViewTreePrinter = exports.GraphPrinter = exports.JsonPrinter = exports.SourceFilePrinter = exports.SourceNamespacePrinter = exports.SourceClassPrinter = exports.SourceMethodPrinter = exports.DotFilePrinter = exports.DotNamespacePrinter = exports.DotClassPrinter = exports.DotMethodPrinter = exports.PrinterBuilder = exports.Printer = exports.Scene = exports.SceneConfig = exports.ArkBody = exports.ImportInfo = exports.ExportInfo = exports.ArkField = exports.ArkMethod = void 0;
|
|
33
36
|
// callgraph/algorithm
|
|
34
37
|
var AbstractAnalysis_1 = require("./callgraph/algorithm/AbstractAnalysis");
|
|
35
38
|
Object.defineProperty(exports, "AbstractAnalysis", { enumerable: true, get: function () { return AbstractAnalysis_1.AbstractAnalysis; } });
|
|
@@ -109,14 +112,10 @@ Object.defineProperty(exports, "DataflowResult", { enumerable: true, get: functi
|
|
|
109
112
|
var DataflowSolver_1 = require("./core/dataflow/DataflowSolver");
|
|
110
113
|
Object.defineProperty(exports, "DataflowSolver", { enumerable: true, get: function () { return DataflowSolver_1.DataflowSolver; } });
|
|
111
114
|
var Edge_1 = require("./core/dataflow/Edge");
|
|
112
|
-
Object.defineProperty(exports, "Edge", { enumerable: true, get: function () { return Edge_1.Edge; } });
|
|
113
115
|
Object.defineProperty(exports, "PathEdgePoint", { enumerable: true, get: function () { return Edge_1.PathEdgePoint; } });
|
|
114
116
|
Object.defineProperty(exports, "PathEdge", { enumerable: true, get: function () { return Edge_1.PathEdge; } });
|
|
115
117
|
var Fact_1 = require("./core/dataflow/Fact");
|
|
116
118
|
Object.defineProperty(exports, "Fact", { enumerable: true, get: function () { return Fact_1.Fact; } });
|
|
117
|
-
var TiantAnalysis_1 = require("./core/dataflow/TiantAnalysis");
|
|
118
|
-
Object.defineProperty(exports, "TiantAnalysisChecker", { enumerable: true, get: function () { return TiantAnalysis_1.TiantAnalysisChecker; } });
|
|
119
|
-
Object.defineProperty(exports, "TiantAnalysisSolver", { enumerable: true, get: function () { return TiantAnalysis_1.TiantAnalysisSolver; } });
|
|
120
119
|
var UndefinedVariable_1 = require("./core/dataflow/UndefinedVariable");
|
|
121
120
|
Object.defineProperty(exports, "UndefinedVariableChecker", { enumerable: true, get: function () { return UndefinedVariable_1.UndefinedVariableChecker; } });
|
|
122
121
|
Object.defineProperty(exports, "UndefinedVariableSolver", { enumerable: true, get: function () { return UndefinedVariable_1.UndefinedVariableSolver; } });
|
|
@@ -191,3 +190,7 @@ __exportStar(require("./utils/FileUtils"), exports);
|
|
|
191
190
|
__exportStar(require("./utils/getAllFiles"), exports);
|
|
192
191
|
__exportStar(require("./utils/json5parser"), exports);
|
|
193
192
|
__exportStar(require("./utils/pathTransfer"), exports);
|
|
193
|
+
__exportStar(require("./utils/AstTreeUtils"), exports);
|
|
194
|
+
//ohos-typescript
|
|
195
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
196
|
+
exports.ts = ohos_typescript_1.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceClass.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceClass.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACvC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxB,OAAO,CAAC,WAAW,CAAoB;gBAEpB,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAW;IAM9C,wBAAwB,IAAI,YAAY,GAAG,SAAS;IAIpD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;
|
|
1
|
+
{"version":3,"file":"SourceClass.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceClass.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACvC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxB,OAAO,CAAC,WAAW,CAAoB;gBAEpB,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAW;IAM9C,wBAAwB,IAAI,YAAY,GAAG,SAAS;IAIpD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;IA0DrB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,eAAe;IAmBvB,SAAS,CAAC,YAAY,IAAI,IAAI,EAAE;IAgBhC,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,oBAAoB;CAU/B;AAED,qBAAa,kBAAmB,SAAQ,WAAW;gBAC5B,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAW;IAI9C,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;CAIxB"}
|
|
@@ -42,9 +42,13 @@ class SourceClass extends SourceBase_1.SourceBase {
|
|
|
42
42
|
}
|
|
43
43
|
dump() {
|
|
44
44
|
this.printer.clear();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const commentsMetadata = this.cls.getMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS);
|
|
46
|
+
if (commentsMetadata instanceof ArkMetadata_1.CommentsMetadata) {
|
|
47
|
+
const comments = commentsMetadata.getComments();
|
|
48
|
+
comments.forEach((comment) => {
|
|
49
|
+
this.printer.writeIndent().writeLine(comment.content);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
48
52
|
if (this.cls.getCategory() === ArkClass_1.ClassCategory.OBJECT) {
|
|
49
53
|
return this.dumpObject();
|
|
50
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceField.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceField.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACvC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,WAAW,CAAsB;gBAEtB,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAa,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAOlF,OAAO,IAAI,MAAM;IAGjB,IAAI,IAAI,MAAM;
|
|
1
|
+
{"version":3,"file":"SourceField.d.ts","sourceRoot":"","sources":["../../../src/save/source/SourceField.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C;;GAEG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACvC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,WAAW,CAAsB;gBAEtB,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAa,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAOlF,OAAO,IAAI,MAAM;IAGjB,IAAI,IAAI,MAAM;CAwCxB"}
|