arkanalyzer 1.0.16 → 1.0.18
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/callgraph/pointerAnalysis/Pag.d.ts +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/Pag.js +9 -0
- package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/PagBuilder.js +6 -2
- package/lib/core/base/Decorator.d.ts +1 -0
- package/lib/core/base/Decorator.d.ts.map +1 -1
- package/lib/core/base/Decorator.js +4 -1
- package/lib/core/base/Type.d.ts +45 -3
- package/lib/core/base/Type.d.ts.map +1 -1
- package/lib/core/base/Type.js +84 -4
- package/lib/core/common/ArkIRTransformer.d.ts +1 -0
- package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkIRTransformer.js +42 -23
- package/lib/core/common/ArkValueTransformer.d.ts +1 -0
- package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
- package/lib/core/common/ArkValueTransformer.js +45 -10
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +6 -0
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +5 -1
- package/lib/core/common/TypeInference.d.ts +1 -0
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +27 -8
- package/lib/core/{common → graph/builder}/CfgBuilder.d.ts +34 -46
- package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/CfgBuilder.js +1139 -0
- package/lib/core/graph/builder/ConditionBuilder.d.ts +16 -0
- package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/ConditionBuilder.js +252 -0
- package/lib/core/graph/builder/LoopBuilder.d.ts +21 -0
- package/lib/core/graph/builder/LoopBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/LoopBuilder.js +251 -0
- package/lib/core/graph/builder/SwitchBuilder.d.ts +12 -0
- package/lib/core/graph/builder/SwitchBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/SwitchBuilder.js +152 -0
- package/lib/core/graph/builder/TrapBuilder.d.ts +17 -0
- package/lib/core/graph/builder/TrapBuilder.d.ts.map +1 -0
- package/lib/core/graph/builder/TrapBuilder.js +272 -0
- package/lib/core/model/ArkMethod.d.ts +1 -1
- package/lib/core/model/ArkMethod.js +1 -1
- package/lib/core/model/ArkSignature.d.ts +9 -1
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +17 -1
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +2 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +1 -1
- package/lib/core/{common → model/builder}/BodyBuilder.d.ts +5 -5
- package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -0
- package/lib/core/{common → model/builder}/BodyBuilder.js +12 -12
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +31 -5
- package/lib/save/JsonPrinter.d.ts +1 -1
- package/lib/save/JsonPrinter.d.ts.map +1 -1
- package/lib/save/JsonPrinter.js +2 -2
- package/lib/save/PrinterBuilder.d.ts +22 -0
- package/lib/save/PrinterBuilder.d.ts.map +1 -1
- package/lib/save/PrinterBuilder.js +54 -1
- package/lib/save/arkir/ArkIRClassPrinter.d.ts +14 -0
- package/lib/save/arkir/ArkIRClassPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRClassPrinter.js +92 -0
- package/lib/save/arkir/ArkIRFieldPrinter.d.ts +12 -0
- package/lib/save/arkir/ArkIRFieldPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRFieldPrinter.js +64 -0
- package/lib/save/arkir/ArkIRFilePrinter.d.ts +13 -0
- package/lib/save/arkir/ArkIRFilePrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRFilePrinter.js +54 -0
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts +17 -0
- package/lib/save/arkir/ArkIRMethodPrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRMethodPrinter.js +159 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts +12 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.d.ts.map +1 -0
- package/lib/save/arkir/ArkIRNamespacePrinter.js +66 -0
- package/lib/save/base/BasePrinter.d.ts +24 -0
- package/lib/save/base/BasePrinter.d.ts.map +1 -0
- package/lib/save/base/BasePrinter.js +70 -0
- package/lib/save/base/ExportPrinter.d.ts +9 -0
- package/lib/save/base/ExportPrinter.d.ts.map +1 -0
- package/lib/save/base/ExportPrinter.js +67 -0
- package/lib/save/base/ImportPrinter.d.ts +10 -0
- package/lib/save/base/ImportPrinter.d.ts.map +1 -0
- package/lib/save/base/ImportPrinter.js +92 -0
- package/lib/save/{source/SourceUtils.d.ts → base/PrinterUtils.d.ts} +2 -2
- package/lib/save/{source/SourceUtils.d.ts.map → base/PrinterUtils.d.ts.map} +1 -1
- package/lib/save/{source/SourceUtils.js → base/PrinterUtils.js} +10 -10
- package/lib/save/source/SourceBase.d.ts +2 -11
- package/lib/save/source/SourceBase.d.ts.map +1 -1
- package/lib/save/source/SourceBase.js +3 -25
- package/lib/save/source/SourceBody.js +3 -3
- package/lib/save/source/SourceClass.d.ts +2 -1
- package/lib/save/source/SourceClass.d.ts.map +1 -1
- package/lib/save/source/SourceClass.js +18 -17
- package/lib/save/source/SourceFilePrinter.d.ts +1 -1
- package/lib/save/source/SourceFilePrinter.d.ts.map +1 -1
- package/lib/save/source/SourceFilePrinter.js +9 -10
- package/lib/save/source/SourceMethod.d.ts +1 -1
- package/lib/save/source/SourceMethod.d.ts.map +1 -1
- package/lib/save/source/SourceMethod.js +37 -22
- package/lib/save/source/SourceNamespace.d.ts.map +1 -1
- package/lib/save/source/SourceNamespace.js +6 -6
- 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 +29 -42
- package/lib/save/source/SourceTransformer.d.ts +3 -1
- package/lib/save/source/SourceTransformer.d.ts.map +1 -1
- package/lib/save/source/SourceTransformer.js +65 -29
- package/package.json +1 -1
- package/lib/core/common/BodyBuilder.d.ts.map +0 -1
- package/lib/core/common/CfgBuilder.d.ts.map +0 -1
- package/lib/core/common/CfgBuilder.js +0 -1886
- package/lib/save/source/SourceModule.d.ts +0 -16
- package/lib/save/source/SourceModule.d.ts.map +0 -1
- package/lib/save/source/SourceModule.js +0 -125
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ArkIRMethodPrinter = void 0;
|
|
18
|
+
const Type_1 = require("../../core/base/Type");
|
|
19
|
+
const ArkStream_1 = require("../ArkStream");
|
|
20
|
+
const Stmt_1 = require("../../core/base/Stmt");
|
|
21
|
+
const ArkMetadata_1 = require("../../core/model/ArkMetadata");
|
|
22
|
+
const BasePrinter_1 = require("../base/BasePrinter");
|
|
23
|
+
/**
|
|
24
|
+
* @category save
|
|
25
|
+
*/
|
|
26
|
+
class ArkIRMethodPrinter extends BasePrinter_1.BasePrinter {
|
|
27
|
+
constructor(method, indent = '') {
|
|
28
|
+
super(indent);
|
|
29
|
+
this.method = method;
|
|
30
|
+
}
|
|
31
|
+
dump() {
|
|
32
|
+
this.printer.clear();
|
|
33
|
+
const commentsMetadata = this.method.getMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS);
|
|
34
|
+
if (commentsMetadata instanceof ArkMetadata_1.CommentsMetadata) {
|
|
35
|
+
this.printComments(commentsMetadata);
|
|
36
|
+
}
|
|
37
|
+
this.printMethod(this.method);
|
|
38
|
+
return this.printer.toString();
|
|
39
|
+
}
|
|
40
|
+
getLine() {
|
|
41
|
+
let line = this.method.getLine();
|
|
42
|
+
if (line === null) {
|
|
43
|
+
line = 0;
|
|
44
|
+
}
|
|
45
|
+
if (line > 0) {
|
|
46
|
+
return line;
|
|
47
|
+
}
|
|
48
|
+
const stmts = [];
|
|
49
|
+
const cfg = this.method.getCfg();
|
|
50
|
+
if (cfg) {
|
|
51
|
+
cfg.getStmts()
|
|
52
|
+
.reverse()
|
|
53
|
+
.forEach((stmt) => stmts.push(stmt));
|
|
54
|
+
}
|
|
55
|
+
for (const stmt of stmts) {
|
|
56
|
+
if (stmt.getOriginPositionInfo().getLineNo() > 0) {
|
|
57
|
+
return stmt.getOriginPositionInfo().getLineNo();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return line;
|
|
61
|
+
}
|
|
62
|
+
printMethod(method) {
|
|
63
|
+
this.printDecorator(method.getDecorators());
|
|
64
|
+
this.printer.writeIndent().write(this.methodProtoToString(method));
|
|
65
|
+
// abstract function no body
|
|
66
|
+
if (!method.getBody()) {
|
|
67
|
+
this.printer.writeLine(';');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.printer.writeLine(' {');
|
|
71
|
+
this.printer.incIndent();
|
|
72
|
+
this.printBody(method);
|
|
73
|
+
this.printer.decIndent();
|
|
74
|
+
this.printer.writeIndent().writeLine('}');
|
|
75
|
+
this.printer.writeLine('');
|
|
76
|
+
}
|
|
77
|
+
printBody(method) {
|
|
78
|
+
if (method.getCfg()) {
|
|
79
|
+
this.printCfg(method.getCfg());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
methodProtoToString(method) {
|
|
83
|
+
let code = new ArkStream_1.ArkCodeBuffer();
|
|
84
|
+
code.writeSpace(this.modifiersToString(method.getModifiers()));
|
|
85
|
+
if (method.getAsteriskToken()) {
|
|
86
|
+
code.writeSpace('*');
|
|
87
|
+
}
|
|
88
|
+
code.write(this.resolveMethodName(method.getName()));
|
|
89
|
+
const genericTypes = method.getGenericTypes();
|
|
90
|
+
if (genericTypes && genericTypes.length > 0) {
|
|
91
|
+
let typeParameters = [];
|
|
92
|
+
genericTypes.forEach((genericType) => {
|
|
93
|
+
typeParameters.push(genericType.toString());
|
|
94
|
+
});
|
|
95
|
+
code.write(`<${genericTypes.join(', ')}>`);
|
|
96
|
+
}
|
|
97
|
+
let parameters = [];
|
|
98
|
+
method.getParameters().forEach((parameter) => {
|
|
99
|
+
let str = parameter.getName();
|
|
100
|
+
if (parameter.hasDotDotDotToken()) {
|
|
101
|
+
str = `...${parameter.getName()}`;
|
|
102
|
+
}
|
|
103
|
+
if (parameter.isOptional()) {
|
|
104
|
+
str += '?';
|
|
105
|
+
}
|
|
106
|
+
if (parameter.getType()) {
|
|
107
|
+
str += ': ' + parameter.getType().toString();
|
|
108
|
+
}
|
|
109
|
+
parameters.push(str);
|
|
110
|
+
});
|
|
111
|
+
code.write(`(${parameters.join(', ')})`);
|
|
112
|
+
const returnType = method.getReturnType();
|
|
113
|
+
if (method.getName() !== 'constructor' && !(returnType instanceof Type_1.UnknownType)) {
|
|
114
|
+
code.write(`: ${returnType.toString()}`);
|
|
115
|
+
}
|
|
116
|
+
return code.toString();
|
|
117
|
+
}
|
|
118
|
+
printCfg(cfg) {
|
|
119
|
+
let blocks = cfg.getBlocks();
|
|
120
|
+
if (blocks.size === 1) {
|
|
121
|
+
cfg.getStmts().map((stmt) => {
|
|
122
|
+
this.printer.writeIndent().writeLine(stmt.toString());
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
for (const block of blocks) {
|
|
127
|
+
this.printBasicBlock(block);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
printBasicBlock(block) {
|
|
132
|
+
let successors = block.getSuccessors();
|
|
133
|
+
this.printer.writeIndent().writeLine(`label${block.getId()}:`);
|
|
134
|
+
this.printer.incIndent();
|
|
135
|
+
if (successors.length === 1) {
|
|
136
|
+
block.getStmts().map((stmt) => {
|
|
137
|
+
this.printer.writeIndent().writeLine(stmt.toString());
|
|
138
|
+
});
|
|
139
|
+
this.printer.writeIndent().writeLine(`goto label${successors[0].getId()}`);
|
|
140
|
+
}
|
|
141
|
+
else if (successors.length === 2) {
|
|
142
|
+
for (const stmt of block.getStmts()) {
|
|
143
|
+
if (stmt instanceof Stmt_1.ArkIfStmt) {
|
|
144
|
+
this.printer.writeIndent().writeLine(`${stmt.toString()} goto label${successors[0].getId()} label${successors[1].getId()}`);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this.printer.writeIndent().writeLine(stmt.toString());
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
block.getStmts().map((stmt) => {
|
|
153
|
+
this.printer.writeIndent().writeLine(stmt.toString());
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
this.printer.decIndent().writeLine('');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.ArkIRMethodPrinter = ArkIRMethodPrinter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArkNamespace } from '../../core/model/ArkNamespace';
|
|
2
|
+
import { BasePrinter } from '../base/BasePrinter';
|
|
3
|
+
/**
|
|
4
|
+
* @category save
|
|
5
|
+
*/
|
|
6
|
+
export declare class ArkIRNamespacePrinter extends BasePrinter {
|
|
7
|
+
ns: ArkNamespace;
|
|
8
|
+
constructor(ns: ArkNamespace, indent?: string);
|
|
9
|
+
getLine(): number;
|
|
10
|
+
dump(): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ArkIRNamespacePrinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArkIRNamespacePrinter.d.ts","sourceRoot":"","sources":["../../../src/save/arkir/ArkIRNamespacePrinter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAQ,MAAM,qBAAqB,CAAC;AAIxD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IAClD,EAAE,EAAE,YAAY,CAAC;gBAEE,EAAE,EAAE,YAAY,EAAE,MAAM,GAAE,MAAW;IAKjD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;CAsCxB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ArkIRNamespacePrinter = void 0;
|
|
18
|
+
const ArkMetadata_1 = require("../../core/model/ArkMetadata");
|
|
19
|
+
const BasePrinter_1 = require("../base/BasePrinter");
|
|
20
|
+
const ArkIRClassPrinter_1 = require("./ArkIRClassPrinter");
|
|
21
|
+
const ExportPrinter_1 = require("../base/ExportPrinter");
|
|
22
|
+
/**
|
|
23
|
+
* @category save
|
|
24
|
+
*/
|
|
25
|
+
class ArkIRNamespacePrinter extends BasePrinter_1.BasePrinter {
|
|
26
|
+
constructor(ns, indent = '') {
|
|
27
|
+
super(indent);
|
|
28
|
+
this.ns = ns;
|
|
29
|
+
}
|
|
30
|
+
getLine() {
|
|
31
|
+
return this.ns.getLine();
|
|
32
|
+
}
|
|
33
|
+
dump() {
|
|
34
|
+
const commentsMetadata = this.ns.getMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS);
|
|
35
|
+
if (commentsMetadata instanceof ArkMetadata_1.CommentsMetadata) {
|
|
36
|
+
const comments = commentsMetadata.getComments();
|
|
37
|
+
comments.forEach((comment) => {
|
|
38
|
+
this.printer.writeIndent().writeLine(comment.content);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
this.printer.writeIndent().writeSpace(this.modifiersToString(this.ns.getModifiers()))
|
|
42
|
+
.writeLine(`namespace ${this.ns.getName()} {`);
|
|
43
|
+
this.printer.incIndent();
|
|
44
|
+
let items = [];
|
|
45
|
+
// print class
|
|
46
|
+
for (let cls of this.ns.getClasses()) {
|
|
47
|
+
items.push(new ArkIRClassPrinter_1.ArkIRClassPrinter(cls, this.printer.getIndent()));
|
|
48
|
+
}
|
|
49
|
+
// print namespace
|
|
50
|
+
for (let childNs of this.ns.getNamespaces()) {
|
|
51
|
+
items.push(new ArkIRNamespacePrinter(childNs, this.printer.getIndent()));
|
|
52
|
+
}
|
|
53
|
+
// print exportInfos
|
|
54
|
+
for (let exportInfo of this.ns.getExportInfos()) {
|
|
55
|
+
items.push(new ExportPrinter_1.ExportPrinter(exportInfo, this.printer.getIndent()));
|
|
56
|
+
}
|
|
57
|
+
items.sort((a, b) => a.getLine() - b.getLine());
|
|
58
|
+
items.forEach((v) => {
|
|
59
|
+
this.printer.write(v.dump());
|
|
60
|
+
});
|
|
61
|
+
this.printer.decIndent();
|
|
62
|
+
this.printer.writeIndent().writeLine('}');
|
|
63
|
+
return this.printer.toString();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ArkIRNamespacePrinter = ArkIRNamespacePrinter;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Decorator } from '../../core/base/Decorator';
|
|
2
|
+
import { ClassCategory } from '../../core/model/ArkClass';
|
|
3
|
+
import { CommentsMetadata } from '../../core/model/ArkMetadata';
|
|
4
|
+
import { Printer } from '../Printer';
|
|
5
|
+
export interface Dump {
|
|
6
|
+
getLine(): number;
|
|
7
|
+
dump(): string;
|
|
8
|
+
}
|
|
9
|
+
export interface PrinterOptions {
|
|
10
|
+
pureTs: boolean;
|
|
11
|
+
noMethodBody: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function setPrinterOptions(options: PrinterOptions): void;
|
|
14
|
+
export declare abstract class BasePrinter extends Printer implements Dump {
|
|
15
|
+
constructor(indent: string);
|
|
16
|
+
abstract getLine(): number;
|
|
17
|
+
protected printDecorator(docorator: Decorator[]): void;
|
|
18
|
+
protected printComments(commentsMetadata: CommentsMetadata): void;
|
|
19
|
+
protected modifiersToString(modifiers: number): string;
|
|
20
|
+
protected resolveMethodName(name: string): string;
|
|
21
|
+
protected classOriginTypeToString(clsCategory: ClassCategory): string;
|
|
22
|
+
static getPrinterOptions(): PrinterOptions;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=BasePrinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePrinter.d.ts","sourceRoot":"","sources":["../../../src/save/base/BasePrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,MAAM,WAAW,IAAI;IACjB,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACzB;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAE/D;AAED,8BAAsB,WAAY,SAAQ,OAAQ,YAAW,IAAI;gBAC1C,MAAM,EAAE,MAAM;IAGjC,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI;IAMtD,SAAS,CAAC,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IAOjE,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAKtD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAajD,SAAS,CAAC,uBAAuB,CAAC,WAAW,EAAE,aAAa,GAAG,MAAM;WAUvD,iBAAiB,IAAI,cAAc;CAGpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BasePrinter = exports.setPrinterOptions = void 0;
|
|
18
|
+
const ArkBaseModel_1 = require("../../core/model/ArkBaseModel");
|
|
19
|
+
const ArkClass_1 = require("../../core/model/ArkClass");
|
|
20
|
+
const Printer_1 = require("../Printer");
|
|
21
|
+
const PrinterUtils_1 = require("./PrinterUtils");
|
|
22
|
+
let printerOptions = { pureTs: false, noMethodBody: false };
|
|
23
|
+
function setPrinterOptions(options) {
|
|
24
|
+
printerOptions = Object.assign(Object.assign({}, printerOptions), options);
|
|
25
|
+
}
|
|
26
|
+
exports.setPrinterOptions = setPrinterOptions;
|
|
27
|
+
class BasePrinter extends Printer_1.Printer {
|
|
28
|
+
constructor(indent) {
|
|
29
|
+
super(indent);
|
|
30
|
+
}
|
|
31
|
+
printDecorator(docorator) {
|
|
32
|
+
docorator.forEach((value) => {
|
|
33
|
+
this.printer.writeIndent().writeLine(value.toString());
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
printComments(commentsMetadata) {
|
|
37
|
+
const comments = commentsMetadata.getComments();
|
|
38
|
+
comments.forEach((comment) => {
|
|
39
|
+
this.printer.writeIndent().writeLine(comment.content);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
modifiersToString(modifiers) {
|
|
43
|
+
let modifiersStr = (0, ArkBaseModel_1.modifiers2stringArray)(modifiers);
|
|
44
|
+
return modifiersStr.join(' ');
|
|
45
|
+
}
|
|
46
|
+
resolveMethodName(name) {
|
|
47
|
+
if (name === '_Constructor') {
|
|
48
|
+
return 'constructor';
|
|
49
|
+
}
|
|
50
|
+
if (name.startsWith('Get-')) {
|
|
51
|
+
return name.replace('Get-', 'get ');
|
|
52
|
+
}
|
|
53
|
+
if (name.startsWith('Set-')) {
|
|
54
|
+
return name.replace('Set-', 'set ');
|
|
55
|
+
}
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
classOriginTypeToString(clsCategory) {
|
|
59
|
+
if (printerOptions.pureTs) {
|
|
60
|
+
if (clsCategory === ArkClass_1.ClassCategory.STRUCT) {
|
|
61
|
+
clsCategory = ArkClass_1.ClassCategory.CLASS;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return PrinterUtils_1.PrinterUtils.classOriginTypeToString.get(clsCategory);
|
|
65
|
+
}
|
|
66
|
+
static getPrinterOptions() {
|
|
67
|
+
return printerOptions;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.BasePrinter = BasePrinter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExportInfo } from '../../core/model/ArkExport';
|
|
2
|
+
import { BasePrinter } from './BasePrinter';
|
|
3
|
+
export declare class ExportPrinter extends BasePrinter {
|
|
4
|
+
info: ExportInfo;
|
|
5
|
+
constructor(info: ExportInfo, indent?: string);
|
|
6
|
+
getLine(): number;
|
|
7
|
+
dump(): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ExportPrinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportPrinter.d.ts","sourceRoot":"","sources":["../../../src/save/base/ExportPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAc,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,aAAc,SAAQ,WAAW;IAC1C,IAAI,EAAE,UAAU,CAAC;gBAEE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAE,MAAW;IAKjD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;CAuCxB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ExportPrinter = void 0;
|
|
18
|
+
const ArkExport_1 = require("../../core/model/ArkExport");
|
|
19
|
+
const ArkMetadata_1 = require("../../core/model/ArkMetadata");
|
|
20
|
+
const BasePrinter_1 = require("./BasePrinter");
|
|
21
|
+
class ExportPrinter extends BasePrinter_1.BasePrinter {
|
|
22
|
+
constructor(info, indent = '') {
|
|
23
|
+
super(indent);
|
|
24
|
+
this.info = info;
|
|
25
|
+
}
|
|
26
|
+
getLine() {
|
|
27
|
+
return this.info.getOriginTsPosition().getLineNo();
|
|
28
|
+
}
|
|
29
|
+
dump() {
|
|
30
|
+
this.printer.clear();
|
|
31
|
+
const commentsMetadata = this.info.getMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS);
|
|
32
|
+
if (commentsMetadata instanceof ArkMetadata_1.CommentsMetadata) {
|
|
33
|
+
this.printComments(commentsMetadata);
|
|
34
|
+
}
|
|
35
|
+
if (!this.info.getFrom() && (this.info.isExport() ||
|
|
36
|
+
this.info.getExportClauseType() === ArkExport_1.ExportType.LOCAL ||
|
|
37
|
+
this.info.getExportClauseType() === ArkExport_1.ExportType.TYPE)) {
|
|
38
|
+
return this.printer.toString();
|
|
39
|
+
}
|
|
40
|
+
if (this.info.getExportClauseName() === '*') {
|
|
41
|
+
// just like: export * as xx from './yy'
|
|
42
|
+
if (this.info.getNameBeforeAs() && this.info.getNameBeforeAs() !== '*') {
|
|
43
|
+
this.printer
|
|
44
|
+
.writeIndent()
|
|
45
|
+
.write(`export ${this.info.getNameBeforeAs()} as ${this.info.getExportClauseName()}`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.printer.writeIndent().write(`export ${this.info.getExportClauseName()}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// just like: export {xxx as x} from './yy'
|
|
53
|
+
if (this.info.getNameBeforeAs()) {
|
|
54
|
+
this.printer.write(`export {${this.info.getNameBeforeAs()} as ${this.info.getExportClauseName()}}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.printer.write(`export {${this.info.getExportClauseName()}}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (this.info.getFrom()) {
|
|
61
|
+
this.printer.write(` from '${this.info.getFrom()}'`);
|
|
62
|
+
}
|
|
63
|
+
this.printer.writeLine(';');
|
|
64
|
+
return this.printer.toString();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ExportPrinter = ExportPrinter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ImportInfo } from '../../core/model/ArkImport';
|
|
2
|
+
import { BasePrinter, Dump } from './BasePrinter';
|
|
3
|
+
export declare class ImportPrinter extends BasePrinter {
|
|
4
|
+
infos: ImportInfo[];
|
|
5
|
+
constructor(infos: ImportInfo[], indent?: string);
|
|
6
|
+
getLine(): number;
|
|
7
|
+
dump(): string;
|
|
8
|
+
}
|
|
9
|
+
export declare function printImports(imports: ImportInfo[], indent: string): Dump[];
|
|
10
|
+
//# sourceMappingURL=ImportPrinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportPrinter.d.ts","sourceRoot":"","sources":["../../../src/save/base/ImportPrinter.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAElD,qBAAa,aAAc,SAAQ,WAAW;IAC1C,KAAK,EAAE,UAAU,EAAE,CAAC;gBAED,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM,GAAE,MAAW;IAKpD,OAAO,IAAI,MAAM;IAIjB,IAAI,IAAI,MAAM;CA2CxB;AAeD,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,CAQ1E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.printImports = exports.ImportPrinter = void 0;
|
|
18
|
+
const ArkMetadata_1 = require("../../core/model/ArkMetadata");
|
|
19
|
+
const BasePrinter_1 = require("./BasePrinter");
|
|
20
|
+
class ImportPrinter extends BasePrinter_1.BasePrinter {
|
|
21
|
+
constructor(infos, indent = '') {
|
|
22
|
+
super(indent);
|
|
23
|
+
this.infos = infos;
|
|
24
|
+
}
|
|
25
|
+
getLine() {
|
|
26
|
+
return this.infos[0].getOriginTsPosition().getLineNo();
|
|
27
|
+
}
|
|
28
|
+
dump() {
|
|
29
|
+
const commentsMetadata = this.infos[0].getMetadata(ArkMetadata_1.ArkMetadataKind.LEADING_COMMENTS);
|
|
30
|
+
if (commentsMetadata instanceof ArkMetadata_1.CommentsMetadata) {
|
|
31
|
+
this.printComments(commentsMetadata);
|
|
32
|
+
}
|
|
33
|
+
let clauseNames = [];
|
|
34
|
+
let namedImports = [];
|
|
35
|
+
for (const info of this.infos) {
|
|
36
|
+
if (info.getImportType() === 'Identifier') {
|
|
37
|
+
// sample: import fs from 'fs'
|
|
38
|
+
clauseNames.push(info.getImportClauseName());
|
|
39
|
+
}
|
|
40
|
+
else if (info.getImportType() === 'NamedImports') {
|
|
41
|
+
// sample: import {xxx} from './yyy'
|
|
42
|
+
if (info.getNameBeforeAs()) {
|
|
43
|
+
namedImports.push(`${info.getNameBeforeAs()} as ${info.getImportClauseName()}`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
namedImports.push(info.getImportClauseName());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (info.getImportType() === 'NamespaceImport') {
|
|
50
|
+
// sample: import * as ts from 'ohos-typescript'
|
|
51
|
+
clauseNames.push(`* as ${info.getImportClauseName()}`);
|
|
52
|
+
}
|
|
53
|
+
else if (info.getImportType() === 'EqualsImport') {
|
|
54
|
+
// sample: import mmmm = require('./xxx')
|
|
55
|
+
this.printer
|
|
56
|
+
.writeIndent()
|
|
57
|
+
.writeLine(`import ${info.getImportClauseName()} = require('${info.getFrom()}');`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// sample: import '../xxx'
|
|
61
|
+
this.printer.writeIndent().writeLine(`import '${info.getFrom()}';`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (namedImports.length > 0) {
|
|
65
|
+
clauseNames.push(`{${namedImports.join(', ')}}`);
|
|
66
|
+
}
|
|
67
|
+
this.printer
|
|
68
|
+
.writeIndent()
|
|
69
|
+
.writeLine(`import ${clauseNames.join(', ')} from '${this.infos[0].getFrom()}';`);
|
|
70
|
+
return this.printer.toString();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ImportPrinter = ImportPrinter;
|
|
74
|
+
function mergeImportInfos(infos) {
|
|
75
|
+
let map = new Map();
|
|
76
|
+
for (let info of infos) {
|
|
77
|
+
let key = `${info.getOriginTsPosition().getLineNo()}-${info.getFrom()}`;
|
|
78
|
+
let merge = map.get(key) || [];
|
|
79
|
+
merge.push(info);
|
|
80
|
+
map.set(key, merge);
|
|
81
|
+
}
|
|
82
|
+
return map;
|
|
83
|
+
}
|
|
84
|
+
function printImports(imports, indent) {
|
|
85
|
+
let mergeImports = mergeImportInfos(imports);
|
|
86
|
+
let items = [];
|
|
87
|
+
for (const [_, importInfos] of mergeImports) {
|
|
88
|
+
items.push(new ImportPrinter(importInfos, indent));
|
|
89
|
+
}
|
|
90
|
+
return items;
|
|
91
|
+
}
|
|
92
|
+
exports.printImports = printImports;
|
|
@@ -4,7 +4,7 @@ import { ArkClass } from '../../core/model/ArkClass';
|
|
|
4
4
|
import { ClassSignature } from '../../core/model/ArkSignature';
|
|
5
5
|
import { ArkNamespace } from '../../core/model/ArkNamespace';
|
|
6
6
|
export declare const CLASS_CATEGORY_COMPONENT = 100;
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class PrinterUtils {
|
|
8
8
|
static classOriginTypeToString: Map<number, string>;
|
|
9
9
|
static isAnonymousClass(name: string): boolean;
|
|
10
10
|
static isDefaultClass(name: string): boolean;
|
|
@@ -22,4 +22,4 @@ export declare class SourceUtils {
|
|
|
22
22
|
static isIdentifierText(text: string): boolean;
|
|
23
23
|
static escape(text: string): string;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=PrinterUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"PrinterUtils.d.ts","sourceRoot":"","sources":["../../../src/save/base/PrinterUtils.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,qBAAqB,EAErB,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAiB,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAS3D,OAAO,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAM7D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,qBAAa,YAAY;IACrB,OAAc,uBAAuB,sBAQlC;WAEW,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIvC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIrC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIxC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI1C,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EAAE,EAAE,oBAAoB,GAAG,OAAO;WAqBvE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI7B,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM;WAOpC,cAAc,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO;WAcxD,iBAAiB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO;WAc3D,0BAA0B,CACpC,UAAU,EAAE,qBAAqB,EACjC,OAAO,GAAE,GAAG,CAAC,qBAAqB,CAAa,GAChD,OAAO;WA2BI,yBAAyB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO;WAUnE,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO;WAajE,4BAA4B,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,MAAM;WAoB9F,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAevC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAY7C"}
|
|
@@ -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
|
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.
|
|
43
|
+
exports.PrinterUtils = exports.CLASS_CATEGORY_COMPONENT = void 0;
|
|
44
44
|
const Constant_1 = require("../../core/base/Constant");
|
|
45
45
|
const Expr_1 = require("../../core/base/Expr");
|
|
46
46
|
const Local_1 = require("../../core/base/Local");
|
|
@@ -51,9 +51,9 @@ const logger_1 = __importStar(require("../../utils/logger"));
|
|
|
51
51
|
const Const_1 = require("../../core/common/Const");
|
|
52
52
|
const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
|
|
53
53
|
const Const_2 = require("../../core/common/Const");
|
|
54
|
-
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, '
|
|
54
|
+
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'PrinterUtils');
|
|
55
55
|
exports.CLASS_CATEGORY_COMPONENT = 100;
|
|
56
|
-
class
|
|
56
|
+
class PrinterUtils {
|
|
57
57
|
static isAnonymousClass(name) {
|
|
58
58
|
return name.startsWith(Const_1.ANONYMOUS_CLASS_PREFIX);
|
|
59
59
|
}
|
|
@@ -117,7 +117,7 @@ class SourceUtils {
|
|
|
117
117
|
visitor.add(invokeExpr);
|
|
118
118
|
let base = invokeExpr.getBase();
|
|
119
119
|
if (!(base instanceof Local_1.Local)) {
|
|
120
|
-
logger.error(`
|
|
120
|
+
logger.error(`PrinterUtils->isComponentAttributeInvoke illegal invoke expr ${invokeExpr}`);
|
|
121
121
|
return false;
|
|
122
122
|
}
|
|
123
123
|
let stmt = base.getDeclaringStmt();
|
|
@@ -126,10 +126,10 @@ class SourceUtils {
|
|
|
126
126
|
}
|
|
127
127
|
let rightOp = stmt.getRightOp();
|
|
128
128
|
if (rightOp instanceof Expr_1.ArkInstanceInvokeExpr) {
|
|
129
|
-
return
|
|
129
|
+
return PrinterUtils.isComponentAttributeInvoke(rightOp, visitor);
|
|
130
130
|
}
|
|
131
131
|
if (rightOp instanceof Expr_1.ArkStaticInvokeExpr) {
|
|
132
|
-
return
|
|
132
|
+
return PrinterUtils.isComponentCreate(rightOp);
|
|
133
133
|
}
|
|
134
134
|
return false;
|
|
135
135
|
}
|
|
@@ -166,7 +166,7 @@ class SourceUtils {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
let className = classSignature.getClassName();
|
|
169
|
-
if (className && className.length > 0 && !
|
|
169
|
+
if (className && className.length > 0 && !PrinterUtils.isDefaultClass(className)) {
|
|
170
170
|
code.push(className);
|
|
171
171
|
}
|
|
172
172
|
return code.join('.');
|
|
@@ -196,8 +196,8 @@ class SourceUtils {
|
|
|
196
196
|
.replace(/\"/g, '\\"');
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
exports.
|
|
200
|
-
|
|
199
|
+
exports.PrinterUtils = PrinterUtils;
|
|
200
|
+
PrinterUtils.classOriginTypeToString = new Map([
|
|
201
201
|
[ArkClass_1.ClassCategory.CLASS, 'class'],
|
|
202
202
|
[ArkClass_1.ClassCategory.STRUCT, 'struct'],
|
|
203
203
|
[ArkClass_1.ClassCategory.INTERFACE, 'interface'],
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Decorator } from '../../core/base/Decorator';
|
|
2
|
-
import { Printer } from '../Printer';
|
|
3
1
|
import { ArkFile } from '../../core/model/ArkFile';
|
|
4
2
|
import { ArkMethod } from '../../core/model/ArkMethod';
|
|
5
3
|
import { ClassSignature, MethodSignature } from '../../core/model/ArkSignature';
|
|
@@ -8,11 +6,8 @@ import { ArkCodeBuffer } from '../ArkStream';
|
|
|
8
6
|
import { Local } from '../../core/base/Local';
|
|
9
7
|
import { TransformerContext } from './SourceTransformer';
|
|
10
8
|
import { ArkNamespace } from '../../core/model/ArkNamespace';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
dump(): string;
|
|
14
|
-
}
|
|
15
|
-
export declare abstract class SourceBase extends Printer implements Dump, TransformerContext {
|
|
9
|
+
import { BasePrinter } from '../base/BasePrinter';
|
|
10
|
+
export declare abstract class SourceBase extends BasePrinter implements TransformerContext {
|
|
16
11
|
protected arkFile: ArkFile;
|
|
17
12
|
protected inBuilder: boolean;
|
|
18
13
|
constructor(arkFile: ArkFile, indent?: string);
|
|
@@ -23,10 +18,6 @@ export declare abstract class SourceBase extends Printer implements Dump, Transf
|
|
|
23
18
|
getPrinter(): ArkCodeBuffer;
|
|
24
19
|
transTemp2Code(temp: Local): string;
|
|
25
20
|
isInBuilderMethod(): boolean;
|
|
26
|
-
abstract getLine(): number;
|
|
27
|
-
protected printDecorator(docorator: Decorator[]): void;
|
|
28
|
-
protected modifiersToString(modifiers: number): string;
|
|
29
21
|
protected resolveKeywordType(keywordStr: string): string;
|
|
30
|
-
protected resolveMethodName(name: string): string;
|
|
31
22
|
}
|
|
32
23
|
//# sourceMappingURL=SourceBase.d.ts.map
|