arkanalyzer 1.0.67 → 1.0.69
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/plugins/SdkPlugin.d.ts +4 -0
- package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.d.ts.map +1 -1
- package/lib/callgraph/pointerAnalysis/plugins/SdkPlugin.js +114 -0
- package/lib/core/common/Const.d.ts +1 -0
- package/lib/core/common/Const.d.ts.map +1 -1
- package/lib/core/common/Const.js +3 -1
- 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 +2 -1
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts +51 -1
- package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
- package/lib/core/graph/builder/ViewTreeBuilder.js +182 -26
- package/package.json +2 -2
|
@@ -15,6 +15,7 @@ export declare class SdkPlugin implements IPagPlugin {
|
|
|
15
15
|
pagBuilder: PagBuilder;
|
|
16
16
|
cg: CallGraph;
|
|
17
17
|
private sdkMethodReturnValueMap;
|
|
18
|
+
private sdkMethodReturnArrayMap;
|
|
18
19
|
private methodParamValueMap;
|
|
19
20
|
private fakeSdkMethodParamDeclaringStmt;
|
|
20
21
|
constructor(pag: Pag, pagBuilder: PagBuilder, cg: CallGraph);
|
|
@@ -28,6 +29,9 @@ export declare class SdkPlugin implements IPagPlugin {
|
|
|
28
29
|
buildSDKFuncPag(funcID: FuncID, sdkMethod: ArkMethod): void;
|
|
29
30
|
private createDummyParamValue;
|
|
30
31
|
private addSDKMethodReturnPagEdge;
|
|
32
|
+
private addSDKMethodReturnArrayPagEdge;
|
|
33
|
+
private addSDKMethodReturnUnionPagEdge;
|
|
34
|
+
private addSDKMethodReturnGenericPagEdge;
|
|
31
35
|
/**
|
|
32
36
|
* process the anonymous method param, create a new CallSite for it and invoke it.
|
|
33
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdkPlugin.d.ts","sourceRoot":"","sources":["../../../../src/callgraph/pointerAnalysis/plugins/SdkPlugin.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"SdkPlugin.d.ts","sourceRoot":"","sources":["../../../../src/callgraph/pointerAnalysis/plugins/SdkPlugin.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAA6B,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,SAAU,YAAW,UAAU;IACxC,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,SAAS,CAAC;IAEd,OAAO,CAAC,uBAAuB,CAA6C;IAC5E,OAAO,CAAC,uBAAuB,CAAkD;IACjF,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,+BAA+B,CAAO;gBAElC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS;IAW3D,OAAO,IAAI,MAAM;IAIjB,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;IAKxD,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAM5E,OAAO,CAAC,uBAAuB;IAiB/B;;OAEG;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAMlE,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,yBAAyB;IA6CjC,OAAO,CAAC,8BAA8B;IAsCtC,OAAO,CAAC,8BAA8B;IAkCtC,OAAO,CAAC,gCAAgC;IA6BxC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAsDzB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,SAAS;CAIhE"}
|
|
@@ -19,6 +19,7 @@ const Expr_1 = require("../../../core/base/Expr");
|
|
|
19
19
|
const Local_1 = require("../../../core/base/Local");
|
|
20
20
|
const Stmt_1 = require("../../../core/base/Stmt");
|
|
21
21
|
const Type_1 = require("../../../core/base/Type");
|
|
22
|
+
const Const_1 = require("../../../core/common/Const");
|
|
22
23
|
const Pag_1 = require("../Pag");
|
|
23
24
|
const PTAUtils_1 = require("../PTAUtils");
|
|
24
25
|
/**
|
|
@@ -31,6 +32,8 @@ class SdkPlugin {
|
|
|
31
32
|
this.pagBuilder = pagBuilder;
|
|
32
33
|
this.cg = cg;
|
|
33
34
|
this.sdkMethodReturnValueMap = new Map();
|
|
35
|
+
this.sdkMethodReturnArrayMap = new Map();
|
|
36
|
+
this.sdkMethodReturnArrayMap = new Map();
|
|
34
37
|
this.methodParamValueMap = new Map();
|
|
35
38
|
this.fakeSdkMethodParamDeclaringStmt = new Stmt_1.ArkAssignStmt(new Local_1.Local(''), new Local_1.Local(''));
|
|
36
39
|
}
|
|
@@ -83,6 +86,23 @@ class SdkPlugin {
|
|
|
83
86
|
}
|
|
84
87
|
addSDKMethodReturnPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes) {
|
|
85
88
|
let returnType = calleeMethod.getReturnType();
|
|
89
|
+
if (returnType instanceof Type_1.ArrayType && cs.callStmt instanceof Stmt_1.ArkAssignStmt) {
|
|
90
|
+
// Handling the return value of collections.Array.creat, return type is ArrayType
|
|
91
|
+
this.addSDKMethodReturnArrayPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (returnType instanceof Type_1.UnionType && cs.callStmt instanceof Stmt_1.ArkAssignStmt) {
|
|
95
|
+
// Handling the return value of ArkTSUtils.ASON.parse, return type is UnionType
|
|
96
|
+
// find real type in UnionType
|
|
97
|
+
this.addSDKMethodReturnUnionPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (returnType instanceof Type_1.GenericType && cs.callStmt instanceof Stmt_1.ArkAssignStmt) {
|
|
101
|
+
// Handling the return value of UIUtils.makeObserved, return type is GenericType
|
|
102
|
+
// find real type in callsite realGenericTypes
|
|
103
|
+
this.addSDKMethodReturnGenericPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
86
106
|
if (!(returnType instanceof Type_1.ClassType) || !(cs.callStmt instanceof Stmt_1.ArkAssignStmt)) {
|
|
87
107
|
return;
|
|
88
108
|
}
|
|
@@ -105,6 +125,100 @@ class SdkPlugin {
|
|
|
105
125
|
srcNodes.push(srcPagNode.getID());
|
|
106
126
|
return;
|
|
107
127
|
}
|
|
128
|
+
addSDKMethodReturnArrayPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes) {
|
|
129
|
+
var _a;
|
|
130
|
+
let returnType = calleeMethod.getReturnType();
|
|
131
|
+
let callstmt = cs.callStmt;
|
|
132
|
+
let arraycidMap = this.sdkMethodReturnArrayMap.get(calleeMethod);
|
|
133
|
+
if (!arraycidMap) {
|
|
134
|
+
arraycidMap = new Map();
|
|
135
|
+
}
|
|
136
|
+
let newArrayExpr = arraycidMap.get(calleeCid);
|
|
137
|
+
if (!newArrayExpr) {
|
|
138
|
+
let staticInvokeExpr = callstmt.getRightOp();
|
|
139
|
+
if (!(staticInvokeExpr instanceof Expr_1.ArkStaticInvokeExpr)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (((_a = staticInvokeExpr.getMethodSignature().getDeclaringClassSignature().getDeclaringNamespaceSignature()) === null || _a === void 0 ? void 0 : _a.getNamespaceName()) === 'collections') {
|
|
143
|
+
let realtypes = staticInvokeExpr.getRealGenericTypes();
|
|
144
|
+
if (realtypes !== undefined && realtypes.length > 0) {
|
|
145
|
+
// create new array with real type
|
|
146
|
+
newArrayExpr = new Expr_1.ArkNewArrayExpr(realtypes[0], staticInvokeExpr.getArg(0));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// create new array with base type
|
|
150
|
+
newArrayExpr = new Expr_1.ArkNewArrayExpr(returnType.getBaseType(), staticInvokeExpr.getArg(0));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (newArrayExpr === undefined) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
arraycidMap.set(calleeCid, newArrayExpr);
|
|
158
|
+
this.sdkMethodReturnArrayMap.set(calleeMethod, arraycidMap);
|
|
159
|
+
let srcPagNode = this.pagBuilder.getOrNewPagNode(calleeCid, newArrayExpr);
|
|
160
|
+
let dstPagNode = this.pagBuilder.getOrNewPagNode(callerCid, callstmt.getLeftOp(), cs.callStmt);
|
|
161
|
+
this.pag.addPagEdge(srcPagNode, dstPagNode, Pag_1.PagEdgeKind.Address, cs.callStmt);
|
|
162
|
+
srcNodes.push(srcPagNode.getID());
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
addSDKMethodReturnUnionPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes) {
|
|
166
|
+
let returnType = calleeMethod.getReturnType();
|
|
167
|
+
let callstmt = cs.callStmt;
|
|
168
|
+
let cidMap = this.sdkMethodReturnValueMap.get(calleeMethod);
|
|
169
|
+
if (!cidMap) {
|
|
170
|
+
cidMap = new Map();
|
|
171
|
+
}
|
|
172
|
+
let newExpr = cidMap.get(calleeCid);
|
|
173
|
+
if (!newExpr) {
|
|
174
|
+
let types = returnType.getTypes();
|
|
175
|
+
for (let uniontype of types) {
|
|
176
|
+
if (uniontype instanceof Type_1.AliasType && uniontype.getOriginalType() instanceof Type_1.ClassType) {
|
|
177
|
+
let classtype = uniontype.getOriginalType();
|
|
178
|
+
newExpr = new Expr_1.ArkNewExpr(classtype);
|
|
179
|
+
}
|
|
180
|
+
if (uniontype instanceof Type_1.ClassType) {
|
|
181
|
+
newExpr = new Expr_1.ArkNewExpr(uniontype);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (newExpr === undefined) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
cidMap.set(calleeCid, newExpr);
|
|
189
|
+
this.sdkMethodReturnValueMap.set(calleeMethod, cidMap);
|
|
190
|
+
let srcPagNode = this.pagBuilder.getOrNewPagNode(calleeCid, newExpr);
|
|
191
|
+
let dstPagNode = this.pagBuilder.getOrNewPagNode(callerCid, callstmt.getLeftOp(), cs.callStmt);
|
|
192
|
+
this.pag.addPagEdge(srcPagNode, dstPagNode, Pag_1.PagEdgeKind.Address, cs.callStmt);
|
|
193
|
+
srcNodes.push(srcPagNode.getID());
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
addSDKMethodReturnGenericPagEdge(cs, callerCid, calleeCid, calleeMethod, srcNodes) {
|
|
197
|
+
if (calleeMethod.getName() === Const_1.MAKEOBSERVED) {
|
|
198
|
+
let callstmt = cs.callStmt;
|
|
199
|
+
let cidMap = this.sdkMethodReturnValueMap.get(calleeMethod);
|
|
200
|
+
if (!cidMap) {
|
|
201
|
+
cidMap = new Map();
|
|
202
|
+
}
|
|
203
|
+
let newExpr = cidMap.get(calleeCid);
|
|
204
|
+
if (!newExpr && cs.args !== undefined && cs.args.length > 0) {
|
|
205
|
+
let type = cs.args[0].getType();
|
|
206
|
+
if (type instanceof Type_1.ClassType) {
|
|
207
|
+
newExpr = new Expr_1.ArkNewExpr(type);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (newExpr === undefined) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
cidMap.set(calleeCid, newExpr);
|
|
214
|
+
this.sdkMethodReturnValueMap.set(calleeMethod, cidMap);
|
|
215
|
+
let srcPagNode = this.pagBuilder.getOrNewPagNode(calleeCid, newExpr);
|
|
216
|
+
let dstPagNode = this.pagBuilder.getOrNewPagNode(callerCid, callstmt.getLeftOp(), cs.callStmt);
|
|
217
|
+
this.pag.addPagEdge(srcPagNode, dstPagNode, Pag_1.PagEdgeKind.Address, cs.callStmt);
|
|
218
|
+
srcNodes.push(srcPagNode.getID());
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
108
222
|
/**
|
|
109
223
|
* process the anonymous method param, create a new CallSite for it and invoke it.
|
|
110
224
|
*/
|
|
@@ -20,4 +20,5 @@ export declare const UNKNOWN_METHOD_NAME = "";
|
|
|
20
20
|
export declare const TEMP_LOCAL_PREFIX = "%";
|
|
21
21
|
export declare const LEXICAL_ENV_NAME_PREFIX: string;
|
|
22
22
|
export declare const ARKTS_STATIC_MARK = "use static";
|
|
23
|
+
export declare const MAKEOBSERVED = "makeObserved";
|
|
23
24
|
//# sourceMappingURL=Const.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Const.d.ts","sourceRoot":"","sources":["../../../src/core/common/Const.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,YAAY,SAAS,CAAC;AAGnC,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AACjE,eAAO,MAAM,sBAAsB,QAAqB,CAAC;AACzD,eA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O,MAAM,oBAAoB,QAA6B,CAAC;AAC/D,eAAO,MAAM,iBAAiB,QAA6B,CAAC;AAC5D,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AACjE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC,eAAO,MAAM,iBAAiB,MAAc,CAAC;AAC7C,eAAO,MAAM,uBAAuB,QAAiC,CAAC;AAGtE,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAG9C,eAAO,MAAM,YAAY,iBAAiB,CAAC"}
|
package/lib/core/common/Const.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ARKTS_STATIC_MARK = exports.LEXICAL_ENV_NAME_PREFIX = exports.TEMP_LOCAL_PREFIX = exports.UNKNOWN_METHOD_NAME = exports.UNKNOWN_FIELD_NAME = exports.UNKNOWN_CLASS_NAME = exports.UNKNOWN_NAMESPACE_NAME = exports.UNKNOWN_FILE_NAME = exports.UNKNOWN_PROJECT_NAME = exports.CALL_SIGNATURE_NAME = exports.ANONYMOUS_METHOD_PREFIX = exports.STATIC_BLOCK_METHOD_NAME_PREFIX = exports.STATIC_INIT_METHOD_NAME = exports.INSTANCE_INIT_METHOD_NAME = exports.DEFAULT_ARK_METHOD_NAME = exports.ANONYMOUS_CLASS_DELIMITER = exports.ANONYMOUS_CLASS_PREFIX = exports.DEFAULT_ARK_CLASS_NAME = exports.DEFAULT_NAME = exports.UNKNOWN_NAME = exports.NAME_PREFIX = exports.NAME_DELIMITER = void 0;
|
|
17
|
+
exports.MAKEOBSERVED = exports.ARKTS_STATIC_MARK = exports.LEXICAL_ENV_NAME_PREFIX = exports.TEMP_LOCAL_PREFIX = exports.UNKNOWN_METHOD_NAME = exports.UNKNOWN_FIELD_NAME = exports.UNKNOWN_CLASS_NAME = exports.UNKNOWN_NAMESPACE_NAME = exports.UNKNOWN_FILE_NAME = exports.UNKNOWN_PROJECT_NAME = exports.CALL_SIGNATURE_NAME = exports.ANONYMOUS_METHOD_PREFIX = exports.STATIC_BLOCK_METHOD_NAME_PREFIX = exports.STATIC_INIT_METHOD_NAME = exports.INSTANCE_INIT_METHOD_NAME = exports.DEFAULT_ARK_METHOD_NAME = exports.ANONYMOUS_CLASS_DELIMITER = exports.ANONYMOUS_CLASS_PREFIX = exports.DEFAULT_ARK_CLASS_NAME = exports.DEFAULT_NAME = exports.UNKNOWN_NAME = exports.NAME_PREFIX = exports.NAME_DELIMITER = void 0;
|
|
18
18
|
// names
|
|
19
19
|
exports.NAME_DELIMITER = '$';
|
|
20
20
|
exports.NAME_PREFIX = '%';
|
|
@@ -43,3 +43,5 @@ exports.TEMP_LOCAL_PREFIX = exports.NAME_PREFIX;
|
|
|
43
43
|
exports.LEXICAL_ENV_NAME_PREFIX = exports.TEMP_LOCAL_PREFIX + 'closures';
|
|
44
44
|
// ArkTS version
|
|
45
45
|
exports.ARKTS_STATIC_MARK = 'use static';
|
|
46
|
+
// Concurrent const
|
|
47
|
+
exports.MAKEOBSERVED = 'makeObserved';
|
|
@@ -52,6 +52,7 @@ export declare const COMPONENT_DECORATOR: Set<string>;
|
|
|
52
52
|
export declare const ENTRY_DECORATOR: string;
|
|
53
53
|
export declare const BUILDER_DECORATOR: string;
|
|
54
54
|
export declare const BUILDER_PARAM_DECORATOR: string;
|
|
55
|
+
export declare const COMPONENT_BEHAVIOR: string;
|
|
55
56
|
export declare function isEtsAtomicComponent(name: string): boolean;
|
|
56
57
|
export declare function isEtsSystemComponent(name: string): boolean;
|
|
57
58
|
export declare function isEtsContainerComponent(name: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EtsConst.d.ts","sourceRoot":"","sources":["../../../src/core/common/EtsConst.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,oB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,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,sBAAsB,EAAE,MAAc,CAAC;AACpD,eAAO,MAAM,oBAAoB,EAAE,MAAe,CAAC;AACnD,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,EAAE,MAAa,CAAC;AACzC,eAAO,MAAM,mBAAmB,EAAE,MAAmB,CAAC;AACtD,eAAO,MAAM,yBAAyB,EAAE,MAAiB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,EAAE,MAAgB,CAAC;AAExD,eAAO,MAAM,2BAA2B,EAAE,GAAG,CAAC,MAAM,CAAwF,CAAC;AAE7I,eAAO,MAAM,gBAAgB,EAAE,MAAiB,CAAC;AACjD,eAAO,MAAM,kBAAkB,EAAE,MAAmB,CAAC;AAErD,eAAO,MAAM,mBAAmB,EAAE,MAAoB,CAAC;AACvD,eAAO,MAAM,SAAS,EAAE,MAAmB,CAAC;AAC5C,eAAO,MAAM,MAAM,EAAE,GAAG,CAAC,MAAM,CAA0B,CAAC;AAE1D,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,mBAAmB,wBAAwB,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
|
|
17
|
+
exports.BUILD_PROFILE_JSON5 = exports.OH_PACKAGE_JSON5 = exports.ON_OFF = exports.CALL_BACK = exports.COMPONENT_ATTRIBUTE = exports.COMPONENT_INSTANCE = exports.COMPONENT_COMMON = exports.SPECIAL_CONTAINER_COMPONENT = exports.COMPONENT_BUILD_FUNCTION = exports.COMPONENT_BRANCH_FUNCTION = exports.COMPONENT_IF_BRANCH = exports.COMPONENT_IF = exports.COMPONENT_REPEAT = exports.COMPONENT_CUSTOMVIEW = exports.COMPONENT_POP_FUNCTION = exports.COMPONENT_CREATE_FUNCTION = exports.isEtsContainerComponent = exports.isEtsSystemComponent = exports.isEtsAtomicComponent = exports.COMPONENT_BEHAVIOR = exports.BUILDER_PARAM_DECORATOR = exports.BUILDER_DECORATOR = exports.ENTRY_DECORATOR = exports.COMPONENT_DECORATOR = exports.BUILDIN_ATOMIC_COMPONENT = exports.BUILDIN_SYSTEM_COMPONENT = exports.COMPONENT_LAZY_FOR_EACH = exports.COMPONENT_FOR_EACH = exports.ETS_COMPILER_OPTIONS = void 0;
|
|
18
18
|
exports.ETS_COMPILER_OPTIONS = {
|
|
19
19
|
ets: {
|
|
20
20
|
emitDecorators: [
|
|
@@ -982,6 +982,7 @@ exports.COMPONENT_DECORATOR = new Set(['Reusable', 'Component', 'ComponentV2', '
|
|
|
982
982
|
exports.ENTRY_DECORATOR = 'Entry';
|
|
983
983
|
exports.BUILDER_DECORATOR = 'Builder';
|
|
984
984
|
exports.BUILDER_PARAM_DECORATOR = 'BuilderParam';
|
|
985
|
+
exports.COMPONENT_BEHAVIOR = 'Behavior';
|
|
985
986
|
function isEtsAtomicComponent(name) {
|
|
986
987
|
return exports.BUILDIN_ATOMIC_COMPONENT.has(name);
|
|
987
988
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Constant } from '../../base/Constant';
|
|
2
2
|
import { Decorator } from '../../base/Decorator';
|
|
3
|
+
import { ArkInstanceInvokeExpr } from '../../base/Expr';
|
|
4
|
+
import { Local } from '../../base/Local';
|
|
3
5
|
import { ArkInstanceFieldRef } from '../../base/Ref';
|
|
4
6
|
import { Stmt } from '../../base/Stmt';
|
|
5
7
|
import { Type } from '../../base/Type';
|
|
@@ -47,10 +49,11 @@ declare class ViewTreeNodeImpl implements ViewTreeNode {
|
|
|
47
49
|
static createCustomComponent(): ViewTreeNodeImpl;
|
|
48
50
|
static createBuilderNode(): ViewTreeNodeImpl;
|
|
49
51
|
static createBuilderParamNode(): ViewTreeNodeImpl;
|
|
52
|
+
static createBehaviorNode(): ViewTreeNodeImpl;
|
|
50
53
|
changeBuilderParam2BuilderNode(builder: ArkMethod): void;
|
|
51
54
|
hasBuilderParam(): boolean;
|
|
52
55
|
clone(parent: ViewTreeNodeImpl, map?: Map<ViewTreeNodeImpl, ViewTreeNodeImpl>): ViewTreeNodeImpl;
|
|
53
|
-
addStmt(tree: ViewTreeImpl, stmt: Stmt): void;
|
|
56
|
+
addStmt(local2Node: Map<Local, ViewTreeNodeImpl>, tree: ViewTreeImpl, stmt: Stmt): void;
|
|
54
57
|
private parseAttributes;
|
|
55
58
|
private getBindValues;
|
|
56
59
|
parseStateValues(tree: ViewTreeImpl, stmt: Stmt): void;
|
|
@@ -173,6 +176,7 @@ export declare class ViewTreeImpl extends TreeNodeStack implements ViewTree {
|
|
|
173
176
|
private repeatCreationParser;
|
|
174
177
|
private ifBranchCreationParser;
|
|
175
178
|
private COMPONENT_CREATE_PARSERS;
|
|
179
|
+
COMPONENT_BEHAVIOR_PARSERS: Map<string, (local2Node: Map<Local, ViewTreeNodeImpl>, stmt: Stmt, expr: ArkInstanceInvokeExpr) => ViewTreeNodeImpl | undefined>;
|
|
176
180
|
private componentCreateParse;
|
|
177
181
|
private parseStaticInvokeExpr;
|
|
178
182
|
/**
|
|
@@ -200,6 +204,52 @@ export declare class ViewTreeImpl extends TreeNodeStack implements ViewTree {
|
|
|
200
204
|
private parseAssignStmt;
|
|
201
205
|
private parseInvokeStmt;
|
|
202
206
|
private buildViewTreeFromCfg;
|
|
207
|
+
/**
|
|
208
|
+
* Parses the 'tabBar' behavior binding.
|
|
209
|
+
* Only supports extracting the argument when it is of type CustomBuilder.
|
|
210
|
+
* Other argument types (e.g. string, Resource, TabBarOptions, SubTabBarStyle, BottomTabBarStyle, ComponentContent) are not handled.
|
|
211
|
+
*
|
|
212
|
+
* Supported signatures:
|
|
213
|
+
* - tabBar(options: string | Resource | CustomBuilder | TabBarOptions)
|
|
214
|
+
* - tabBar(value: SubTabBarStyle | BottomTabBarStyle) // API 9+
|
|
215
|
+
* - tabBar(content: ComponentContent | SubTabBarStyle | BottomTabBarStyle | string | Resource | CustomBuilder | TabBarOptions) // API 18+
|
|
216
|
+
*/
|
|
217
|
+
private tabBarComponentParser;
|
|
218
|
+
/**
|
|
219
|
+
* Parses the 'navDestination' behavior binding.
|
|
220
|
+
* Supports extracting the 'builder' argument when it is of FunctionType.
|
|
221
|
+
*
|
|
222
|
+
* navDestination(builder: (name: string, param: unknown) => void)
|
|
223
|
+
*/
|
|
224
|
+
private navDestinationComponentParser;
|
|
225
|
+
/**
|
|
226
|
+
* Parses the 'bindContextMenu' behavior binding for API 8 and API 12.
|
|
227
|
+
* Only supports extracting the 'content' argument when it is of type CustomBuilder.
|
|
228
|
+
* Other argument types (e.g. ResponseType, ContextMenuOptions) are not handled.
|
|
229
|
+
*
|
|
230
|
+
* Supported signatures:
|
|
231
|
+
* - bindContextMenu(content: CustomBuilder, responseType: ResponseType, options?: ContextMenuOptions): T // API 8
|
|
232
|
+
* - bindContextMenu(isShown: boolean, content: CustomBuilder, options?: ContextMenuOptions): T // API 12
|
|
233
|
+
*/
|
|
234
|
+
private bindContextMenuComponentParser;
|
|
235
|
+
/**
|
|
236
|
+
* Parses the 'bindContentCover' behavior binding.
|
|
237
|
+
* Only supports extracting the CustomBuilder argument from the second parameter.
|
|
238
|
+
* Other ContentCoverOptions properties are not handled.
|
|
239
|
+
*
|
|
240
|
+
* bindContentCover(isShow: boolean, builder: CustomBuilder, options?: ContentCoverOptions): T
|
|
241
|
+
*/
|
|
242
|
+
private bindContentCoverComponentParser;
|
|
243
|
+
/**
|
|
244
|
+
* Parses the 'bindPopup' behavior binding.
|
|
245
|
+
* Only supports extracting the 'builder' field from CustomPopupOptions (custom popup content).
|
|
246
|
+
* Other PopupOptions properties are not supported yet.
|
|
247
|
+
*
|
|
248
|
+
* bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): T
|
|
249
|
+
*/
|
|
250
|
+
private bindPopupComponentParser;
|
|
251
|
+
private parseBehaviorComponent;
|
|
252
|
+
private parseBuilderFieldNode;
|
|
203
253
|
}
|
|
204
254
|
export declare function buildViewTree(render: ArkMethod): ViewTree;
|
|
205
255
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewTreeBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/builder/ViewTreeBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ViewTreeBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/builder/ViewTreeBuilder.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AA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AEzD"}
|
|
@@ -266,6 +266,11 @@ class ViewTreeNodeImpl {
|
|
|
266
266
|
instance.type = ViewTreeNodeType.BuilderParam;
|
|
267
267
|
return instance;
|
|
268
268
|
}
|
|
269
|
+
static createBehaviorNode() {
|
|
270
|
+
let instance = new ViewTreeNodeImpl(EtsConst_1.COMPONENT_BEHAVIOR);
|
|
271
|
+
instance.type = ViewTreeNodeType.SystemComponent; // to check
|
|
272
|
+
return instance;
|
|
273
|
+
}
|
|
269
274
|
changeBuilderParam2BuilderNode(builder) {
|
|
270
275
|
var _a;
|
|
271
276
|
this.name = EtsConst_1.BUILDER_DECORATOR;
|
|
@@ -309,13 +314,13 @@ class ViewTreeNodeImpl {
|
|
|
309
314
|
}
|
|
310
315
|
return newNode;
|
|
311
316
|
}
|
|
312
|
-
addStmt(tree, stmt) {
|
|
313
|
-
this.parseAttributes(stmt);
|
|
317
|
+
addStmt(local2Node, tree, stmt) {
|
|
318
|
+
this.parseAttributes(local2Node, tree, stmt);
|
|
314
319
|
if (this.name !== EtsConst_1.COMPONENT_FOR_EACH && this.name !== EtsConst_1.COMPONENT_LAZY_FOR_EACH) {
|
|
315
320
|
this.parseStateValues(tree, stmt);
|
|
316
321
|
}
|
|
317
322
|
}
|
|
318
|
-
parseAttributes(stmt) {
|
|
323
|
+
parseAttributes(local2Node, tree, stmt) {
|
|
319
324
|
let expr;
|
|
320
325
|
if (stmt instanceof Stmt_1.ArkAssignStmt) {
|
|
321
326
|
let op = stmt.getRightOp();
|
|
@@ -346,6 +351,23 @@ class ViewTreeNodeImpl {
|
|
|
346
351
|
relationValues.push(arg);
|
|
347
352
|
}
|
|
348
353
|
}
|
|
354
|
+
let builderNode;
|
|
355
|
+
if (tree.COMPONENT_BEHAVIOR_PARSERS.has(key) && expr instanceof Expr_1.ArkInstanceInvokeExpr) {
|
|
356
|
+
let parseFn = tree.COMPONENT_BEHAVIOR_PARSERS.get(key);
|
|
357
|
+
if (parseFn) {
|
|
358
|
+
builderNode = parseFn(local2Node, stmt, expr);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (builderNode) {
|
|
362
|
+
// create a virtual node name 'Behavior' to hold the behaviorNode
|
|
363
|
+
let behaviorNode = ViewTreeNodeImpl.createBehaviorNode();
|
|
364
|
+
behaviorNode.attributes.set(key, [stmt, relationValues]);
|
|
365
|
+
behaviorNode.parseStateValues(tree, stmt);
|
|
366
|
+
behaviorNode.children.push(builderNode);
|
|
367
|
+
builderNode.parent = behaviorNode;
|
|
368
|
+
this.children.push(behaviorNode);
|
|
369
|
+
behaviorNode.parent = this;
|
|
370
|
+
}
|
|
349
371
|
this.attributes.set(key, [stmt, relationValues]);
|
|
350
372
|
}
|
|
351
373
|
}
|
|
@@ -473,6 +495,15 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
473
495
|
['If.branch', this.ifBranchCreationParser.bind(this)],
|
|
474
496
|
['WaterFlow.create', this.waterFlowCreationParser.bind(this)],
|
|
475
497
|
]);
|
|
498
|
+
this.COMPONENT_BEHAVIOR_PARSERS = new Map([
|
|
499
|
+
['tabBar', this.tabBarComponentParser.bind(this)],
|
|
500
|
+
['navDestination', this.navDestinationComponentParser.bind(this)],
|
|
501
|
+
['bindContextMenu', this.bindContextMenuComponentParser.bind(this)],
|
|
502
|
+
['bindMenu', this.bindContextMenuComponentParser.bind(this)],
|
|
503
|
+
['bindContentCover', this.bindContentCoverComponentParser.bind(this)],
|
|
504
|
+
['bindSheet', this.bindContentCoverComponentParser.bind(this)],
|
|
505
|
+
['bindPopup', this.bindPopupComponentParser.bind(this)],
|
|
506
|
+
]);
|
|
476
507
|
this.render = render;
|
|
477
508
|
this.stateValues = new Map();
|
|
478
509
|
this.fieldTypes = new Map();
|
|
@@ -643,7 +674,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
643
674
|
/**
|
|
644
675
|
* @internal
|
|
645
676
|
*/
|
|
646
|
-
addBuilderNode(method) {
|
|
677
|
+
addBuilderNode(method, shouldPush = true) {
|
|
647
678
|
let builderViewTree = method.getViewTree();
|
|
648
679
|
if (!builderViewTree || !builderViewTree.getRoot()) {
|
|
649
680
|
logger.error(`ViewTree->addBuilderNode ${method.getSignature().toString()} build viewtree fail.`);
|
|
@@ -651,12 +682,16 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
651
682
|
let node = ViewTreeNodeImpl.createBuilderNode();
|
|
652
683
|
node.signature = method.getSignature();
|
|
653
684
|
node.classSignature = node.signature;
|
|
654
|
-
|
|
655
|
-
|
|
685
|
+
if (shouldPush) {
|
|
686
|
+
this.push(node);
|
|
687
|
+
this.pop();
|
|
688
|
+
}
|
|
656
689
|
return node;
|
|
657
690
|
}
|
|
658
691
|
let root = builderViewTree.getRoot();
|
|
659
|
-
|
|
692
|
+
if (shouldPush) {
|
|
693
|
+
this.push(root);
|
|
694
|
+
}
|
|
660
695
|
if (method.getDeclaringArkClass() === this.render.getDeclaringArkClass()) {
|
|
661
696
|
for (const [field, nodes] of builderViewTree.getStateValues()) {
|
|
662
697
|
for (const node of nodes) {
|
|
@@ -664,7 +699,9 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
664
699
|
}
|
|
665
700
|
}
|
|
666
701
|
}
|
|
667
|
-
|
|
702
|
+
if (shouldPush) {
|
|
703
|
+
this.pop();
|
|
704
|
+
}
|
|
668
705
|
return root;
|
|
669
706
|
}
|
|
670
707
|
/**
|
|
@@ -917,34 +954,34 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
917
954
|
this.popComponentExpect(EtsConst_1.COMPONENT_IF);
|
|
918
955
|
return this.addSystemComponentNode(EtsConst_1.COMPONENT_IF_BRANCH);
|
|
919
956
|
}
|
|
920
|
-
componentCreateParse(componentName, methodName, stmt, expr) {
|
|
957
|
+
componentCreateParse(local2Node, componentName, methodName, stmt, expr) {
|
|
921
958
|
let parserFn = this.COMPONENT_CREATE_PARSERS.get(`${componentName}.${methodName}`);
|
|
922
959
|
if (parserFn) {
|
|
923
960
|
let node = parserFn(componentName, stmt, expr);
|
|
924
|
-
node === null || node === void 0 ? void 0 : node.addStmt(this, stmt);
|
|
961
|
+
node === null || node === void 0 ? void 0 : node.addStmt(local2Node, this, stmt);
|
|
925
962
|
return node;
|
|
926
963
|
}
|
|
927
964
|
this.popAutomicComponent(componentName);
|
|
928
965
|
let node = this.addSystemComponentNode(componentName);
|
|
929
|
-
node.addStmt(this, stmt);
|
|
966
|
+
node.addStmt(local2Node, this, stmt);
|
|
930
967
|
return node;
|
|
931
968
|
}
|
|
932
|
-
parseStaticInvokeExpr(local2Node, stmt, expr) {
|
|
969
|
+
parseStaticInvokeExpr(local2Node, stmt, expr, shouldPush = true) {
|
|
933
970
|
let methodSignature = expr.getMethodSignature();
|
|
934
971
|
let method = this.findMethod(methodSignature);
|
|
935
972
|
if (method === null || method === void 0 ? void 0 : method.hasBuilderDecorator()) {
|
|
936
|
-
let node = this.addBuilderNode(method);
|
|
973
|
+
let node = this.addBuilderNode(method, shouldPush);
|
|
937
974
|
node.parseStateValues(this, stmt);
|
|
938
975
|
return node;
|
|
939
976
|
}
|
|
940
977
|
let name = methodSignature.getDeclaringClassSignature().getClassName();
|
|
941
978
|
let methodName = methodSignature.getMethodSubSignature().getMethodName();
|
|
942
979
|
if (this.isCreateFunc(methodName)) {
|
|
943
|
-
return this.componentCreateParse(name, methodName, stmt, expr);
|
|
980
|
+
return this.componentCreateParse(local2Node, name, methodName, stmt, expr);
|
|
944
981
|
}
|
|
945
982
|
let currentNode = this.top();
|
|
946
983
|
if (name === (currentNode === null || currentNode === void 0 ? void 0 : currentNode.name)) {
|
|
947
|
-
currentNode.addStmt(this, stmt);
|
|
984
|
+
currentNode.addStmt(local2Node, this, stmt);
|
|
948
985
|
if (methodName === EtsConst_1.COMPONENT_POP_FUNCTION) {
|
|
949
986
|
this.pop();
|
|
950
987
|
}
|
|
@@ -962,7 +999,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
962
999
|
* @param local2Node
|
|
963
1000
|
* @param expr
|
|
964
1001
|
*/
|
|
965
|
-
parseInstanceInvokeExpr(local2Node, stmt, expr) {
|
|
1002
|
+
parseInstanceInvokeExpr(local2Node, stmt, expr, shouldPush = true) {
|
|
966
1003
|
let temp = expr.getBase();
|
|
967
1004
|
if (local2Node.has(temp)) {
|
|
968
1005
|
let component = local2Node.get(temp);
|
|
@@ -976,7 +1013,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
976
1013
|
this.pop();
|
|
977
1014
|
}
|
|
978
1015
|
else {
|
|
979
|
-
component === null || component === void 0 ? void 0 : component.addStmt(this, stmt);
|
|
1016
|
+
component === null || component === void 0 ? void 0 : component.addStmt(local2Node, this, stmt);
|
|
980
1017
|
}
|
|
981
1018
|
return component;
|
|
982
1019
|
}
|
|
@@ -994,11 +1031,11 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
994
1031
|
}
|
|
995
1032
|
let method = this.findMethod(expr.getMethodSignature());
|
|
996
1033
|
if (name === 'this' && (method === null || method === void 0 ? void 0 : method.hasBuilderDecorator())) {
|
|
997
|
-
return this.addBuilderNode(method);
|
|
1034
|
+
return this.addBuilderNode(method, shouldPush);
|
|
998
1035
|
}
|
|
999
1036
|
return undefined;
|
|
1000
1037
|
}
|
|
1001
|
-
parsePtrInvokeExpr(local2Node, stmt, expr) {
|
|
1038
|
+
parsePtrInvokeExpr(local2Node, stmt, expr, shouldPush = true) {
|
|
1002
1039
|
let temp = expr.getFuncPtrLocal();
|
|
1003
1040
|
if (temp instanceof Local_1.Local && local2Node.has(temp)) {
|
|
1004
1041
|
let component = local2Node.get(temp);
|
|
@@ -1012,7 +1049,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1012
1049
|
this.pop();
|
|
1013
1050
|
}
|
|
1014
1051
|
else {
|
|
1015
|
-
component === null || component === void 0 ? void 0 : component.addStmt(this, stmt);
|
|
1052
|
+
component === null || component === void 0 ? void 0 : component.addStmt(local2Node, this, stmt);
|
|
1016
1053
|
}
|
|
1017
1054
|
return component;
|
|
1018
1055
|
}
|
|
@@ -1031,7 +1068,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1031
1068
|
}
|
|
1032
1069
|
let method = this.findMethod(expr.getMethodSignature());
|
|
1033
1070
|
if (name === 'this' && (method === null || method === void 0 ? void 0 : method.hasBuilderDecorator())) {
|
|
1034
|
-
return this.addBuilderNode(method);
|
|
1071
|
+
return this.addBuilderNode(method, shouldPush);
|
|
1035
1072
|
}
|
|
1036
1073
|
}
|
|
1037
1074
|
return undefined;
|
|
@@ -1050,7 +1087,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1050
1087
|
* @param stmt
|
|
1051
1088
|
* @returns
|
|
1052
1089
|
*/
|
|
1053
|
-
parseAssignStmt(local2Node, stmt) {
|
|
1090
|
+
parseAssignStmt(local2Node, stmt, shouldPush = true) {
|
|
1054
1091
|
let left = stmt.getLeftOp();
|
|
1055
1092
|
let right = stmt.getRightOp();
|
|
1056
1093
|
if (!(left instanceof Local_1.Local)) {
|
|
@@ -1058,13 +1095,13 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1058
1095
|
}
|
|
1059
1096
|
let component;
|
|
1060
1097
|
if (right instanceof Expr_1.ArkStaticInvokeExpr) {
|
|
1061
|
-
component = this.parseStaticInvokeExpr(local2Node, stmt, right);
|
|
1098
|
+
component = this.parseStaticInvokeExpr(local2Node, stmt, right, shouldPush);
|
|
1062
1099
|
}
|
|
1063
1100
|
else if (right instanceof Expr_1.ArkInstanceInvokeExpr) {
|
|
1064
|
-
component = this.parseInstanceInvokeExpr(local2Node, stmt, right);
|
|
1101
|
+
component = this.parseInstanceInvokeExpr(local2Node, stmt, right, shouldPush);
|
|
1065
1102
|
}
|
|
1066
1103
|
else if (right instanceof Expr_1.ArkPtrInvokeExpr) {
|
|
1067
|
-
component = this.parsePtrInvokeExpr(local2Node, stmt, right);
|
|
1104
|
+
component = this.parsePtrInvokeExpr(local2Node, stmt, right, shouldPush);
|
|
1068
1105
|
}
|
|
1069
1106
|
if (component) {
|
|
1070
1107
|
local2Node.set(left, component);
|
|
@@ -1093,7 +1130,7 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1093
1130
|
continue;
|
|
1094
1131
|
}
|
|
1095
1132
|
if (stmt instanceof Stmt_1.ArkAssignStmt) {
|
|
1096
|
-
this.parseAssignStmt(local2Node, stmt);
|
|
1133
|
+
this.parseAssignStmt(local2Node, stmt, false);
|
|
1097
1134
|
}
|
|
1098
1135
|
else if (stmt instanceof Stmt_1.ArkInvokeStmt) {
|
|
1099
1136
|
this.parseInvokeStmt(local2Node, stmt);
|
|
@@ -1101,6 +1138,125 @@ class ViewTreeImpl extends TreeNodeStack {
|
|
|
1101
1138
|
}
|
|
1102
1139
|
}
|
|
1103
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Parses the 'tabBar' behavior binding.
|
|
1143
|
+
* Only supports extracting the argument when it is of type CustomBuilder.
|
|
1144
|
+
* Other argument types (e.g. string, Resource, TabBarOptions, SubTabBarStyle, BottomTabBarStyle, ComponentContent) are not handled.
|
|
1145
|
+
*
|
|
1146
|
+
* Supported signatures:
|
|
1147
|
+
* - tabBar(options: string | Resource | CustomBuilder | TabBarOptions)
|
|
1148
|
+
* - tabBar(value: SubTabBarStyle | BottomTabBarStyle) // API 9+
|
|
1149
|
+
* - tabBar(content: ComponentContent | SubTabBarStyle | BottomTabBarStyle | string | Resource | CustomBuilder | TabBarOptions) // API 18+
|
|
1150
|
+
*/
|
|
1151
|
+
tabBarComponentParser(local2Node, stmt, expr) {
|
|
1152
|
+
// Only the first argument (index 0) is analyzed for CustomBuilder type
|
|
1153
|
+
return this.parseBehaviorComponent(local2Node, expr, 0);
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Parses the 'navDestination' behavior binding.
|
|
1157
|
+
* Supports extracting the 'builder' argument when it is of FunctionType.
|
|
1158
|
+
*
|
|
1159
|
+
* navDestination(builder: (name: string, param: unknown) => void)
|
|
1160
|
+
*/
|
|
1161
|
+
navDestinationComponentParser(local2Node, stmt, expr) {
|
|
1162
|
+
const args = expr.getArgs();
|
|
1163
|
+
const arg = args[0];
|
|
1164
|
+
const type = arg.getType();
|
|
1165
|
+
if (!(type instanceof Type_1.FunctionType)) {
|
|
1166
|
+
return undefined;
|
|
1167
|
+
}
|
|
1168
|
+
return this.parseBehaviorComponent(local2Node, expr, 0);
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Parses the 'bindContextMenu' behavior binding for API 8 and API 12.
|
|
1172
|
+
* Only supports extracting the 'content' argument when it is of type CustomBuilder.
|
|
1173
|
+
* Other argument types (e.g. ResponseType, ContextMenuOptions) are not handled.
|
|
1174
|
+
*
|
|
1175
|
+
* Supported signatures:
|
|
1176
|
+
* - bindContextMenu(content: CustomBuilder, responseType: ResponseType, options?: ContextMenuOptions): T // API 8
|
|
1177
|
+
* - bindContextMenu(isShown: boolean, content: CustomBuilder, options?: ContextMenuOptions): T // API 12
|
|
1178
|
+
*/
|
|
1179
|
+
bindContextMenuComponentParser(local2Node, stmt, expr) {
|
|
1180
|
+
const args = expr.getArgs();
|
|
1181
|
+
const firstType = args[0].getType();
|
|
1182
|
+
const argIndex = firstType instanceof Type_1.BooleanType ? 1 : 0;
|
|
1183
|
+
return this.parseBehaviorComponent(local2Node, expr, argIndex);
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Parses the 'bindContentCover' behavior binding.
|
|
1187
|
+
* Only supports extracting the CustomBuilder argument from the second parameter.
|
|
1188
|
+
* Other ContentCoverOptions properties are not handled.
|
|
1189
|
+
*
|
|
1190
|
+
* bindContentCover(isShow: boolean, builder: CustomBuilder, options?: ContentCoverOptions): T
|
|
1191
|
+
*/
|
|
1192
|
+
bindContentCoverComponentParser(local2Node, stmt, expr) {
|
|
1193
|
+
return this.parseBehaviorComponent(local2Node, expr, 1);
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Parses the 'bindPopup' behavior binding.
|
|
1197
|
+
* Only supports extracting the 'builder' field from CustomPopupOptions (custom popup content).
|
|
1198
|
+
* Other PopupOptions properties are not supported yet.
|
|
1199
|
+
*
|
|
1200
|
+
* bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): T
|
|
1201
|
+
*/
|
|
1202
|
+
bindPopupComponentParser(local2Node, stmt, expr) {
|
|
1203
|
+
return this.parseBehaviorComponent(local2Node, expr, 1, 'builder');
|
|
1204
|
+
}
|
|
1205
|
+
parseBehaviorComponent(local2Node, expr, argIndex, builderFieldName) {
|
|
1206
|
+
const args = expr.getArgs();
|
|
1207
|
+
const arg = args[argIndex];
|
|
1208
|
+
const local = arg;
|
|
1209
|
+
const type = arg.getType();
|
|
1210
|
+
// Prefer to return existing node
|
|
1211
|
+
if (local2Node.has(local)) {
|
|
1212
|
+
const node = local2Node.get(local);
|
|
1213
|
+
return node;
|
|
1214
|
+
}
|
|
1215
|
+
// Normal ‘Builder’ parsing
|
|
1216
|
+
if (!builderFieldName) {
|
|
1217
|
+
if (type instanceof Type_1.FunctionType) {
|
|
1218
|
+
const method = this.findMethod(type.getMethodSignature());
|
|
1219
|
+
if (method && method.hasBuilderDecorator()) {
|
|
1220
|
+
const builderNode = this.addBuilderNode(method, false);
|
|
1221
|
+
local2Node.set(local, builderNode);
|
|
1222
|
+
return builderNode;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
// Complex builder field parsing (e.g. 'builder' field in ‘bindPopup’)
|
|
1228
|
+
if (type instanceof Type_1.ClassType && builderFieldName) {
|
|
1229
|
+
return this.parseBuilderFieldNode(local, type, builderFieldName, local2Node);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return undefined;
|
|
1233
|
+
}
|
|
1234
|
+
parseBuilderFieldNode(local, type, builderFieldName, local2Node) {
|
|
1235
|
+
const cls = this.findClass(type.getClassSignature());
|
|
1236
|
+
if (!cls) {
|
|
1237
|
+
return undefined;
|
|
1238
|
+
}
|
|
1239
|
+
const field = cls.getFieldWithName(builderFieldName);
|
|
1240
|
+
if (!field) {
|
|
1241
|
+
return undefined;
|
|
1242
|
+
}
|
|
1243
|
+
const map = parseObjectLiteral(cls, this.getDeclaringArkClass().getDeclaringArkFile().getScene());
|
|
1244
|
+
const builderValue = map.get(field);
|
|
1245
|
+
if (!(builderValue instanceof Ref_1.ArkInstanceFieldRef)) {
|
|
1246
|
+
return undefined;
|
|
1247
|
+
}
|
|
1248
|
+
const builder_type = builderValue.getType();
|
|
1249
|
+
if (!(builder_type instanceof Type_1.FunctionType)) {
|
|
1250
|
+
return undefined;
|
|
1251
|
+
}
|
|
1252
|
+
const method = this.findMethod(builder_type.getMethodSignature());
|
|
1253
|
+
if (method && method.hasBuilderDecorator()) {
|
|
1254
|
+
const builderNode = this.addBuilderNode(method, false);
|
|
1255
|
+
local2Node.set(local, builderNode);
|
|
1256
|
+
return builderNode;
|
|
1257
|
+
}
|
|
1258
|
+
return undefined;
|
|
1259
|
+
}
|
|
1104
1260
|
}
|
|
1105
1261
|
exports.ViewTreeImpl = ViewTreeImpl;
|
|
1106
1262
|
function buildViewTree(render) {
|