arkanalyzer 1.0.80 → 1.0.82
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/core/base/Expr.d.ts.map +1 -1
- package/lib/core/base/Expr.js +5 -3
- package/lib/core/common/Const.d.ts +2 -0
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +4 -2
- package/lib/core/common/EtsConst.d.ts +1 -0
- package/lib/core/common/EtsConst.d.ts.map +1 -1
- package/lib/core/common/EtsConst.js +3 -2
- package/lib/core/common/IRInference.d.ts +0 -7
- package/lib/core/common/IRInference.d.ts.map +1 -1
- package/lib/core/common/IRInference.js +14 -30
- package/lib/core/common/ModelUtils.d.ts.map +1 -1
- package/lib/core/common/ModelUtils.js +8 -15
- package/lib/core/common/TSConst.d.ts +1 -0
- package/lib/core/common/TSConst.d.ts.map +1 -1
- package/lib/core/common/TSConst.js +3 -2
- package/lib/core/inference/ModelInference.d.ts.map +1 -1
- package/lib/core/inference/ModelInference.js +25 -5
- package/lib/core/inference/ValueInference.d.ts +1 -36
- package/lib/core/inference/ValueInference.d.ts.map +1 -1
- package/lib/core/inference/ValueInference.js +26 -177
- package/lib/core/inference/abc/AbcInference.d.ts +7 -0
- package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
- package/lib/core/inference/abc/AbcInference.js +28 -2
- package/lib/core/inference/arkts/ArkTsInference.d.ts +43 -1
- package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
- package/lib/core/inference/arkts/ArkTsInference.js +189 -2
- package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkClassBuilder.js +2 -5
- package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
- package/lib/core/model/builder/ArkMethodBuilder.js +3 -3
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/save/base/BasePrinter.d.ts.map +1 -1
- package/lib/save/base/BasePrinter.js +6 -5
- package/lib/utils/IntMap.d.ts +48 -0
- package/lib/utils/IntMap.d.ts.map +1 -0
- package/lib/utils/IntMap.js +134 -0
- package/lib/utils/IntWorkList.d.ts +35 -0
- package/lib/utils/IntWorkList.d.ts.map +1 -0
- package/lib/utils/IntWorkList.js +97 -0
- package/lib/utils/PackedSparseMap.d.ts +26 -0
- package/lib/utils/PackedSparseMap.d.ts.map +1 -0
- package/lib/utils/PackedSparseMap.js +140 -0
- package/lib/utils/logger.d.ts +1 -0
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024-
|
|
3
|
+
* Copyright (c) 2024-2026 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
|
|
@@ -44,8 +44,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
44
44
|
};
|
|
45
45
|
var InstanceInvokeExprInference_1;
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.
|
|
48
|
-
const Ref_1 = require("../base/Ref");
|
|
47
|
+
exports.LocalInference = exports.ArkCastExprInference = exports.ArkInstanceOfExprInference = exports.ArkConditionExprInference = exports.ArkNormalBinOpExprInference = exports.ArkNewArrayExprInference = exports.ArkNewExprInference = exports.ArkPtrInvokeExprInference = exports.StaticInvokeExprInference = exports.InstanceInvokeExprInference = exports.StaticFieldRefInference = exports.FieldRefInference = exports.ClosureFieldRefInference = exports.ParameterRefInference = exports.ValueInference = exports.Bind = exports.valueCtors = exports.InferLanguage = void 0;
|
|
49
48
|
const Type_1 = require("../base/Type");
|
|
50
49
|
const TypeInference_1 = require("../common/TypeInference");
|
|
51
50
|
const IRInference_1 = require("../common/IRInference");
|
|
@@ -60,8 +59,6 @@ const ArkClass_1 = require("../model/ArkClass");
|
|
|
60
59
|
const Constant_1 = require("../base/Constant");
|
|
61
60
|
const logger_1 = __importStar(require("../../utils/logger"));
|
|
62
61
|
const ArkSignature_1 = require("../model/ArkSignature");
|
|
63
|
-
const ArkImport_1 = require("../model/ArkImport");
|
|
64
|
-
const ArkField_1 = require("../model/ArkField");
|
|
65
62
|
const Builtin_1 = require("../common/Builtin");
|
|
66
63
|
const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'ValueInference');
|
|
67
64
|
var InferLanguage;
|
|
@@ -415,9 +412,31 @@ let ArkPtrInvokeExprInference = class ArkPtrInvokeExprInference extends StaticIn
|
|
|
415
412
|
return 'ArkPtrInvokeExpr';
|
|
416
413
|
}
|
|
417
414
|
infer(expr, stmt) {
|
|
418
|
-
|
|
415
|
+
var _a;
|
|
416
|
+
let ptrType = expr.getFuncPtrLocal().getType();
|
|
417
|
+
if (ptrType instanceof Type_1.UnionType) {
|
|
418
|
+
const funType = ptrType.getTypes().find(t => t instanceof Type_1.FunctionType);
|
|
419
|
+
if (funType instanceof Type_1.FunctionType) {
|
|
420
|
+
ptrType = funType;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
ptrType = ptrType.getTypes().find(t => t instanceof Type_1.ClassType);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
let methodSignature;
|
|
419
427
|
if (ptrType instanceof Type_1.FunctionType) {
|
|
420
|
-
|
|
428
|
+
methodSignature = ptrType.getMethodSignature();
|
|
429
|
+
}
|
|
430
|
+
else if (ptrType instanceof Type_1.ClassType) {
|
|
431
|
+
const methodName = ptrType.getClassSignature().getClassName() === TSConst_1.FUNCTION ? TSConst_1.CALL : Const_1.CALL_SIGNATURE_NAME;
|
|
432
|
+
const scene = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile().getScene();
|
|
433
|
+
const callback = (_a = scene.getClass(ptrType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getMethodWithName(methodName);
|
|
434
|
+
if (callback) {
|
|
435
|
+
methodSignature = callback.getSignature();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (methodSignature) {
|
|
439
|
+
expr.setMethodSignature(methodSignature);
|
|
421
440
|
}
|
|
422
441
|
super.infer(expr, stmt);
|
|
423
442
|
return undefined;
|
|
@@ -599,173 +618,3 @@ LocalInference = __decorate([
|
|
|
599
618
|
Bind()
|
|
600
619
|
], LocalInference);
|
|
601
620
|
exports.LocalInference = LocalInference;
|
|
602
|
-
let ArkTSFieldRefInference = class ArkTSFieldRefInference extends FieldRefInference {
|
|
603
|
-
preInfer(value, stmt) {
|
|
604
|
-
if (stmt.getDef() === value && this.isAnonClassThisRef(value, stmt.getCfg().getDeclaringMethod())) {
|
|
605
|
-
return false;
|
|
606
|
-
}
|
|
607
|
-
return super.preInfer(value);
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Checks if a value represents an anonymous class 'this' field reference
|
|
611
|
-
* Identifies field references that access fields directly on 'this' in anonymous class constructors
|
|
612
|
-
* @param {Value} stmtDef - The value to check (typically a field reference)
|
|
613
|
-
* @param {ArkMethod} arkMethod - The method containing the value
|
|
614
|
-
* @returns {boolean} True if the value is an anonymous class 'this' field reference
|
|
615
|
-
*/
|
|
616
|
-
isAnonClassThisRef(stmtDef, arkMethod) {
|
|
617
|
-
return (arkMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME || arkMethod.getName() === TSConst_1.CONSTRUCTOR_NAME) &&
|
|
618
|
-
stmtDef instanceof Ref_1.ArkInstanceFieldRef &&
|
|
619
|
-
stmtDef.getBase().getName() === TSConst_1.THIS_NAME &&
|
|
620
|
-
arkMethod.getDeclaringArkClass().isAnonymousClass() &&
|
|
621
|
-
stmtDef.getFieldName().indexOf('.') === -1;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
ArkTSFieldRefInference = __decorate([
|
|
625
|
-
Bind(InferLanguage.ARK_TS1_1)
|
|
626
|
-
], ArkTSFieldRefInference);
|
|
627
|
-
exports.ArkTSFieldRefInference = ArkTSFieldRefInference;
|
|
628
|
-
let ArkTsInstanceInvokeExprInference = class ArkTsInstanceInvokeExprInference extends InstanceInvokeExprInference {
|
|
629
|
-
/**
|
|
630
|
-
* Performs inference on an instance invocation expression within the context of a statement
|
|
631
|
-
* Enhances the base implementation with real generic type inference and extension function support
|
|
632
|
-
* @param {ArkInstanceInvokeExpr} value - The invocation expression to infer
|
|
633
|
-
* @param {Stmt} stmt - The statement containing the invocation
|
|
634
|
-
* @returns {Value | undefined} Returns a new expression if transformed, undefined otherwise
|
|
635
|
-
*/
|
|
636
|
-
infer(value, stmt) {
|
|
637
|
-
var _a;
|
|
638
|
-
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
639
|
-
TypeInference_1.TypeInference.inferRealGenericTypes(value.getRealGenericTypes(), arkMethod.getDeclaringArkClass());
|
|
640
|
-
const result = (_a = IRInference_1.IRInference.inferInstanceMember(value.getBase().getType(), value, arkMethod, InstanceInvokeExprInference.inferInvokeExpr)) !== null && _a !== void 0 ? _a : IRInference_1.IRInference.processExtendFunc(value, arkMethod, super.getMethodName(value, arkMethod));
|
|
641
|
-
return !result || result === value ? undefined : result;
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
ArkTsInstanceInvokeExprInference = __decorate([
|
|
645
|
-
Bind(InferLanguage.ARK_TS1_1)
|
|
646
|
-
], ArkTsInstanceInvokeExprInference);
|
|
647
|
-
exports.ArkTsInstanceInvokeExprInference = ArkTsInstanceInvokeExprInference;
|
|
648
|
-
let AliasTypeExprInference = class AliasTypeExprInference extends ValueInference {
|
|
649
|
-
getValueName() {
|
|
650
|
-
return 'AliasTypeExpr';
|
|
651
|
-
}
|
|
652
|
-
preInfer(value) {
|
|
653
|
-
return value.getOriginalType() === undefined;
|
|
654
|
-
}
|
|
655
|
-
infer(value, stmt) {
|
|
656
|
-
var _a;
|
|
657
|
-
let originalObject = value.getOriginalObject();
|
|
658
|
-
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
659
|
-
let type;
|
|
660
|
-
let originalLocal;
|
|
661
|
-
if (originalObject instanceof Local_1.Local) {
|
|
662
|
-
originalLocal = ModelUtils_1.ModelUtils.findArkModelByRefName(originalObject.getName(), arkMethod.getDeclaringArkClass());
|
|
663
|
-
if (Expr_1.AliasTypeExpr.isAliasTypeOriginalModel(originalLocal)) {
|
|
664
|
-
originalObject = originalLocal;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
if (originalObject instanceof ArkImport_1.ImportInfo) {
|
|
668
|
-
const arkExport = (_a = originalObject.getLazyExportInfo()) === null || _a === void 0 ? void 0 : _a.getArkExport();
|
|
669
|
-
const importClauseName = originalObject.getImportClauseName();
|
|
670
|
-
if (importClauseName.includes('.') && arkExport instanceof ArkClass_1.ArkClass) {
|
|
671
|
-
type = TypeInference_1.TypeInference.inferUnclearRefName(importClauseName, arkExport);
|
|
672
|
-
}
|
|
673
|
-
else if (arkExport) {
|
|
674
|
-
type = TypeInference_1.TypeInference.parseArkExport2Type(arkExport);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
else if (originalObject instanceof Type_1.Type) {
|
|
678
|
-
type = TypeInference_1.TypeInference.inferUnclearedType(originalObject, arkMethod.getDeclaringArkClass());
|
|
679
|
-
}
|
|
680
|
-
else if (originalObject instanceof ArkField_1.ArkField) {
|
|
681
|
-
type = originalObject.getType();
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
type = TypeInference_1.TypeInference.parseArkExport2Type(originalObject);
|
|
685
|
-
}
|
|
686
|
-
if (type) {
|
|
687
|
-
const realGenericTypes = value.getRealGenericTypes();
|
|
688
|
-
if (TypeInference_1.TypeInference.checkType(type, t => t instanceof Type_1.GenericType || t instanceof Type_1.AnyType) && realGenericTypes && realGenericTypes.length > 0) {
|
|
689
|
-
TypeInference_1.TypeInference.inferRealGenericTypes(realGenericTypes, arkMethod.getDeclaringArkClass());
|
|
690
|
-
type = TypeInference_1.TypeInference.replaceTypeWithReal(type, realGenericTypes);
|
|
691
|
-
}
|
|
692
|
-
value.setOriginalType(type);
|
|
693
|
-
if (Expr_1.AliasTypeExpr.isAliasTypeOriginalModel(originalLocal)) {
|
|
694
|
-
value.setOriginalObject(originalLocal);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
return undefined;
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
AliasTypeExprInference = __decorate([
|
|
701
|
-
Bind(InferLanguage.ARK_TS1_1)
|
|
702
|
-
], AliasTypeExprInference);
|
|
703
|
-
exports.AliasTypeExprInference = AliasTypeExprInference;
|
|
704
|
-
let ArkTSLocalInference = class ArkTSLocalInference extends LocalInference {
|
|
705
|
-
getValueName() {
|
|
706
|
-
return 'Local';
|
|
707
|
-
}
|
|
708
|
-
preInfer(value) {
|
|
709
|
-
const type = value.getType();
|
|
710
|
-
if (value.getName() === TSConst_1.THIS_NAME && type instanceof Type_1.ClassType &&
|
|
711
|
-
type.getClassSignature().getClassName().startsWith(Const_1.ANONYMOUS_CLASS_PREFIX)) {
|
|
712
|
-
return true;
|
|
713
|
-
}
|
|
714
|
-
else if (type instanceof Type_1.FunctionType) {
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
return super.preInfer(value);
|
|
718
|
-
}
|
|
719
|
-
infer(value, stmt) {
|
|
720
|
-
var _a;
|
|
721
|
-
const name = value.getName();
|
|
722
|
-
const type = value.getType();
|
|
723
|
-
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
724
|
-
let newType;
|
|
725
|
-
if (name === TSConst_1.THIS_NAME) {
|
|
726
|
-
newType = (_a = IRInference_1.IRInference.inferThisLocal(arkMethod)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
727
|
-
if (newType) {
|
|
728
|
-
value.setType(newType);
|
|
729
|
-
}
|
|
730
|
-
return undefined;
|
|
731
|
-
}
|
|
732
|
-
else if (type instanceof Type_1.FunctionType) {
|
|
733
|
-
const methodSignature = type.getMethodSignature();
|
|
734
|
-
methodSignature.getMethodSubSignature().getParameters().forEach(p => TypeInference_1.TypeInference.inferParameterType(p, arkMethod));
|
|
735
|
-
TypeInference_1.TypeInference.inferSignatureReturnType(methodSignature, arkMethod);
|
|
736
|
-
return undefined;
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
newType = TypeInference_1.TypeInference.inferUnclearedType(type, arkMethod.getDeclaringArkClass());
|
|
740
|
-
}
|
|
741
|
-
if (newType) {
|
|
742
|
-
value.setType(newType);
|
|
743
|
-
return undefined;
|
|
744
|
-
}
|
|
745
|
-
return super.infer(value, stmt);
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
ArkTSLocalInference = __decorate([
|
|
749
|
-
Bind(InferLanguage.ARK_TS1_1)
|
|
750
|
-
], ArkTSLocalInference);
|
|
751
|
-
exports.ArkTSLocalInference = ArkTSLocalInference;
|
|
752
|
-
let AbcFieldRefInference = class AbcFieldRefInference extends FieldRefInference {
|
|
753
|
-
getValueName() {
|
|
754
|
-
return 'ArkInstanceFieldRef';
|
|
755
|
-
}
|
|
756
|
-
preInfer(value, stmt) {
|
|
757
|
-
const type = value.getType();
|
|
758
|
-
const projectName = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile().getProjectName();
|
|
759
|
-
if (TypeInference_1.TypeInference.isAnonType(type, projectName)) {
|
|
760
|
-
const baseType = value.getBase().getType();
|
|
761
|
-
if (!TypeInference_1.TypeInference.isUnclearType(baseType) && !TypeInference_1.TypeInference.isAnonType(baseType, projectName)) {
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
return super.preInfer(value, stmt);
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
AbcFieldRefInference = __decorate([
|
|
769
|
-
Bind(InferLanguage.ABC)
|
|
770
|
-
], AbcFieldRefInference);
|
|
771
|
-
exports.AbcFieldRefInference = AbcFieldRefInference;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ImportInfoInference, MethodInference, StmtInference } from '../ModelInference';
|
|
2
2
|
import { ArkMethod } from '../../model/ArkMethod';
|
|
3
3
|
import { InferenceBuilder } from '../InferenceBuilder';
|
|
4
|
+
import { FieldRefInference } from '../ValueInference';
|
|
5
|
+
import { Stmt } from '../../base/Stmt';
|
|
6
|
+
import { ArkInstanceFieldRef } from '../../base/Ref';
|
|
4
7
|
export declare class AbcMethodInference extends MethodInference {
|
|
5
8
|
preInfer(arkMethod: ArkMethod): void;
|
|
6
9
|
private inferArkUIComponentLifeCycleMethod;
|
|
@@ -10,4 +13,8 @@ export declare class AbcInferenceBuilder extends InferenceBuilder {
|
|
|
10
13
|
buildMethodInference(): MethodInference;
|
|
11
14
|
buildStmtInference(): StmtInference;
|
|
12
15
|
}
|
|
16
|
+
export declare class AbcFieldRefInference extends FieldRefInference {
|
|
17
|
+
getValueName(): string;
|
|
18
|
+
preInfer(value: ArkInstanceFieldRef, stmt: Stmt): boolean;
|
|
19
|
+
}
|
|
13
20
|
//# sourceMappingURL=AbcInference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbcInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/abc/AbcInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGxF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"AbcInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/abc/AbcInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGxF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAQ,iBAAiB,EAAiC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,OAAO,EAAoB,mBAAmB,EAAmB,MAAM,gBAAgB,CAAC;AA6BxF,qBAAa,kBAAmB,SAAQ,eAAe;IAE5C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAQ3C,OAAO,CAAC,kCAAkC;CA8B7C;AA0CD,qBAAa,mBAAoB,SAAQ,gBAAgB;IAE9C,wBAAwB,IAAI,mBAAmB;IAI/C,oBAAoB,IAAI,eAAe;IAIvC,kBAAkB,IAAI,aAAa;CAK7C;AAED,qBACa,oBAAqB,SAAQ,iBAAiB;IAChD,YAAY,IAAI,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;CAWnE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024-
|
|
3
|
+
* Copyright (c) 2024-2026 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
|
|
@@ -13,8 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
16
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AbcInferenceBuilder = exports.AbcMethodInference = void 0;
|
|
23
|
+
exports.AbcFieldRefInference = exports.AbcInferenceBuilder = exports.AbcMethodInference = void 0;
|
|
18
24
|
const ModelInference_1 = require("../ModelInference");
|
|
19
25
|
const ModelUtils_1 = require("../../common/ModelUtils");
|
|
20
26
|
const ArkMethod_1 = require("../../model/ArkMethod");
|
|
@@ -142,3 +148,23 @@ class AbcInferenceBuilder extends InferenceBuilder_1.InferenceBuilder {
|
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
exports.AbcInferenceBuilder = AbcInferenceBuilder;
|
|
151
|
+
let AbcFieldRefInference = class AbcFieldRefInference extends ValueInference_1.FieldRefInference {
|
|
152
|
+
getValueName() {
|
|
153
|
+
return 'ArkInstanceFieldRef';
|
|
154
|
+
}
|
|
155
|
+
preInfer(value, stmt) {
|
|
156
|
+
const type = value.getType();
|
|
157
|
+
const projectName = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile().getProjectName();
|
|
158
|
+
if (TypeInference_1.TypeInference.isAnonType(type, projectName)) {
|
|
159
|
+
const baseType = value.getBase().getType();
|
|
160
|
+
if (!TypeInference_1.TypeInference.isUnclearType(baseType) && !TypeInference_1.TypeInference.isAnonType(baseType, projectName)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return super.preInfer(value, stmt);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
AbcFieldRefInference = __decorate([
|
|
168
|
+
(0, ValueInference_1.Bind)(ValueInference_1.InferLanguage.ABC)
|
|
169
|
+
], AbcFieldRefInference);
|
|
170
|
+
exports.AbcFieldRefInference = AbcFieldRefInference;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClassInference, ImportInfoInference, MethodInference, StmtInference } from '../ModelInference';
|
|
2
2
|
import { ArkMethod } from '../../model/ArkMethod';
|
|
3
3
|
import { InferenceBuilder } from '../InferenceBuilder';
|
|
4
|
-
import { ValueInference } from '../ValueInference';
|
|
4
|
+
import { FieldRefInference, InstanceInvokeExprInference, LocalInference, ValueInference } from '../ValueInference';
|
|
5
5
|
import { Stmt } from '../../base/Stmt';
|
|
6
6
|
import { Value } from '../../base/Value';
|
|
7
7
|
import { Type } from '../../base/Type';
|
|
8
|
+
import { ArkInstanceFieldRef } from '../../base/Ref';
|
|
9
|
+
import { Local } from '../../base/Local';
|
|
10
|
+
import { AliasTypeExpr, ArkInstanceInvokeExpr } from '../../base/Expr';
|
|
8
11
|
export declare class ArkTsStmtInference extends StmtInference {
|
|
9
12
|
constructor(valueInferences: ValueInference<Value>[]);
|
|
10
13
|
typeSpread(stmt: Stmt, method: ArkMethod): Set<Stmt>;
|
|
@@ -25,4 +28,43 @@ export declare class JsInferenceBuilder extends InferenceBuilder {
|
|
|
25
28
|
buildMethodInference(): MethodInference;
|
|
26
29
|
buildStmtInference(): StmtInference;
|
|
27
30
|
}
|
|
31
|
+
export declare class ArkTSFieldRefInference extends FieldRefInference {
|
|
32
|
+
preInfer(value: ArkInstanceFieldRef, stmt: Stmt): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a value represents an anonymous class 'this' field reference
|
|
35
|
+
* Identifies field references that access fields directly on 'this' in anonymous class constructors
|
|
36
|
+
* @param {Value} stmtDef - The value to check (typically a field reference)
|
|
37
|
+
* @param {ArkMethod} arkMethod - The method containing the value
|
|
38
|
+
* @returns {boolean} True if the value is an anonymous class 'this' field reference
|
|
39
|
+
*/
|
|
40
|
+
private isAnonClassThisRef;
|
|
41
|
+
}
|
|
42
|
+
export declare class ArkTsInstanceInvokeExprInference extends InstanceInvokeExprInference {
|
|
43
|
+
/**
|
|
44
|
+
* Performs inference on an instance invocation expression within the context of a statement
|
|
45
|
+
* Enhances the base implementation with real generic type inference and extension function support
|
|
46
|
+
* @param {ArkInstanceInvokeExpr} value - The invocation expression to infer
|
|
47
|
+
* @param {Stmt} stmt - The statement containing the invocation
|
|
48
|
+
* @returns {Value | undefined} Returns a new expression if transformed, undefined otherwise
|
|
49
|
+
*/
|
|
50
|
+
infer(value: ArkInstanceInvokeExpr, stmt: Stmt): Value | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
53
|
+
* @param expr
|
|
54
|
+
* @param arkMethod
|
|
55
|
+
* @param methodName
|
|
56
|
+
*/
|
|
57
|
+
private processExtendFunc;
|
|
58
|
+
}
|
|
59
|
+
export declare class AliasTypeExprInference extends ValueInference<AliasTypeExpr> {
|
|
60
|
+
getValueName(): string;
|
|
61
|
+
preInfer(value: AliasTypeExpr): boolean;
|
|
62
|
+
infer(value: AliasTypeExpr, stmt: Stmt): Value | undefined;
|
|
63
|
+
}
|
|
64
|
+
export declare class ArkTSLocalInference extends LocalInference {
|
|
65
|
+
getValueName(): string;
|
|
66
|
+
preInfer(value: Local): boolean;
|
|
67
|
+
infer(value: Local, stmt: Stmt): Value | undefined;
|
|
68
|
+
private getEnumValue;
|
|
69
|
+
}
|
|
28
70
|
//# sourceMappingURL=ArkTsInference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkTsInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/arkts/ArkTsInference.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKxG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"ArkTsInference.d.ts","sourceRoot":"","sources":["../../../../src/core/inference/arkts/ArkTsInference.ts"],"names":[],"mappings":"AAeA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not use this file except in compliance with the License.
|
|
6
6
|
* You may obtain a copy of the License at
|
|
@@ -13,10 +13,18 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
};
|
|
16
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.JsInferenceBuilder = exports.ArkTs2InferenceBuilder = exports.ArkTsInferenceBuilder = exports.ArkTsStmtInference = void 0;
|
|
23
|
+
exports.ArkTSLocalInference = exports.AliasTypeExprInference = exports.ArkTsInstanceInvokeExprInference = exports.ArkTSFieldRefInference = exports.JsInferenceBuilder = exports.ArkTs2InferenceBuilder = exports.ArkTsInferenceBuilder = exports.ArkTsStmtInference = void 0;
|
|
18
24
|
const ModelInference_1 = require("../ModelInference");
|
|
25
|
+
const ArkImport_1 = require("../../model/ArkImport");
|
|
19
26
|
const ModelUtils_1 = require("../../common/ModelUtils");
|
|
27
|
+
const ArkClass_1 = require("../../model/ArkClass");
|
|
20
28
|
const TypeInference_1 = require("../../common/TypeInference");
|
|
21
29
|
const InferenceBuilder_1 = require("../InferenceBuilder");
|
|
22
30
|
const ValueInference_1 = require("../ValueInference");
|
|
@@ -25,6 +33,11 @@ const Type_1 = require("../../base/Type");
|
|
|
25
33
|
const Ref_1 = require("../../base/Ref");
|
|
26
34
|
const Local_1 = require("../../base/Local");
|
|
27
35
|
const AbcInference_1 = require("../abc/AbcInference");
|
|
36
|
+
const Const_1 = require("../../common/Const");
|
|
37
|
+
const TSConst_1 = require("../../common/TSConst");
|
|
38
|
+
const Expr_1 = require("../../base/Expr");
|
|
39
|
+
const IRInference_1 = require("../../common/IRInference");
|
|
40
|
+
const ArkField_1 = require("../../model/ArkField");
|
|
28
41
|
class ArkTsImportInference extends ModelInference_1.ImportInfoInference {
|
|
29
42
|
/**
|
|
30
43
|
* get arkFile and assign to from file
|
|
@@ -162,3 +175,177 @@ class JsInferenceBuilder extends InferenceBuilder_1.InferenceBuilder {
|
|
|
162
175
|
}
|
|
163
176
|
}
|
|
164
177
|
exports.JsInferenceBuilder = JsInferenceBuilder;
|
|
178
|
+
let ArkTSFieldRefInference = class ArkTSFieldRefInference extends ValueInference_1.FieldRefInference {
|
|
179
|
+
preInfer(value, stmt) {
|
|
180
|
+
if (stmt.getDef() === value && this.isAnonClassThisRef(value, stmt.getCfg().getDeclaringMethod())) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return super.preInfer(value);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Checks if a value represents an anonymous class 'this' field reference
|
|
187
|
+
* Identifies field references that access fields directly on 'this' in anonymous class constructors
|
|
188
|
+
* @param {Value} stmtDef - The value to check (typically a field reference)
|
|
189
|
+
* @param {ArkMethod} arkMethod - The method containing the value
|
|
190
|
+
* @returns {boolean} True if the value is an anonymous class 'this' field reference
|
|
191
|
+
*/
|
|
192
|
+
isAnonClassThisRef(stmtDef, arkMethod) {
|
|
193
|
+
return (arkMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME || arkMethod.getName() === TSConst_1.CONSTRUCTOR_NAME) &&
|
|
194
|
+
stmtDef instanceof Ref_1.ArkInstanceFieldRef &&
|
|
195
|
+
stmtDef.getBase().getName() === TSConst_1.THIS_NAME &&
|
|
196
|
+
arkMethod.getDeclaringArkClass().isAnonymousClass() &&
|
|
197
|
+
stmtDef.getFieldName().indexOf('.') === -1;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
ArkTSFieldRefInference = __decorate([
|
|
201
|
+
(0, ValueInference_1.Bind)(ValueInference_1.InferLanguage.ARK_TS1_1)
|
|
202
|
+
], ArkTSFieldRefInference);
|
|
203
|
+
exports.ArkTSFieldRefInference = ArkTSFieldRefInference;
|
|
204
|
+
let ArkTsInstanceInvokeExprInference = class ArkTsInstanceInvokeExprInference extends ValueInference_1.InstanceInvokeExprInference {
|
|
205
|
+
/**
|
|
206
|
+
* Performs inference on an instance invocation expression within the context of a statement
|
|
207
|
+
* Enhances the base implementation with real generic type inference and extension function support
|
|
208
|
+
* @param {ArkInstanceInvokeExpr} value - The invocation expression to infer
|
|
209
|
+
* @param {Stmt} stmt - The statement containing the invocation
|
|
210
|
+
* @returns {Value | undefined} Returns a new expression if transformed, undefined otherwise
|
|
211
|
+
*/
|
|
212
|
+
infer(value, stmt) {
|
|
213
|
+
var _a;
|
|
214
|
+
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
215
|
+
TypeInference_1.TypeInference.inferRealGenericTypes(value.getRealGenericTypes(), arkMethod.getDeclaringArkClass());
|
|
216
|
+
const result = (_a = IRInference_1.IRInference.inferInstanceMember(value.getBase().getType(), value, arkMethod, ValueInference_1.InstanceInvokeExprInference.inferInvokeExpr)) !== null && _a !== void 0 ? _a : this.processExtendFunc(value, arkMethod, super.getMethodName(value, arkMethod));
|
|
217
|
+
return !result || result === value ? undefined : result;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* process arkUI function with Annotation @Extend @Styles @AnimatableExtend
|
|
221
|
+
* @param expr
|
|
222
|
+
* @param arkMethod
|
|
223
|
+
* @param methodName
|
|
224
|
+
*/
|
|
225
|
+
processExtendFunc(expr, arkMethod, methodName) {
|
|
226
|
+
var _a;
|
|
227
|
+
const annoMethod = (_a = arkMethod.getDeclaringArkClass().getMethodWithName(methodName)) !== null && _a !== void 0 ? _a : arkMethod.getDeclaringArkFile().getDefaultClass().getMethodWithName(methodName);
|
|
228
|
+
if (annoMethod) {
|
|
229
|
+
expr.setMethodSignature(annoMethod.getSignature());
|
|
230
|
+
return expr;
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
ArkTsInstanceInvokeExprInference = __decorate([
|
|
236
|
+
(0, ValueInference_1.Bind)(ValueInference_1.InferLanguage.ARK_TS1_1)
|
|
237
|
+
], ArkTsInstanceInvokeExprInference);
|
|
238
|
+
exports.ArkTsInstanceInvokeExprInference = ArkTsInstanceInvokeExprInference;
|
|
239
|
+
let AliasTypeExprInference = class AliasTypeExprInference extends ValueInference_1.ValueInference {
|
|
240
|
+
getValueName() {
|
|
241
|
+
return 'AliasTypeExpr';
|
|
242
|
+
}
|
|
243
|
+
preInfer(value) {
|
|
244
|
+
return value.getOriginalType() === undefined;
|
|
245
|
+
}
|
|
246
|
+
infer(value, stmt) {
|
|
247
|
+
var _a;
|
|
248
|
+
let originalObject = value.getOriginalObject();
|
|
249
|
+
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
250
|
+
let type;
|
|
251
|
+
let originalLocal;
|
|
252
|
+
if (originalObject instanceof Local_1.Local) {
|
|
253
|
+
originalLocal = ModelUtils_1.ModelUtils.findArkModelByRefName(originalObject.getName(), arkMethod.getDeclaringArkClass());
|
|
254
|
+
if (Expr_1.AliasTypeExpr.isAliasTypeOriginalModel(originalLocal)) {
|
|
255
|
+
originalObject = originalLocal;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (originalObject instanceof ArkImport_1.ImportInfo) {
|
|
259
|
+
const arkExport = (_a = originalObject.getLazyExportInfo()) === null || _a === void 0 ? void 0 : _a.getArkExport();
|
|
260
|
+
const importClauseName = originalObject.getImportClauseName();
|
|
261
|
+
if (importClauseName.includes('.') && arkExport instanceof ArkClass_1.ArkClass) {
|
|
262
|
+
type = TypeInference_1.TypeInference.inferUnclearRefName(importClauseName, arkExport);
|
|
263
|
+
}
|
|
264
|
+
else if (arkExport) {
|
|
265
|
+
type = TypeInference_1.TypeInference.parseArkExport2Type(arkExport);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (originalObject instanceof Type_1.Type) {
|
|
269
|
+
type = TypeInference_1.TypeInference.inferUnclearedType(originalObject, arkMethod.getDeclaringArkClass());
|
|
270
|
+
}
|
|
271
|
+
else if (originalObject instanceof ArkField_1.ArkField) {
|
|
272
|
+
type = originalObject.getType();
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
type = TypeInference_1.TypeInference.parseArkExport2Type(originalObject);
|
|
276
|
+
}
|
|
277
|
+
if (type) {
|
|
278
|
+
const realGenericTypes = value.getRealGenericTypes();
|
|
279
|
+
if (TypeInference_1.TypeInference.checkType(type, t => t instanceof Type_1.GenericType || t instanceof Type_1.AnyType) && realGenericTypes && realGenericTypes.length > 0) {
|
|
280
|
+
TypeInference_1.TypeInference.inferRealGenericTypes(realGenericTypes, arkMethod.getDeclaringArkClass());
|
|
281
|
+
type = TypeInference_1.TypeInference.replaceTypeWithReal(type, realGenericTypes);
|
|
282
|
+
}
|
|
283
|
+
value.setOriginalType(type);
|
|
284
|
+
if (Expr_1.AliasTypeExpr.isAliasTypeOriginalModel(originalLocal)) {
|
|
285
|
+
value.setOriginalObject(originalLocal);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
AliasTypeExprInference = __decorate([
|
|
292
|
+
(0, ValueInference_1.Bind)(ValueInference_1.InferLanguage.ARK_TS1_1)
|
|
293
|
+
], AliasTypeExprInference);
|
|
294
|
+
exports.AliasTypeExprInference = AliasTypeExprInference;
|
|
295
|
+
let ArkTSLocalInference = class ArkTSLocalInference extends ValueInference_1.LocalInference {
|
|
296
|
+
getValueName() {
|
|
297
|
+
return 'Local';
|
|
298
|
+
}
|
|
299
|
+
preInfer(value) {
|
|
300
|
+
const type = value.getType();
|
|
301
|
+
if (value.getName() === TSConst_1.THIS_NAME && type instanceof Type_1.ClassType &&
|
|
302
|
+
type.getClassSignature().getClassName().startsWith(Const_1.ANONYMOUS_CLASS_PREFIX)) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
else if (type instanceof Type_1.FunctionType) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
return super.preInfer(value);
|
|
309
|
+
}
|
|
310
|
+
infer(value, stmt) {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
const name = value.getName();
|
|
313
|
+
const type = value.getType();
|
|
314
|
+
const arkMethod = stmt.getCfg().getDeclaringMethod();
|
|
315
|
+
let newType;
|
|
316
|
+
if (name === TSConst_1.THIS_NAME) {
|
|
317
|
+
newType = (_a = IRInference_1.IRInference.inferThisLocal(arkMethod)) === null || _a === void 0 ? void 0 : _a.getType();
|
|
318
|
+
if (newType) {
|
|
319
|
+
value.setType(newType);
|
|
320
|
+
}
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
else if (type instanceof Type_1.FunctionType) {
|
|
324
|
+
const methodSignature = type.getMethodSignature();
|
|
325
|
+
methodSignature.getMethodSubSignature().getParameters().forEach(p => TypeInference_1.TypeInference.inferParameterType(p, arkMethod));
|
|
326
|
+
TypeInference_1.TypeInference.inferSignatureReturnType(methodSignature, arkMethod);
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
newType = (_b = TypeInference_1.TypeInference.inferUnclearedType(type, arkMethod.getDeclaringArkClass())) !== null && _b !== void 0 ? _b : this.getEnumValue(arkMethod.getDeclaringArkClass(), name);
|
|
331
|
+
}
|
|
332
|
+
if (newType) {
|
|
333
|
+
value.setType(newType);
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
return super.infer(value, stmt);
|
|
337
|
+
}
|
|
338
|
+
getEnumValue(arkClass, name) {
|
|
339
|
+
if (arkClass.getCategory() === ArkClass_1.ClassCategory.ENUM) {
|
|
340
|
+
const field = arkClass.getStaticFieldWithName(name);
|
|
341
|
+
if (field) {
|
|
342
|
+
return TypeInference_1.TypeInference.getEnumValueType(field);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
ArkTSLocalInference = __decorate([
|
|
349
|
+
(0, ValueInference_1.Bind)(ValueInference_1.InferLanguage.ARK_TS1_1)
|
|
350
|
+
], ArkTSLocalInference);
|
|
351
|
+
exports.ArkTSLocalInference = ArkTSLocalInference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkClassBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkClassBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ArkClassBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkClassBuilder.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AA2CtD,MAAM,MAAM,aAAa,GACnB,EAAE,CAAC,gBAAgB,GACnB,EAAE,CAAC,oBAAoB,GACvB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,eAAe,GAClB,EAAE,CAAC,iBAAiB,GACpB,EAAE,CAAC,uBAAuB,CAAC;AAUjC,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,CAItH;AAED,wBAAgB,oCAAoC,CAChD,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,QAAQ,EACtB,MAAM,EAAE,EAAE,CAAC,iBAAiB,EAC5B,UAAU,EAAE,EAAE,CAAC,UAAU,GAC1B,IAAI,CAIN;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,GAAG,IAAI,CAOpJ;AAED,wBAAgB,8BAA8B,CAC1C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,eAAe,CAAC,EAAE,SAAS,GAC5B,IAAI,CASN;AAED,wBAAgB,mCAAmC,CAC/C,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,eAAe,CAAC,EAAE,SAAS,GAC5B,IAAI,CAUN;AAmBD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,GAAG,IAAI,CA0BvI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c) 2024-
|
|
3
|
+
* Copyright (c) 2024-2026 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
|
|
@@ -390,10 +390,7 @@ function buildMethodsForClass(clsNode, cls, sourceFile) {
|
|
|
390
390
|
ohos_typescript_1.default.isCallSignatureDeclaration(member)) {
|
|
391
391
|
let mthd = new ArkMethod_1.ArkMethod();
|
|
392
392
|
(0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(member, cls, mthd, sourceFile);
|
|
393
|
-
if (ohos_typescript_1.default.
|
|
394
|
-
(0, ArkFieldBuilder_1.buildGetAccessor2ArkField)(member, mthd, sourceFile);
|
|
395
|
-
}
|
|
396
|
-
else if (ohos_typescript_1.default.isConstructorDeclaration(member)) {
|
|
393
|
+
if (ohos_typescript_1.default.isConstructorDeclaration(member)) {
|
|
397
394
|
buildParameterProperty2ArkField(member.parameters, cls, sourceFile);
|
|
398
395
|
}
|
|
399
396
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArkMethodBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkMethodBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgBjC,OAAO,EAAkE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvG,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ArkMethodBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkMethodBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,IAAI,EAAe,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MA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