arkanalyzer 1.0.12 → 1.0.14
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/lib/Config.d.ts +1 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/callgraph/algorithm/AbstractAnalysis.js +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +1 -1
- package/lib/core/base/Ref.js +1 -1
- package/lib/core/common/ArkIRTransformer.d.ts +2 -1
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +83 -59
- package/lib/core/common/ArkValueTransformer.d.ts +6 -1
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +228 -152
- package/lib/core/common/Builtin.d.ts +3 -1
- package/lib/core/common/Builtin.d.ts.map +1 -1
- package/lib/core/common/Builtin.js +3 -0
- package/lib/core/common/CfgBuilder.js +8 -8
- 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/ValueUtil.d.ts +2 -2
- package/lib/core/common/ValueUtil.d.ts.map +1 -1
- package/lib/core/graph/BasicBlock.js +1 -1
- 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/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/ArkMethod.js +2 -2
- package/lib/core/model/builder/ArkClassBuilder.js +7 -7
- 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 +1 -1
- package/lib/core/model/builder/ArkNamespaceBuilder.js +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -1
- 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 +8 -4
- 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.map +1 -1
- package/lib/save/source/SourceStmt.js +7 -4
- 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/CfgStructualAnalysis.js +1 -1
- package/lib/utils/SparseBitVector.d.ts +3 -0
- package/lib/utils/SparseBitVector.d.ts.map +1 -1
- package/lib/utils/SparseBitVector.js +3 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassSignature, FileSignature } from '../model/ArkSignature';
|
|
1
|
+
import { ClassSignature, FileSignature, MethodSignature } from '../model/ArkSignature';
|
|
2
2
|
import { ClassType } from '../base/Type';
|
|
3
3
|
export declare class Builtin {
|
|
4
4
|
static OBJECT: string;
|
|
@@ -27,6 +27,8 @@ export declare class Builtin {
|
|
|
27
27
|
static ITERATOR_RESULT_CLASS_SIGNATURE: ClassSignature;
|
|
28
28
|
static ITERATOR_CLASS_TYPE: ClassType;
|
|
29
29
|
static ITERATOR_RESULT_CLASS_TYPE: ClassType;
|
|
30
|
+
static TO_STRING: string;
|
|
31
|
+
static TO_STRING_METHOD_SIGNATURE: MethodSignature;
|
|
30
32
|
private static buildBuiltInClasses;
|
|
31
33
|
private static buildBuiltInClassesFileSignature;
|
|
32
34
|
static buildBuiltInClassSignature(className: string): ClassSignature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Builtin.d.ts","sourceRoot":"","sources":["../../../src/core/common/Builtin.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Builtin.d.ts","sourceRoot":"","sources":["../../../src/core/common/Builtin.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAsB,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAErD,qBAAa,OAAO;IAGhB,OAAc,MAAM,SAAY;IAChC,OAAc,KAAK,SAAW;IAC9B,OAAc,GAAG,SAAS;IAC1B,OAAc,GAAG,SAAS;IAC1B,OAAc,MAAM,SAAY;IAEhC,OAAc,gBAAgB,cAA8B;IAG5D,OAAc,kBAAkB,SAAY;IAC5C,OAAc,eAAe,SAAkB;IAE/C,OAAc,+BAA+B,gBAA8C;IAC3F,OAAc,sBAAsB,iBAAgD;IACpF,OAAc,qBAAqB,iBAA+C;IAClF,OAAc,mBAAmB,iBAA6C;IAC9E,OAAc,mBAAmB,iBAA6C;IAC9E,OAAc,sBAAsB,iBAAgD;IACpF,OAAc,iBAAiB,YAA8C;IAC7E,OAAc,4BAA4B,8BAAwC;IAGlF,OAAc,iBAAiB,SAAc;IAC7C,OAAc,QAAQ,SAAc;IACpC,OAAc,aAAa,SAAU;IACrC,OAAc,eAAe,SAAoB;IACjD,OAAc,oBAAoB,SAAU;IAC5C,OAAc,qBAAqB,SAAW;IAE9C,OAAc,wBAAwB,iBAAkD;IACxF,OAAc,+BAA+B,iBAAyD;IACtG,OAAc,mBAAmB,YAAgD;IACjF,OAAc,0BAA0B,YAAuD;IAG/F,OAAc,SAAS,SAAc;IACrC,OAAc,0BAA0B,kBACyC;IAEjF,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAUlC,OAAO,CAAC,MAAM,CAAC,gCAAgC;WAIjC,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc;IAI3E,OAAO,CAAC,MAAM,CAAC,6BAA6B;CAS/C"}
|
|
@@ -76,3 +76,6 @@ Builtin.ITERATOR_CLASS_SIGNATURE = _a.buildBuiltInClassSignature(_a.ITERATOR);
|
|
|
76
76
|
Builtin.ITERATOR_RESULT_CLASS_SIGNATURE = _a.buildBuiltInClassSignature(_a.ITERATOR_RESULT);
|
|
77
77
|
Builtin.ITERATOR_CLASS_TYPE = new Type_1.ClassType(_a.ITERATOR_CLASS_SIGNATURE);
|
|
78
78
|
Builtin.ITERATOR_RESULT_CLASS_TYPE = new Type_1.ClassType(_a.ITERATOR_RESULT_CLASS_SIGNATURE);
|
|
79
|
+
// constants for string
|
|
80
|
+
Builtin.TO_STRING = 'toString';
|
|
81
|
+
Builtin.TO_STRING_METHOD_SIGNATURE = new ArkSignature_1.MethodSignature(ArkSignature_1.ClassSignature.DEFAULT, new ArkSignature_1.MethodSubSignature(_a.TO_STRING, [], Type_1.StringType.getInstance(), false));
|
|
@@ -1049,24 +1049,24 @@ class CfgBuilder {
|
|
|
1049
1049
|
buildCfgAndOriginalCfgForSimpleArrowFunction() {
|
|
1050
1050
|
const stmts = [];
|
|
1051
1051
|
const arkIRTransformer = new ArkIRTransformer_1.ArkIRTransformer(this.sourceFile, this.declaringMethod);
|
|
1052
|
-
|
|
1052
|
+
arkIRTransformer.prebuildStmts().forEach(stmt => stmts.push(stmt));
|
|
1053
1053
|
const expressionBodyNode = this.astRoot.body;
|
|
1054
1054
|
const expressionBodyStmts = [];
|
|
1055
1055
|
let { value: expressionBodyValue, valueOriginalPositions: expressionBodyPositions, stmts: tempStmts, } = arkIRTransformer.tsNodeToValueAndStmts(expressionBodyNode);
|
|
1056
|
-
expressionBodyStmts.push(
|
|
1056
|
+
tempStmts.forEach(stmt => expressionBodyStmts.push(stmt));
|
|
1057
1057
|
if (IRUtils_1.IRUtils.moreThanOneAddress(expressionBodyValue)) {
|
|
1058
1058
|
({
|
|
1059
1059
|
value: expressionBodyValue,
|
|
1060
1060
|
valueOriginalPositions: expressionBodyPositions,
|
|
1061
1061
|
stmts: tempStmts,
|
|
1062
1062
|
} = arkIRTransformer.generateAssignStmtForValue(expressionBodyValue, expressionBodyPositions));
|
|
1063
|
-
expressionBodyStmts.push(
|
|
1063
|
+
tempStmts.forEach(stmt => expressionBodyStmts.push(stmt));
|
|
1064
1064
|
}
|
|
1065
1065
|
const returnStmt = new Stmt_1.ArkReturnStmt(expressionBodyValue);
|
|
1066
1066
|
returnStmt.setOperandOriginalPositions([expressionBodyPositions[0], ...expressionBodyPositions]);
|
|
1067
1067
|
expressionBodyStmts.push(returnStmt);
|
|
1068
1068
|
arkIRTransformer.mapStmtsToTsStmt(expressionBodyStmts, expressionBodyNode);
|
|
1069
|
-
stmts.push(
|
|
1069
|
+
expressionBodyStmts.forEach(stmt => stmts.push(stmt));
|
|
1070
1070
|
const cfg = new Cfg_1.Cfg();
|
|
1071
1071
|
const blockInCfg = new BasicBlock_1.BasicBlock();
|
|
1072
1072
|
blockInCfg.setId(0);
|
|
@@ -1096,7 +1096,7 @@ class CfgBuilder {
|
|
|
1096
1096
|
// build block in Cfg
|
|
1097
1097
|
const stmtsInBlock = [];
|
|
1098
1098
|
if (i === 0) {
|
|
1099
|
-
|
|
1099
|
+
arkIRTransformer.prebuildStmts().forEach(stmt => stmtsInBlock.push(stmt));
|
|
1100
1100
|
}
|
|
1101
1101
|
const stmtsCnt = this.blocks[i].stmts.length;
|
|
1102
1102
|
if (this.blocks[i].stmts[stmtsCnt - 1].type === 'tryStatement') {
|
|
@@ -1419,7 +1419,7 @@ class CfgBuilder {
|
|
|
1419
1419
|
else {
|
|
1420
1420
|
const blockBuilderBeforeCondition = blockBuilder.lasts[0];
|
|
1421
1421
|
const blockBeforeCondition = blockBuilderToCfgBlock.get(blockBuilderBeforeCondition);
|
|
1422
|
-
blockBeforeCondition === null || blockBeforeCondition === void 0 ? void 0 : blockBeforeCondition.getStmts().push(
|
|
1422
|
+
stmtsInsertBeforeCondition.forEach(stmt => blockBeforeCondition === null || blockBeforeCondition === void 0 ? void 0 : blockBeforeCondition.getStmts().push(stmt));
|
|
1423
1423
|
}
|
|
1424
1424
|
if (dummyInitializerStmtIdx !== -1 && ifStmtIdx !== stmtsCnt - 1) {
|
|
1425
1425
|
// put incrementor statements into block which reenters condition
|
|
@@ -1481,7 +1481,7 @@ class CfgBuilder {
|
|
|
1481
1481
|
blockBuilderInsertBeforeCondition.lasts.push(...collectedBlockBuilders);
|
|
1482
1482
|
blockBuilderInsertBeforeCondition.nexts.push(conditionBlockBuilder);
|
|
1483
1483
|
const blockInsertBeforeCondition = new BasicBlock_1.BasicBlock();
|
|
1484
|
-
blockInsertBeforeCondition.getStmts().push(
|
|
1484
|
+
stmtsInsertBeforeCondition.forEach(stmt => blockInsertBeforeCondition.getStmts().push(stmt));
|
|
1485
1485
|
blockInsertBeforeCondition.getPredecessors().push(...collectedBlocks);
|
|
1486
1486
|
blockInsertBeforeCondition.addSuccessorBlock(block);
|
|
1487
1487
|
for (const prevBlockBuilder of collectedBlockBuilders) {
|
|
@@ -1557,7 +1557,7 @@ class CfgBuilder {
|
|
|
1557
1557
|
else {
|
|
1558
1558
|
// put incrementor statements into prev reenter block
|
|
1559
1559
|
const blockReenterCondition = blockBuilderToCfgBlock.get(blockBuildersReenterCondition[0]);
|
|
1560
|
-
blockReenterCondition === null || blockReenterCondition === void 0 ? void 0 : blockReenterCondition.getStmts().push(
|
|
1560
|
+
stmtsReenterCondition.forEach(stmt => blockReenterCondition === null || blockReenterCondition === void 0 ? void 0 : blockReenterCondition.getStmts().push(stmt));
|
|
1561
1561
|
}
|
|
1562
1562
|
}
|
|
1563
1563
|
buildTraps(blockBuilderToCfgBlock, blockBuildersBeforeTry, arkIRTransformer, basicBlockSet) {
|
|
@@ -2,14 +2,15 @@ import { Value } from '../base/Value';
|
|
|
2
2
|
import { Scene } from '../../Scene';
|
|
3
3
|
import ts from 'ohos-typescript';
|
|
4
4
|
import { SceneOptions } from '../../Config';
|
|
5
|
+
import { CommentsMetadata } from '../model/ArkMetadata';
|
|
5
6
|
import { Stmt } from '../base/Stmt';
|
|
6
7
|
import { ArkBaseModel } from '../model/ArkBaseModel';
|
|
7
8
|
import { FullPosition } from '../base/Position';
|
|
8
9
|
export declare class IRUtils {
|
|
9
10
|
static moreThanOneAddress(value: Value): boolean;
|
|
10
11
|
static generateTextForStmt(scene: Scene): void;
|
|
11
|
-
static
|
|
12
|
-
static
|
|
12
|
+
static setComments(metadata: Stmt | ArkBaseModel, node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions): void;
|
|
13
|
+
static getCommentsMetadata(node: ts.Node, sourceFile: ts.SourceFile, options: SceneOptions, isLeading: boolean): CommentsMetadata;
|
|
13
14
|
static isTempLocal(value: Value): boolean;
|
|
14
15
|
static findOperandIdx(stmt: Stmt, operand: Value): number;
|
|
15
16
|
static adjustOperandOriginalPositions(stmt: Stmt, oldValue: Value, newValue: Value): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IRUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRUtils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"IRUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRUtils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAgC,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,qBAAa,OAAO;WACF,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;WAczC,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;WAWvC,WAAW,CAAC,QAAQ,EAAE,IAAI,GAAG,YAAY,EAC7B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,YAAY,GAAG,IAAI;WAYxC,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,EAC/D,SAAS,EAAE,OAAO,GAAG,gBAAgB;WA0BzD,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;WAIlC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM;WAYlD,8BAA8B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI;WA0ClF,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE;CAOxE"}
|
|
@@ -22,9 +22,9 @@ const Expr_1 = require("../base/Expr");
|
|
|
22
22
|
const Ref_1 = require("../base/Ref");
|
|
23
23
|
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
24
24
|
const ArkMetadata_1 = require("../model/ArkMetadata");
|
|
25
|
+
const Position_1 = require("../base/Position");
|
|
25
26
|
const Local_1 = require("../base/Local");
|
|
26
27
|
const Const_1 = require("./Const");
|
|
27
|
-
const Position_1 = require("../base/Position");
|
|
28
28
|
class IRUtils {
|
|
29
29
|
static moreThanOneAddress(value) {
|
|
30
30
|
if (value instanceof Expr_1.AbstractBinopExpr ||
|
|
@@ -47,23 +47,37 @@ class IRUtils {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
static
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS,
|
|
50
|
+
static setComments(metadata, node, sourceFile, options) {
|
|
51
|
+
const leadingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, true);
|
|
52
|
+
if (leadingCommentsMetadata.getComments().length > 0) {
|
|
53
|
+
metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS, leadingCommentsMetadata);
|
|
54
|
+
}
|
|
55
|
+
const trailingCommentsMetadata = this.getCommentsMetadata(node, sourceFile, options, false);
|
|
56
|
+
if (trailingCommentsMetadata.getComments().length > 0) {
|
|
57
|
+
metadata.setMetadata(ArkMetadata_1.ArkMetadataKind.TRAILING_COMMENTS, trailingCommentsMetadata);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
|
-
static
|
|
57
|
-
|
|
58
|
-
if (!options.enableLeadingComments) {
|
|
59
|
-
return comments;
|
|
60
|
+
static getCommentsMetadata(node, sourceFile, options, isLeading) {
|
|
61
|
+
const comments = [];
|
|
62
|
+
if ((isLeading && !options.enableLeadingComments) || (!isLeading && !options.enableTrailingComments)) {
|
|
63
|
+
return new ArkMetadata_1.CommentsMetadata(comments);
|
|
60
64
|
}
|
|
61
|
-
const commentRanges = ohos_typescript_1.default.getLeadingCommentRanges(
|
|
65
|
+
const commentRanges = (isLeading ? ohos_typescript_1.default.getLeadingCommentRanges(sourceFile.text, node.pos)
|
|
66
|
+
: ohos_typescript_1.default.getTrailingCommentRanges(sourceFile.text, node.end)) || []; // node.pos is the start position of
|
|
67
|
+
// leading comment, while node.end is the
|
|
68
|
+
// end position of the statement
|
|
69
|
+
const getPosition = (pos, end) => {
|
|
70
|
+
const start = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, pos);
|
|
71
|
+
const endPos = ohos_typescript_1.default.getLineAndCharacterOfPosition(sourceFile, end);
|
|
72
|
+
return new Position_1.FullPosition(start.line + 1, start.character + 1, endPos.line + 1, endPos.character + 1);
|
|
73
|
+
};
|
|
62
74
|
for (const range of commentRanges) {
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
comments.push({
|
|
76
|
+
content: sourceFile.text.substring(range.pos, range.end).replace(/\r\n/g, '\n'),
|
|
77
|
+
position: getPosition(range.pos, range.end),
|
|
78
|
+
});
|
|
65
79
|
}
|
|
66
|
-
return comments;
|
|
80
|
+
return new ArkMetadata_1.CommentsMetadata(comments);
|
|
67
81
|
}
|
|
68
82
|
static isTempLocal(value) {
|
|
69
83
|
return value instanceof Local_1.Local && value.getName().startsWith(Const_1.NAME_PREFIX);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Constant } from '../base/Constant';
|
|
1
|
+
import { Constant, StringConstant } from '../base/Constant';
|
|
2
2
|
export declare const EMPTY_STRING = "";
|
|
3
3
|
export declare class ValueUtil {
|
|
4
4
|
private static readonly NumberConstantCache;
|
|
5
|
-
|
|
5
|
+
static readonly EMPTY_STRING_CONSTANT: StringConstant;
|
|
6
6
|
static getOrCreateNumberConst(n: number): Constant;
|
|
7
7
|
static createStringConst(str: string): Constant;
|
|
8
8
|
static createConst(str: string): Constant;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueUtil.d.ts","sourceRoot":"","sources":["../../../src/core/common/ValueUtil.ts"],"names":[],"mappings":"AAeA,OAAO,EAEH,QAAQ,
|
|
1
|
+
{"version":3,"file":"ValueUtil.d.ts","sourceRoot":"","sources":["../../../src/core/common/ValueUtil.ts"],"names":[],"mappings":"AAeA,OAAO,EAEH,QAAQ,EAGR,cAAc,EAEjB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAoC;IAC/E,gBAAuB,qBAAqB,iBAAoC;WAElE,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ;WAS3C,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;WAOxC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;WAQlC,iBAAiB,IAAI,QAAQ;WAI7B,eAAe,IAAI,QAAQ;WAI3B,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ;CAG7D"}
|
|
@@ -3,6 +3,7 @@ import { ArkFile } from './ArkFile';
|
|
|
3
3
|
import { ArkSignature, ClassSignature, LocalSignature, MethodSignature, NamespaceSignature } from './ArkSignature';
|
|
4
4
|
import { ArkBaseModel, ModifierType } from './ArkBaseModel';
|
|
5
5
|
import { ArkError } from '../common/ArkError';
|
|
6
|
+
import { CommentsMetadata } from './ArkMetadata';
|
|
6
7
|
export type ExportSignature = NamespaceSignature | ClassSignature | MethodSignature | LocalSignature;
|
|
7
8
|
export declare enum ExportType {
|
|
8
9
|
NAME_SPACE = 0,
|
|
@@ -62,7 +63,8 @@ export declare class ExportInfo extends ArkBaseModel implements FromInfo {
|
|
|
62
63
|
declaringArkFile(value: ArkFile): any;
|
|
63
64
|
arkExport(value: ArkExport): any;
|
|
64
65
|
exportFrom(exportFrom: string): any;
|
|
65
|
-
setLeadingComments(
|
|
66
|
+
setLeadingComments(commentsMetadata: CommentsMetadata): any;
|
|
67
|
+
setTrailingComments(commentsMetadata: CommentsMetadata): any;
|
|
66
68
|
build(): ExportInfo;
|
|
67
69
|
};
|
|
68
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkExport.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkExport.ts"],"names":[],"mappings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129
129
|
}
|
|
130
130
|
return this;
|
|
131
131
|
}
|
|
132
|
-
setLeadingComments(
|
|
133
|
-
if (
|
|
134
|
-
this.exportInfo.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS,
|
|
132
|
+
setLeadingComments(commentsMetadata) {
|
|
133
|
+
if (commentsMetadata.getComments().length > 0) {
|
|
134
|
+
this.exportInfo.setMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS, commentsMetadata);
|
|
135
|
+
}
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
setTrailingComments(commentsMetadata) {
|
|
139
|
+
if (commentsMetadata.getComments().length > 0) {
|
|
140
|
+
this.exportInfo.setMetadata(ArkMetadata_1.ArkMetadataKind.TRAILING_COMMENTS, commentsMetadata);
|
|
135
141
|
}
|
|
136
142
|
return this;
|
|
137
143
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { FullPosition } from '../base/Position';
|
|
1
2
|
export declare enum ArkMetadataKind {
|
|
2
|
-
LEADING_COMMENTS = 0
|
|
3
|
+
LEADING_COMMENTS = 0,
|
|
4
|
+
TRAILING_COMMENTS = 1
|
|
5
|
+
}
|
|
6
|
+
export interface ArkMetadataType {
|
|
3
7
|
}
|
|
4
|
-
export type ArkMetadataType = string[];
|
|
5
8
|
/**
|
|
6
9
|
* ArkMetadata
|
|
7
10
|
* @example
|
|
@@ -17,4 +20,13 @@ export declare class ArkMetadata {
|
|
|
17
20
|
getMetadata(kind: ArkMetadataKind): ArkMetadataType | undefined;
|
|
18
21
|
setMetadata(kind: ArkMetadataKind, value: ArkMetadataType): void;
|
|
19
22
|
}
|
|
23
|
+
export type CommentItem = {
|
|
24
|
+
content: string;
|
|
25
|
+
position: FullPosition;
|
|
26
|
+
};
|
|
27
|
+
export declare class CommentsMetadata implements ArkMetadataType {
|
|
28
|
+
private comments;
|
|
29
|
+
constructor(comments: CommentItem[]);
|
|
30
|
+
getComments(): CommentItem[];
|
|
31
|
+
}
|
|
20
32
|
//# sourceMappingURL=ArkMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkMetadata.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkMetadata.ts"],"names":[],"mappings":"AAeA,oBAAY,eAAe;IACvB,gBAAgB,IAAA;
|
|
1
|
+
{"version":3,"file":"ArkMetadata.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkMetadata.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,oBAAY,eAAe;IACvB,gBAAgB,IAAA;IAChB,iBAAiB,IAAA;CACpB;AAED,MAAM,WAAW,eAAe;CAC/B;AAED;;;;;;;;;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;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAA;CACzB,CAAC;AAEF,qBAAa,gBAAiB,YAAW,eAAe;IACpD,OAAO,CAAC,QAAQ,CAAqB;gBAEzB,QAAQ,EAAE,WAAW,EAAE;IAI5B,WAAW,IAAI,WAAW,EAAE;CAGtC"}
|
|
@@ -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;
|
|
@@ -397,7 +397,7 @@ class ArkMethod extends ArkBaseModel_1.ArkBaseModel {
|
|
|
397
397
|
let stmts = [];
|
|
398
398
|
if (this.getCfg()) {
|
|
399
399
|
const cfg = this.getCfg();
|
|
400
|
-
|
|
400
|
+
cfg.getStmts().forEach(stmt => stmts.push(stmt));
|
|
401
401
|
}
|
|
402
402
|
let results = [];
|
|
403
403
|
for (let stmt of stmts) {
|
|
@@ -417,7 +417,7 @@ class ArkMethod extends ArkBaseModel_1.ArkBaseModel {
|
|
|
417
417
|
let stmts = [];
|
|
418
418
|
if (this.getCfg()) {
|
|
419
419
|
const cfg = this.getCfg();
|
|
420
|
-
|
|
420
|
+
cfg.getStmts().forEach(stmt => stmts.push(stmt));
|
|
421
421
|
}
|
|
422
422
|
for (let stmt of stmts) {
|
|
423
423
|
if (stmt instanceof Stmt_1.ArkAssignStmt) {
|
|
@@ -136,7 +136,7 @@ function buildNormalArkClass(clsNode, cls, sourceFile, declaringMethod) {
|
|
|
136
136
|
default:
|
|
137
137
|
;
|
|
138
138
|
}
|
|
139
|
-
IRUtils_1.IRUtils.
|
|
139
|
+
IRUtils_1.IRUtils.setComments(cls, clsNode, sourceFile, cls.getDeclaringArkFile().getScene().getOptions());
|
|
140
140
|
}
|
|
141
141
|
exports.buildNormalArkClass = buildNormalArkClass;
|
|
142
142
|
function init4InstanceInitMethod(cls) {
|
|
@@ -291,7 +291,7 @@ function buildObjectLiteralExpression2ArkClass(clsNode, cls, sourceFile, declari
|
|
|
291
291
|
const arkField = (0, ArkFieldBuilder_1.buildProperty2ArkField)(property, sourceFile, cls);
|
|
292
292
|
if (ohos_typescript_1.default.isPropertyAssignment(property)) {
|
|
293
293
|
getInitStmts(instanceIRTransformer, arkField, property.initializer);
|
|
294
|
-
|
|
294
|
+
arkField.getInitializer().forEach(stmt => instanceFieldInitializerStmts.push(stmt));
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
else {
|
|
@@ -344,20 +344,20 @@ function buildArkClassMembers(clsNode, cls, sourceFile) {
|
|
|
344
344
|
if (ohos_typescript_1.default.isClassDeclaration(clsNode) || ohos_typescript_1.default.isClassExpression(clsNode) || ohos_typescript_1.default.isStructDeclaration(clsNode)) {
|
|
345
345
|
if (arkField.isStatic()) {
|
|
346
346
|
getInitStmts(staticIRTransformer, arkField, member.initializer);
|
|
347
|
-
|
|
347
|
+
arkField.getInitializer().forEach(stmt => staticFieldInitializerStmts.push(stmt));
|
|
348
348
|
}
|
|
349
349
|
else {
|
|
350
350
|
if (!instanceIRTransformer)
|
|
351
351
|
console.log(clsNode.getText(sourceFile));
|
|
352
352
|
getInitStmts(instanceIRTransformer, arkField, member.initializer);
|
|
353
|
-
|
|
353
|
+
arkField.getInitializer().forEach(stmt => instanceFieldInitializerStmts.push(stmt));
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
else if (ohos_typescript_1.default.isEnumMember(member)) {
|
|
358
358
|
const arkField = (0, ArkFieldBuilder_1.buildProperty2ArkField)(member, sourceFile, cls);
|
|
359
359
|
getInitStmts(staticIRTransformer, arkField, member.initializer);
|
|
360
|
-
|
|
360
|
+
arkField.getInitializer().forEach(stmt => staticFieldInitializerStmts.push(stmt));
|
|
361
361
|
}
|
|
362
362
|
else if (ohos_typescript_1.default.isIndexSignatureDeclaration(member)) {
|
|
363
363
|
(0, ArkFieldBuilder_1.buildIndexSignature2ArkField)(member, sourceFile, cls);
|
|
@@ -397,11 +397,11 @@ function getInitStmts(transformer, field, initNode) {
|
|
|
397
397
|
if (initNode) {
|
|
398
398
|
const stmts = [];
|
|
399
399
|
let { value: initValue, valueOriginalPositions: initPositions, stmts: initStmts, } = transformer.tsNodeToValueAndStmts(initNode);
|
|
400
|
-
stmts.push(
|
|
400
|
+
initStmts.forEach(stmt => stmts.push(stmt));
|
|
401
401
|
if (IRUtils_1.IRUtils.moreThanOneAddress(initValue)) {
|
|
402
402
|
({ value: initValue, valueOriginalPositions: initPositions, stmts: initStmts } =
|
|
403
403
|
transformer.generateAssignStmtForValue(initValue, initPositions));
|
|
404
|
-
stmts.push(
|
|
404
|
+
initStmts.forEach(stmt => stmts.push(stmt));
|
|
405
405
|
}
|
|
406
406
|
const fieldRef = new Ref_1.ArkInstanceFieldRef(transformer.getThisLocal(), field.getSignature());
|
|
407
407
|
const fieldRefPositions = [Position_1.FullPosition.DEFAULT, Position_1.FullPosition.DEFAULT];
|
|
@@ -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,eA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H;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,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;
|
|
@@ -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) {
|
|
@@ -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
|
package/lib/index.d.ts
CHANGED
|
@@ -76,4 +76,7 @@ export * from './utils/FileUtils';
|
|
|
76
76
|
export * from './utils/getAllFiles';
|
|
77
77
|
export * from './utils/json5parser';
|
|
78
78
|
export * from './utils/pathTransfer';
|
|
79
|
+
export * from './utils/AstTreeUtils';
|
|
80
|
+
import ts from 'ohos-typescript';
|
|
81
|
+
export { ts };
|
|
79
82
|
//# 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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Ae,EAAE,MAAM,wBAAwB,CAAC;AAGzD,cAAc,4CAA4C,CAAC;AAG3D,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,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
34
|
exports.SCCDetection = exports.BaseExplicitGraph = exports.BaseNode = exports.BaseEdge = exports.DominanceTree = exports.DominanceFinder = exports.Cfg = exports.BasicBlock = exports.UndefinedVariableSolver = exports.UndefinedVariableChecker = exports.TiantAnalysisSolver = exports.TiantAnalysisChecker = exports.Fact = exports.PathEdge = exports.PathEdgePoint = exports.Edge = 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;
|
|
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 = exports.ArkClass = exports.ArkNamespace = exports.ArkFile = 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 = exports.ArkClass = exports.ArkNamespace = exports.ArkFile = 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; } });
|
|
@@ -191,3 +194,7 @@ __exportStar(require("./utils/FileUtils"), exports);
|
|
|
191
194
|
__exportStar(require("./utils/getAllFiles"), exports);
|
|
192
195
|
__exportStar(require("./utils/json5parser"), exports);
|
|
193
196
|
__exportStar(require("./utils/pathTransfer"), exports);
|
|
197
|
+
__exportStar(require("./utils/AstTreeUtils"), exports);
|
|
198
|
+
//ohos-typescript
|
|
199
|
+
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
200
|
+
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
|
}
|