arkanalyzer 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/arkanalyzer.json +14 -13
- package/lib/core/base/Ref.d.ts.map +1 -1
- package/lib/core/base/Ref.js +3 -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 +15 -0
- package/lib/core/common/IRInference.d.ts +9 -0
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +92 -12
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +16 -5
- package/lib/core/common/SdkUtils.d.ts +3 -0
- package/lib/core/common/SdkUtils.d.ts.map +1 -1
- package/lib/core/common/SdkUtils.js +26 -4
- package/lib/core/common/TSConst.d.ts +2 -0
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TSConst.js +4 -2
- package/lib/core/common/TypeInference.d.ts +6 -3
- package/lib/core/common/TypeInference.d.ts.map +1 -1
- package/lib/core/common/TypeInference.js +101 -43
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +3 -0
- package/lib/core/model/ArkClass.d.ts.map +1 -1
- package/lib/core/model/ArkClass.js +3 -0
- package/lib/core/model/ArkSignature.d.ts +5 -0
- package/lib/core/model/ArkSignature.d.ts.map +1 -1
- package/lib/core/model/ArkSignature.js +14 -0
- package/lib/core/model/builder/ArkClassBuilder.d.ts +1 -1
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +16 -47
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +1 -0
- package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
- package/lib/core/model/builder/builderUtils.js +15 -2
- package/package.json +2 -2
package/config/arkanalyzer.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"supportFileExts": [
|
|
3
|
+
".ets",
|
|
4
|
+
".ts",
|
|
5
|
+
".d.ets",
|
|
6
|
+
".d.ts"
|
|
7
|
+
],
|
|
8
|
+
"enableLeadingComments": false,
|
|
9
|
+
"ignoreFileNames": [
|
|
10
|
+
"oh_modules",
|
|
11
|
+
"node_modules",
|
|
12
|
+
"hvigorfile.ts"
|
|
13
|
+
],
|
|
12
14
|
"sdkGlobalFolders": [
|
|
13
15
|
"component",
|
|
14
|
-
"@internal"
|
|
15
|
-
"common"
|
|
16
|
+
"@internal"
|
|
16
17
|
],
|
|
17
|
-
|
|
18
|
+
"tsconfig": "tsconfig.json"
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../../src/core/base/Ref.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAa,SAAS,EAAE,IAAI,EAAqC,MAAM,QAAQ,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B;;GAEG;AACH,8BAAsB,WAAY,YAAW,KAAK;IAC9C,QAAQ,CAAC,OAAO,IAAI,KAAK,EAAE;IAE3B,QAAQ,CAAC,OAAO,IAAI,IAAI;IAEjB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;CAGt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AAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;IAO/C,OAAO,IAAI,KAAK,EAAE;IAIlB,OAAO,IAAI,KAAK;IAIhB,OAAO,IAAI,IAAI;IAIf,YAAY,IAAI,MAAM;IAItB,QAAQ,IAAI,MAAM;CAG5B"}
|
package/lib/core/base/Ref.js
CHANGED
|
@@ -271,10 +271,9 @@ class ArkThisRef extends AbstractRef {
|
|
|
271
271
|
this.type = type;
|
|
272
272
|
}
|
|
273
273
|
inferType(arkMethod) {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
let type = TypeInference_1.TypeInference.inferBaseType(className.split(Const_1.ANONYMOUS_CLASS_DELIMITER)[1], arkClass);
|
|
274
|
+
const classSignature = this.type.getClassSignature();
|
|
275
|
+
if (classSignature.getClassName().startsWith(Const_1.ANONYMOUS_CLASS_PREFIX)) {
|
|
276
|
+
let type = TypeInference_1.TypeInference.inferBaseType(classSignature.getDeclaringClassName(), arkMethod.getDeclaringArkClass());
|
|
278
277
|
if (type instanceof Type_1.ClassType) {
|
|
279
278
|
this.type = type;
|
|
280
279
|
}
|
|
@@ -37,6 +37,7 @@ export declare class ArkIRTransformer {
|
|
|
37
37
|
tsNodeToStmts(node: ts.Node): Stmt[];
|
|
38
38
|
tsNodeToValueAndStmts(node: ts.Node): ValueAndStmts;
|
|
39
39
|
private functionDeclarationToStmts;
|
|
40
|
+
private classDeclarationToStmts;
|
|
40
41
|
private returnStatementToStmts;
|
|
41
42
|
private blockToStmts;
|
|
42
43
|
private expressionStatementToStmts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkIRTransformer.d.ts","sourceRoot":"","sources":["../../../src/core/common/ArkIRTransformer.ts"],"names":[],"mappings":"AAeA,OAAO,EAOH,cAAc,EAGd,aAAa,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA2E,SAAS,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,KAAK,EAAE,M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,OAAO,CAAC,kBAAkB;IAyD1B,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,uBAAuB;IAgBxB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI;WAU7C,oBAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,aAAa,GAAG,IAAI;WAchE,qBAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,cAAc,GAAG,IAAI;IAsDzE,0BAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,aAAa;IAQ/F,uBAAuB,CAAC,SAAS,EAAE,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAC5E,wBAAwB,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE;IA+BzE,2BAA2B,CAAC,wBAAwB,EAAE,OAAO,GAAG,IAAI;CAG9E"}
|
|
@@ -60,6 +60,8 @@ const ArkValueTransformer_1 = require("./ArkValueTransformer");
|
|
|
60
60
|
const ArkImport_1 = require("../model/ArkImport");
|
|
61
61
|
const TypeInference_1 = require("./TypeInference");
|
|
62
62
|
const TypeExpr_1 = require("../base/TypeExpr");
|
|
63
|
+
const ArkClassBuilder_1 = require("../model/builder/ArkClassBuilder");
|
|
64
|
+
const ArkClass_1 = require("../model/ArkClass");
|
|
63
65
|
class DummyStmt extends Stmt_1.Stmt {
|
|
64
66
|
constructor(text) {
|
|
65
67
|
super();
|
|
@@ -154,6 +156,9 @@ class ArkIRTransformer {
|
|
|
154
156
|
else if (ts.isExportAssignment(node)) {
|
|
155
157
|
stmts = this.expressionInExportToStmts(node.expression);
|
|
156
158
|
}
|
|
159
|
+
else if (ts.isClassDeclaration(node)) {
|
|
160
|
+
stmts = this.classDeclarationToStmts(node);
|
|
161
|
+
}
|
|
157
162
|
this.mapStmtsToTsStmt(stmts, node);
|
|
158
163
|
if (stmts.length > 0) {
|
|
159
164
|
IRUtils_1.IRUtils.setComments(stmts[0], node, this.sourceFile, this.declaringMethod.getDeclaringArkFile().getScene().getOptions());
|
|
@@ -172,6 +177,16 @@ class ArkIRTransformer {
|
|
|
172
177
|
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(functionDeclarationNode, declaringClass, arkMethod, this.sourceFile, this.declaringMethod);
|
|
173
178
|
return [];
|
|
174
179
|
}
|
|
180
|
+
classDeclarationToStmts(node) {
|
|
181
|
+
const cls = new ArkClass_1.ArkClass();
|
|
182
|
+
const declaringArkNamespace = this.declaringMethod.getDeclaringArkClass().getDeclaringArkNamespace();
|
|
183
|
+
if (declaringArkNamespace) {
|
|
184
|
+
cls.setDeclaringArkNamespace(declaringArkNamespace);
|
|
185
|
+
}
|
|
186
|
+
cls.setDeclaringArkFile(this.declaringMethod.getDeclaringArkFile());
|
|
187
|
+
(0, ArkClassBuilder_1.buildNormalArkClassFromArkMethod)(node, cls, this.sourceFile, this.declaringMethod);
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
175
190
|
returnStatementToStmts(returnStatement) {
|
|
176
191
|
const stmts = [];
|
|
177
192
|
if (returnStatement.expression) {
|
|
@@ -16,12 +16,21 @@ export declare class IRInference {
|
|
|
16
16
|
private static inferStaticInvokeExprByMethodName;
|
|
17
17
|
private static generateNewMethodSignature;
|
|
18
18
|
static inferInstanceInvokeExpr(expr: ArkInstanceInvokeExpr, arkMethod: ArkMethod): AbstractInvokeExpr;
|
|
19
|
+
/**
|
|
20
|
+
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
21
|
+
* @param expr
|
|
22
|
+
* @param arkMethod
|
|
23
|
+
* @param methodName
|
|
24
|
+
*/
|
|
25
|
+
private static processExtendFunc;
|
|
19
26
|
static inferFieldRef(ref: ArkInstanceFieldRef, arkMethod: ArkMethod): AbstractRef;
|
|
20
27
|
private static inferArgs;
|
|
21
28
|
private static inferArg;
|
|
22
29
|
static inferRightWithSdkType(leftType: Type, rightType: Type, ackClass: ArkClass): void;
|
|
23
30
|
static inferArgTypeWithSdk(sdkType: ClassType, scene: Scene, argType: Type): void;
|
|
24
31
|
private static inferInvokeExpr;
|
|
32
|
+
private static inferInvokeExprWithArray;
|
|
33
|
+
private static inferInvokeExprWithFunction;
|
|
25
34
|
private static inferInvokeExprWithDeclaredClass;
|
|
26
35
|
private static getRealTypes;
|
|
27
36
|
static replaceMethodSignature(init: MethodSignature, declared: MethodSignature): MethodSignature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAKH,SAAS,EAIT,IAAI,
|
|
1
|
+
{"version":3,"file":"IRInference.d.ts","sourceRoot":"","sources":["../../../src/core/common/IRInference.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAKH,SAAS,EAIT,IAAI,EAKP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAGH,cAAc,EAEd,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAEH,WAAW,EAEX,mBAAmB,EAGtB,MAAM,aAAa,CAAC;AAarB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,E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AAG,IAAI;IA2BjE,OAAO,CAAC,MAAM,CAAC,yBAAyB;WA4C1B,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,GAAE,GAAG,CAAC,MAAM,CAAa,GAAG,IAAI;IA+B/H,OAAO,CAAC,MAAM,CAAC,eAAe;WAiChB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY;WAiC3E,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WA2CnE,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;CAapF"}
|
|
@@ -173,17 +173,25 @@ class IRInference {
|
|
|
173
173
|
return signature;
|
|
174
174
|
}
|
|
175
175
|
static inferInstanceInvokeExpr(expr, arkMethod) {
|
|
176
|
+
var _a, _b, _c;
|
|
176
177
|
const arkClass = arkMethod.getDeclaringArkClass();
|
|
177
178
|
TypeInference_1.TypeInference.inferRealGenericTypes(expr.getRealGenericTypes(), arkClass);
|
|
178
179
|
this.inferLocal(expr.getBase(), arkMethod);
|
|
179
180
|
const baseType = TypeInference_1.TypeInference.replaceAliasType(expr.getBase().getType());
|
|
180
|
-
|
|
181
|
+
let methodName = expr.getMethodSignature().getMethodSubSignature().getMethodName();
|
|
182
|
+
if (methodName.startsWith(Const_1.NAME_PREFIX)) {
|
|
183
|
+
const declaringStmt = (_b = (_a = arkMethod.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().get(methodName)) === null || _b === void 0 ? void 0 : _b.getDeclaringStmt();
|
|
184
|
+
if (declaringStmt instanceof Stmt_1.ArkAssignStmt && declaringStmt.getRightOp() instanceof Ref_1.ArkInstanceFieldRef) {
|
|
185
|
+
const rightOp = declaringStmt.getRightOp();
|
|
186
|
+
methodName = rightOp.getBase().getName() + '.' + rightOp.getFieldName();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
181
189
|
const scene = arkClass.getDeclaringArkFile().getScene();
|
|
182
190
|
if ((methodName === 'forEach') && (baseType instanceof Type_1.ArrayType)) {
|
|
183
191
|
this.processForEach(expr.getArg(0), baseType, scene);
|
|
184
192
|
return expr;
|
|
185
193
|
}
|
|
186
|
-
let result = this.inferInvokeExpr(expr, baseType, methodName, scene);
|
|
194
|
+
let result = (_c = this.inferInvokeExpr(expr, baseType, methodName, scene)) !== null && _c !== void 0 ? _c : this.processExtendFunc(expr, arkMethod, methodName);
|
|
187
195
|
if (result) {
|
|
188
196
|
this.inferArgs(result, arkMethod);
|
|
189
197
|
return result;
|
|
@@ -191,6 +199,28 @@ class IRInference {
|
|
|
191
199
|
logger.warn('invoke ArkInstanceInvokeExpr MethodSignature type fail: ', expr.toString());
|
|
192
200
|
return expr;
|
|
193
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
204
|
+
* @param expr
|
|
205
|
+
* @param arkMethod
|
|
206
|
+
* @param methodName
|
|
207
|
+
*/
|
|
208
|
+
static processExtendFunc(expr, arkMethod, methodName) {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
const type = TypeInference_1.TypeInference.inferBaseType(methodName, arkMethod.getDeclaringArkClass());
|
|
211
|
+
if (type instanceof Type_1.FunctionType) {
|
|
212
|
+
const methodSignature = type.getMethodSignature();
|
|
213
|
+
// because of last stmt is ArkReturnVoidStmt, the ArkInvokeStmt at -2 before ArkReturnVoidStmt.
|
|
214
|
+
const endIndex = -2;
|
|
215
|
+
const endStmt = (_b = (_a = arkMethod.getDeclaringArkFile().getScene().getMethod(methodSignature)) === null || _a === void 0 ? void 0 : _a.getCfg()) === null || _b === void 0 ? void 0 : _b.getStmts().at(endIndex);
|
|
216
|
+
if (endStmt instanceof Stmt_1.ArkInvokeStmt) {
|
|
217
|
+
methodSignature.getMethodSubSignature().setReturnType(endStmt.getInvokeExpr().getType());
|
|
218
|
+
}
|
|
219
|
+
expr.setMethodSignature(methodSignature);
|
|
220
|
+
return expr;
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
194
224
|
static inferFieldRef(ref, arkMethod) {
|
|
195
225
|
this.inferLocal(ref.getBase(), arkMethod);
|
|
196
226
|
const baseType = TypeInference_1.TypeInference.replaceAliasType(ref.getBase().getType());
|
|
@@ -236,6 +266,11 @@ class IRInference {
|
|
|
236
266
|
else if (paramType instanceof Type_1.ArrayType && argType instanceof Type_1.ArrayType) {
|
|
237
267
|
this.inferArg(expr, argType.getBaseType(), paramType.getBaseType(), scene, realTypes);
|
|
238
268
|
}
|
|
269
|
+
else if (expr instanceof Expr_1.ArkInstanceInvokeExpr && expr.getBase().getType() instanceof Type_1.ArrayType) {
|
|
270
|
+
if (paramType instanceof Type_1.ArrayType && paramType.getBaseType() instanceof Type_1.GenericType) {
|
|
271
|
+
this.inferArg(expr, argType, expr.getBase().getType().getBaseType(), scene, realTypes);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
239
274
|
if (paramType instanceof Type_1.ClassType && scene.getProjectSdkMap().has(paramType.getClassSignature()
|
|
240
275
|
.getDeclaringFileSignature().getProjectName())) {
|
|
241
276
|
this.inferArgTypeWithSdk(paramType, scene, argType);
|
|
@@ -244,9 +279,12 @@ class IRInference {
|
|
|
244
279
|
realTypes.push(argType);
|
|
245
280
|
}
|
|
246
281
|
else if (paramType instanceof Type_1.FunctionType && argType instanceof Type_1.FunctionType) {
|
|
247
|
-
const
|
|
282
|
+
const method = scene.getMethod(argType.getMethodSignature());
|
|
283
|
+
if (method) {
|
|
284
|
+
TypeInference_1.TypeInference.inferTypeInMethod(method);
|
|
285
|
+
}
|
|
248
286
|
const realTypes = expr.getRealGenericTypes();
|
|
249
|
-
TypeInference_1.TypeInference.inferFunctionType(argType,
|
|
287
|
+
TypeInference_1.TypeInference.inferFunctionType(argType, paramType.getMethodSignature().getMethodSubSignature(), realTypes);
|
|
250
288
|
}
|
|
251
289
|
}
|
|
252
290
|
static inferRightWithSdkType(leftType, rightType, ackClass) {
|
|
@@ -262,7 +300,7 @@ class IRInference {
|
|
|
262
300
|
else if (rightType instanceof Type_1.ArrayType && leftType instanceof Type_1.ArrayType) {
|
|
263
301
|
const baseType = TypeInference_1.TypeInference.replaceAliasType(leftType.getBaseType());
|
|
264
302
|
if (baseType instanceof Type_1.ClassType) {
|
|
265
|
-
IRInference.inferArgTypeWithSdk(baseType, ackClass.getDeclaringArkFile().getScene(), rightType);
|
|
303
|
+
IRInference.inferArgTypeWithSdk(baseType, ackClass.getDeclaringArkFile().getScene(), rightType.getBaseType());
|
|
266
304
|
}
|
|
267
305
|
}
|
|
268
306
|
}
|
|
@@ -278,15 +316,21 @@ class IRInference {
|
|
|
278
316
|
this.inferAnonymousClass(scene.getClass(argType.getClassSignature()), sdkType.getClassSignature());
|
|
279
317
|
}
|
|
280
318
|
else if (argType instanceof Type_1.FunctionType) {
|
|
281
|
-
const
|
|
319
|
+
const param = (_b = (_a = scene.getClass(sdkType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) === null || _b === void 0 ? void 0 : _b.getSignature().getMethodSubSignature();
|
|
282
320
|
const realTypes = sdkType.getRealGenericTypes();
|
|
283
|
-
TypeInference_1.TypeInference.inferFunctionType(argType,
|
|
321
|
+
TypeInference_1.TypeInference.inferFunctionType(argType, param, realTypes);
|
|
284
322
|
}
|
|
285
323
|
}
|
|
286
324
|
static inferInvokeExpr(expr, baseType, methodName, scene) {
|
|
287
325
|
if (baseType instanceof Type_1.AliasType) {
|
|
288
326
|
return this.inferInvokeExpr(expr, baseType.getOriginalType(), methodName, scene);
|
|
289
327
|
}
|
|
328
|
+
else if (baseType instanceof Type_1.ArrayType) {
|
|
329
|
+
const arrayInterface = scene.getSdkGlobal(Builtin_1.Builtin.ARRAY);
|
|
330
|
+
if (arrayInterface instanceof ArkClass_1.ArkClass) {
|
|
331
|
+
return this.inferInvokeExpr(expr, new Type_1.ClassType(arrayInterface.getSignature(), [baseType.getBaseType()]), methodName, scene);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
290
334
|
else if (baseType instanceof Type_1.UnionType) {
|
|
291
335
|
for (let type of baseType.flatType()) {
|
|
292
336
|
if (type instanceof Type_1.UndefinedType || type instanceof Type_1.NullType) {
|
|
@@ -315,10 +359,15 @@ class IRInference {
|
|
|
315
359
|
}
|
|
316
360
|
}
|
|
317
361
|
else if (baseType instanceof Type_1.FunctionType) {
|
|
318
|
-
|
|
319
|
-
|
|
362
|
+
return IRInference.inferInvokeExprWithFunction(methodName, expr, baseType, scene);
|
|
363
|
+
}
|
|
364
|
+
else if (baseType instanceof Type_1.ArrayType) {
|
|
365
|
+
return IRInference.inferInvokeExprWithArray(methodName, expr, baseType, scene);
|
|
320
366
|
}
|
|
321
|
-
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
static inferInvokeExprWithArray(methodName, expr, baseType, scene) {
|
|
370
|
+
if (methodName === Builtin_1.Builtin.ITERATOR_FUNCTION) {
|
|
322
371
|
const returnType = expr.getMethodSignature().getMethodSubSignature().getReturnType();
|
|
323
372
|
if (returnType instanceof Type_1.ClassType && returnType.getClassSignature().getDeclaringFileSignature()
|
|
324
373
|
.getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
|
|
@@ -326,6 +375,28 @@ class IRInference {
|
|
|
326
375
|
return expr;
|
|
327
376
|
}
|
|
328
377
|
}
|
|
378
|
+
else {
|
|
379
|
+
const arrayInterface = scene.getSdkGlobal(Builtin_1.Builtin.ARRAY);
|
|
380
|
+
if (arrayInterface instanceof ArkClass_1.ArkClass) {
|
|
381
|
+
return this.inferInvokeExpr(expr, new Type_1.ClassType(arrayInterface.getSignature(), [baseType.getBaseType()]), methodName, scene);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
static inferInvokeExprWithFunction(methodName, expr, baseType, scene) {
|
|
387
|
+
if (methodName === Const_1.CALL_SIGNATURE_NAME) {
|
|
388
|
+
expr.setMethodSignature(baseType.getMethodSignature());
|
|
389
|
+
return expr;
|
|
390
|
+
}
|
|
391
|
+
const funcInterface = scene.getSdkGlobal(TSConst_1.FUNCTION);
|
|
392
|
+
if (funcInterface instanceof ArkClass_1.ArkClass) {
|
|
393
|
+
const method = ModelUtils_1.ModelUtils.findPropertyInClass(methodName, funcInterface);
|
|
394
|
+
if (method instanceof ArkMethod_1.ArkMethod) {
|
|
395
|
+
expr.setRealGenericTypes([baseType]);
|
|
396
|
+
expr.setMethodSignature(method.getSignature());
|
|
397
|
+
return expr;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
329
400
|
return null;
|
|
330
401
|
}
|
|
331
402
|
static inferInvokeExprWithDeclaredClass(expr, baseType, methodName, scene) {
|
|
@@ -429,7 +500,13 @@ class IRInference {
|
|
|
429
500
|
var _a, _b, _c;
|
|
430
501
|
const arkClass = arkMethod.getDeclaringArkClass();
|
|
431
502
|
if (base.getName() === TSConst_1.THIS_NAME) {
|
|
432
|
-
if (
|
|
503
|
+
if (arkClass.isAnonymousClass()) {
|
|
504
|
+
const thisType = TypeInference_1.TypeInference.inferBaseType(arkClass.getSignature().getDeclaringClassName(), arkClass);
|
|
505
|
+
if (thisType instanceof Type_1.ClassType) {
|
|
506
|
+
base.setType(thisType);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
433
510
|
base.setType(new Type_1.ClassType(arkClass.getSignature(), arkClass.getGenericsTypes()));
|
|
434
511
|
}
|
|
435
512
|
return;
|
|
@@ -444,7 +521,7 @@ class IRInference {
|
|
|
444
521
|
baseType = (_c = (_b = ModelUtils_1.ModelUtils.findDeclaredLocal(base, arkMethod)) === null || _b === void 0 ? void 0 : _b.getType()) !== null && _c !== void 0 ? _c : TypeInference_1.TypeInference.inferBaseType(base.getName(), arkClass);
|
|
445
522
|
}
|
|
446
523
|
}
|
|
447
|
-
if (baseType && !TypeInference_1.TypeInference.isUnclearType(baseType)) {
|
|
524
|
+
if (baseType instanceof Type_1.UnionType || (baseType && !TypeInference_1.TypeInference.isUnclearType(baseType))) {
|
|
448
525
|
base.setType(baseType);
|
|
449
526
|
}
|
|
450
527
|
}
|
|
@@ -547,6 +624,9 @@ class IRInference {
|
|
|
547
624
|
deepInfer(rightType.getBaseType(), classSignature);
|
|
548
625
|
}
|
|
549
626
|
}
|
|
627
|
+
else if (type instanceof Type_1.FunctionType && rightType instanceof Type_1.FunctionType) {
|
|
628
|
+
TypeInference_1.TypeInference.inferFunctionType(rightType, type.getMethodSignature().getMethodSubSignature(), type.getRealGenericTypes());
|
|
629
|
+
}
|
|
550
630
|
const leftOp = lastStmt.getLeftOp();
|
|
551
631
|
if (leftOp instanceof Ref_1.AbstractFieldRef) {
|
|
552
632
|
leftOp.setFieldSignature(property.getSignature());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/ModelUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAEH,cAAc,EAKd,eAAe,EAEf,SAAS,EACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAc,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,OAAO,
|
|
1
|
+
{"version":3,"file":"ModelUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/ModelUtils.ts"],"names":[],"mappings":"AAeA,OAA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,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CA4BlF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAiB7F;AAqED,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GAAG,IAAI,CAK9F"}
|
|
@@ -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
|
|
@@ -346,7 +346,7 @@ class ModelUtils {
|
|
|
346
346
|
return null;
|
|
347
347
|
}
|
|
348
348
|
static findDeclaredLocal(local, arkMethod, times = 0) {
|
|
349
|
-
var _a, _b, _c;
|
|
349
|
+
var _a, _b, _c, _d;
|
|
350
350
|
if (arkMethod.getDeclaringArkFile().getScene().getOptions().isScanAbc) {
|
|
351
351
|
return null;
|
|
352
352
|
}
|
|
@@ -371,8 +371,16 @@ class ModelUtils {
|
|
|
371
371
|
const start = parentName.indexOf(Const_1.NAME_DELIMITER);
|
|
372
372
|
let invokeMethod;
|
|
373
373
|
if (start < 0) {
|
|
374
|
-
const
|
|
375
|
-
|
|
374
|
+
const className = arkMethod.getDeclaringArkClass().getName();
|
|
375
|
+
const outerStart = className.indexOf(Const_1.NAME_DELIMITER);
|
|
376
|
+
const outerEnd = className.lastIndexOf('.');
|
|
377
|
+
if (outerStart > -1 && outerEnd > -1) {
|
|
378
|
+
invokeMethod = (_b = arkMethod.getDeclaringArkFile().getClassWithName(className.substring(outerStart + 1, outerEnd))) === null || _b === void 0 ? void 0 : _b.getMethodWithName(className.substring(outerEnd + 1));
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
const cls = arkMethod.getDeclaringArkClass();
|
|
382
|
+
invokeMethod = (_c = cls.getDefaultArkMethod()) !== null && _c !== void 0 ? _c : (_d = cls.getDeclaringArkFile().getDefaultClass()) === null || _d === void 0 ? void 0 : _d.getDefaultArkMethod();
|
|
383
|
+
}
|
|
376
384
|
}
|
|
377
385
|
else {
|
|
378
386
|
parentName = parentName.substring(start + 1);
|
|
@@ -478,7 +486,6 @@ exports.ModelUtils = ModelUtils;
|
|
|
478
486
|
ModelUtils.implicitArkUIBuilderMethods = new Set();
|
|
479
487
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ModelUtils');
|
|
480
488
|
let moduleMap;
|
|
481
|
-
const fileSuffixArray = ['.ets', '.ts', '.d.ets', '.d.ts'];
|
|
482
489
|
exports.sdkImportMap = new Map();
|
|
483
490
|
/**
|
|
484
491
|
* find arkFile by from info
|
|
@@ -626,6 +633,10 @@ function getArkFileFormMap(projectName, filePath, scene) {
|
|
|
626
633
|
if (/\.e?ts$/.test(filePath)) {
|
|
627
634
|
return scene.getFile(new ArkSignature_1.FileSignature(projectName, filePath));
|
|
628
635
|
}
|
|
636
|
+
const fileSuffixArray = scene.getOptions().supportFileExts;
|
|
637
|
+
if (!fileSuffixArray) {
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
629
640
|
for (const suffix of fileSuffixArray) {
|
|
630
641
|
const arkFile = scene.getFile(new ArkSignature_1.FileSignature(projectName, filePath + suffix));
|
|
631
642
|
if (arkFile) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ArkFile } from '../model/ArkFile';
|
|
2
2
|
import { ArkExport } from '../model/ArkExport';
|
|
3
|
+
import { ArkMethod } from '../model/ArkMethod';
|
|
4
|
+
import { AbstractFieldRef } from '../base/Ref';
|
|
3
5
|
export declare class SdkUtils {
|
|
4
6
|
static buildGlobalMap(file: ArkFile, globalMap: Map<string, ArkExport>): void;
|
|
5
7
|
private static loadClass;
|
|
6
8
|
private static loadGlobalLocal;
|
|
7
9
|
private static copyMethod;
|
|
10
|
+
static computeGlobalThis(leftOp: AbstractFieldRef, arkMethod: ArkMethod): void;
|
|
8
11
|
}
|
|
9
12
|
//# sourceMappingURL=SdkUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,qBAAa,QAAQ;WAEH,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAiCpF,OAAO,CAAC,MAAM,CAAC,SAAS;IAexB,OAAO,CAAC,MAAM,CAAC,eAAe;IAyB9B,OAAO,CAAC,MAAM,CAAC,UAAU;WAYX,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;CAQxF"}
|
|
@@ -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
|
|
@@ -18,13 +18,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.SdkUtils = void 0;
|
|
21
|
+
const ArkExport_1 = require("../model/ArkExport");
|
|
21
22
|
const EtsConst_1 = require("./EtsConst");
|
|
22
23
|
const TSConst_1 = require("./TSConst");
|
|
23
24
|
const Const_1 = require("./Const");
|
|
24
25
|
const ArkClass_1 = require("../model/ArkClass");
|
|
25
26
|
const ArkSignature_1 = require("../model/ArkSignature");
|
|
26
27
|
const ModelUtils_1 = require("./ModelUtils");
|
|
28
|
+
const Local_1 = require("../base/Local");
|
|
27
29
|
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const IRInference_1 = require("./IRInference");
|
|
31
|
+
const Type_1 = require("../base/Type");
|
|
32
|
+
const ArkNamespace_1 = require("../model/ArkNamespace");
|
|
28
33
|
class SdkUtils {
|
|
29
34
|
static buildGlobalMap(file, globalMap) {
|
|
30
35
|
var _a, _b, _c, _d;
|
|
@@ -36,6 +41,7 @@ class SdkUtils {
|
|
|
36
41
|
if (!isGlobalPath) {
|
|
37
42
|
return;
|
|
38
43
|
}
|
|
44
|
+
IRInference_1.IRInference.inferFile(file);
|
|
39
45
|
ModelUtils_1.ModelUtils.getAllClassesInFile(file).forEach(cls => {
|
|
40
46
|
if (!cls.isAnonymousClass() && !cls.isDefaultArkClass()) {
|
|
41
47
|
SdkUtils.loadClass(globalMap, cls);
|
|
@@ -49,11 +55,12 @@ class SdkUtils {
|
|
|
49
55
|
const defaultArkMethod = file.getDefaultClass().getDefaultArkMethod();
|
|
50
56
|
(_b = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => {
|
|
51
57
|
const name = local.getName();
|
|
52
|
-
if (name !== TSConst_1.THIS_NAME && !name.startsWith(Const_1.TEMP_LOCAL_PREFIX)
|
|
58
|
+
if (name !== TSConst_1.THIS_NAME && !name.startsWith(Const_1.TEMP_LOCAL_PREFIX)) {
|
|
53
59
|
this.loadGlobalLocal(local, defaultArkMethod, globalMap);
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
62
|
(_d = (_c = defaultArkMethod === null || defaultArkMethod === void 0 ? void 0 : defaultArkMethod.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeMap()) === null || _d === void 0 ? void 0 : _d.forEach(a => globalMap.set(a[0].getName(), a[0]));
|
|
63
|
+
ModelUtils_1.ModelUtils.getAllNamespacesInFile(file).forEach(ns => globalMap.set(ns.getName(), ns));
|
|
57
64
|
}
|
|
58
65
|
static loadClass(globalMap, cls) {
|
|
59
66
|
const old = globalMap.get(cls.getName());
|
|
@@ -74,11 +81,12 @@ class SdkUtils {
|
|
|
74
81
|
static loadGlobalLocal(local, defaultArkMethod, globalMap) {
|
|
75
82
|
const name = local.getName();
|
|
76
83
|
local.setSignature(new ArkSignature_1.LocalSignature(name, defaultArkMethod.getSignature()));
|
|
77
|
-
|
|
84
|
+
const scene = defaultArkMethod.getDeclaringArkFile().getScene();
|
|
85
|
+
if (scene.getOptions().isScanAbc) {
|
|
78
86
|
const instance = globalMap.get(name + 'Interface');
|
|
79
87
|
const attr = globalMap.get(name + EtsConst_1.COMPONENT_ATTRIBUTE);
|
|
80
88
|
if (attr instanceof ArkClass_1.ArkClass && instance instanceof ArkClass_1.ArkClass) {
|
|
81
|
-
instance.getMethods().forEach(m => attr.addMethod(m));
|
|
89
|
+
instance.getMethods().filter(m => !instance.getMethodWithName(m.getName())).forEach(m => attr.addMethod(m));
|
|
82
90
|
globalMap.set(name, attr);
|
|
83
91
|
return;
|
|
84
92
|
}
|
|
@@ -87,6 +95,12 @@ class SdkUtils {
|
|
|
87
95
|
if (!old) {
|
|
88
96
|
globalMap.set(name, local);
|
|
89
97
|
}
|
|
98
|
+
else if (old instanceof ArkClass_1.ArkClass && local.getType() instanceof Type_1.ClassType) {
|
|
99
|
+
const localConstructor = scene.getClass(local.getType().getClassSignature());
|
|
100
|
+
if (localConstructor) {
|
|
101
|
+
localConstructor.getMethods().filter(m => !old.getMethodWithName(m.getName())).forEach(m => old.addMethod(m));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
90
104
|
}
|
|
91
105
|
static copyMethod(from, to) {
|
|
92
106
|
from.getMethods().forEach(method => {
|
|
@@ -101,5 +115,13 @@ class SdkUtils {
|
|
|
101
115
|
}
|
|
102
116
|
});
|
|
103
117
|
}
|
|
118
|
+
static computeGlobalThis(leftOp, arkMethod) {
|
|
119
|
+
const globalThis = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(TSConst_1.GLOBAL_THIS_NAME);
|
|
120
|
+
if (globalThis instanceof ArkNamespace_1.ArkNamespace) {
|
|
121
|
+
const exportInfo = new ArkExport_1.ExportInfo.Builder().exportClauseName(leftOp.getFieldName())
|
|
122
|
+
.arkExport(new Local_1.Local(leftOp.getFieldName(), leftOp.getType())).build();
|
|
123
|
+
globalThis.addExportInfo(exportInfo);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
104
126
|
}
|
|
105
127
|
exports.SdkUtils = SdkUtils;
|
|
@@ -5,6 +5,8 @@ export declare const GLOBAL_THIS_NAME: string;
|
|
|
5
5
|
export declare const DEFAULT = "default";
|
|
6
6
|
export declare const ALL = "*";
|
|
7
7
|
export declare const IMPORT = "import";
|
|
8
|
+
export declare const PROMISE = "Promise";
|
|
9
|
+
export declare const FUNCTION = "Function";
|
|
8
10
|
export declare const DECLARE_KEYWORD = "DeclareKeyword";
|
|
9
11
|
export declare const NULL_KEYWORD = "null";
|
|
10
12
|
export declare const UNDEFINED_KEYWORD = "undefined";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TSConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/TSConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,gBAAgB,EAAE,MAAqB,CAAA;AAEpD,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,eAAO,MAAM,GAAG,MAAM,CAAC;AAEvB,eAAO,MAAM,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"TSConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/TSConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,gBAAgB,EAAE,MAAqB,CAAA;AAEpD,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,eAAO,MAAM,GAAG,MAAM,CAAC;AAEvB,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,QAAQ,aAAa,CAAC;AAGnC,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,aAAa,kBAAkB,CAAC"}
|
|
@@ -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
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TSCONFIG_JSON = exports.NEVER_KEYWORD = exports.VOID_KEYWORD = exports.STRING_KEYWORD = exports.NUMBER_KEYWORD = exports.BOOLEAN_KEYWORD = exports.UNKNOWN_KEYWORD = exports.ANY_KEYWORD = exports.UNDEFINED_KEYWORD = exports.NULL_KEYWORD = exports.DECLARE_KEYWORD = exports.IMPORT = exports.ALL = exports.DEFAULT = exports.GLOBAL_THIS_NAME = exports.THIS_NAME = exports.SUPER_NAME = exports.CONSTRUCTOR_NAME = void 0;
|
|
17
|
+
exports.TSCONFIG_JSON = exports.NEVER_KEYWORD = exports.VOID_KEYWORD = exports.STRING_KEYWORD = exports.NUMBER_KEYWORD = exports.BOOLEAN_KEYWORD = exports.UNKNOWN_KEYWORD = exports.ANY_KEYWORD = exports.UNDEFINED_KEYWORD = exports.NULL_KEYWORD = exports.DECLARE_KEYWORD = exports.FUNCTION = exports.PROMISE = exports.IMPORT = exports.ALL = exports.DEFAULT = exports.GLOBAL_THIS_NAME = exports.THIS_NAME = exports.SUPER_NAME = exports.CONSTRUCTOR_NAME = void 0;
|
|
18
18
|
exports.CONSTRUCTOR_NAME = 'constructor';
|
|
19
19
|
exports.SUPER_NAME = 'super';
|
|
20
20
|
exports.THIS_NAME = 'this';
|
|
@@ -22,6 +22,8 @@ exports.GLOBAL_THIS_NAME = 'globalThis';
|
|
|
22
22
|
exports.DEFAULT = 'default';
|
|
23
23
|
exports.ALL = '*';
|
|
24
24
|
exports.IMPORT = 'import';
|
|
25
|
+
exports.PROMISE = 'Promise';
|
|
26
|
+
exports.FUNCTION = 'Function';
|
|
25
27
|
// ast const
|
|
26
28
|
exports.DECLARE_KEYWORD = 'DeclareKeyword';
|
|
27
29
|
exports.NULL_KEYWORD = 'null';
|
|
@@ -5,8 +5,7 @@ import { ArkExport } from '../model/ArkExport';
|
|
|
5
5
|
import { ArkClass } from '../model/ArkClass';
|
|
6
6
|
import { ArkField } from '../model/ArkField';
|
|
7
7
|
import { Value } from '../base/Value';
|
|
8
|
-
import { MethodSignature } from '../model/ArkSignature';
|
|
9
|
-
import { MethodParameter } from '../model/builder/ArkMethodBuilder';
|
|
8
|
+
import { MethodSignature, MethodSubSignature } from '../model/ArkSignature';
|
|
10
9
|
export declare class TypeInference {
|
|
11
10
|
static inferTypeInArkField(arkField: ArkField): void;
|
|
12
11
|
/**
|
|
@@ -21,6 +20,7 @@ export declare class TypeInference {
|
|
|
21
20
|
*/
|
|
22
21
|
static inferUnclearedType(leftOpType: Type, declaringArkClass: ArkClass, rightType?: Type): Type | null | undefined;
|
|
23
22
|
static inferTypeInMethod(arkMethod: ArkMethod): void;
|
|
23
|
+
private static resolveStmt;
|
|
24
24
|
/**
|
|
25
25
|
* @Deprecated
|
|
26
26
|
* @param arkMethod
|
|
@@ -47,6 +47,7 @@ export declare class TypeInference {
|
|
|
47
47
|
* @param arkMethod
|
|
48
48
|
*/
|
|
49
49
|
static resolveArkAssignStmt(stmt: Stmt, arkMethod: ArkMethod): void;
|
|
50
|
+
private static resolveLeftOp;
|
|
50
51
|
private static setValueType;
|
|
51
52
|
static isUnclearType(type: Type | null | undefined): boolean;
|
|
52
53
|
private static hasUnclearReferenceType;
|
|
@@ -55,6 +56,7 @@ export declare class TypeInference {
|
|
|
55
56
|
static inferValueType(value: Value, arkMethod: ArkMethod): Type | null;
|
|
56
57
|
private static inferParameterType;
|
|
57
58
|
static inferSignatureReturnType(oldSignature: MethodSignature, arkMethod: ArkMethod): void;
|
|
59
|
+
private static inferReturnType;
|
|
58
60
|
static inferGenericType(types: GenericType[] | undefined, arkClass: ArkClass): void;
|
|
59
61
|
/**
|
|
60
62
|
* Infer type for a given {@link UnclearReferenceType} type.
|
|
@@ -98,6 +100,7 @@ export declare class TypeInference {
|
|
|
98
100
|
static inferDynamicImportType(from: string, arkClass: ArkClass): Type | null;
|
|
99
101
|
static replaceTypeWithReal(type: Type, realTypes?: Type[]): Type;
|
|
100
102
|
static replaceAliasType(type: Type): Type;
|
|
101
|
-
static inferFunctionType(argType: FunctionType,
|
|
103
|
+
static inferFunctionType(argType: FunctionType, paramSubSignature: MethodSubSignature | undefined, realTypes: Type[] | undefined): void;
|
|
104
|
+
private static resolveArkReturnStmt;
|
|
102
105
|
}
|
|
103
106
|
//# sourceMappingURL=TypeInference.d.ts.map
|