!3369 @Builder param 判断防护

Merge pull request !3369 from Bo Jiang/builder
This commit is contained in:
openharmony_ci 2024-05-23 09:53:53 +00:00 committed by Gitee
commit 3dfef67e76
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 21 additions and 15 deletions

View File

@ -1735,10 +1735,16 @@ function addForEachId(node: ts.ExpressionStatement, isGlobalBuilder: boolean = f
export function parentConditionalExpression(builderInnerComponent: boolean = false): ts.ConditionalExpression {
return ts.factory.createConditionalExpression(
projectConfig.minAPIVersion >= 12 && builderInnerComponent ? ts.factory.createBinaryExpression(
ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
ts.factory.createIdentifier(PUV2_VIEW_BASE)) :
builderInnerComponent ? ts.factory.createBinaryExpression(
ts.factory.createBinaryExpression(
ts.factory.createTypeOfExpression(ts.factory.createIdentifier(PUV2_VIEW_BASE)),
ts.factory.createToken(ts.SyntaxKind.ExclamationEqualsEqualsToken),
ts.factory.createStringLiteral(COMPONENT_IF_UNDEFINED)
),
ts.factory.createToken(ts.SyntaxKind.AmpersandAmpersandToken), ts.factory.createBinaryExpression(
ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
ts.factory.createIdentifier(PUV2_VIEW_BASE))) :
ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARENT),

View File

@ -102,7 +102,7 @@ class Index extends ViewPU {
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new AAA(parent ? parent : this, { AAA: ComA }, undefined, elmtId, () => { }, { page: "@builderOrComponentAsName.ets", line: 10, col: 5 });
let componentCall = new AAA(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, { AAA: ComA }, undefined, elmtId, () => { }, { page: "@builderOrComponentAsName.ets", line: 10, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {

View File

@ -164,7 +164,7 @@ function testIfIdComponent(value, parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => {
if (isInitialRender) {
let componentCall = new TestBuilderChild(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormFirst.ets", line: 37, col: 7 });
let componentCall = new TestBuilderChild(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormFirst.ets", line: 37, col: 7 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};

View File

@ -160,7 +160,7 @@ function testInnerComponent(value, parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => {
if (isInitialRender) {
let componentCall = new TestBuilderChild(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormSecond.ets", line: 40, col: 5 });
let componentCall = new TestBuilderChild(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormSecond.ets", line: 40, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};
@ -179,7 +179,7 @@ function testInnerComponent(value, parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => {
if (isInitialRender) {
let componentCall = new TestBuilderChild(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormSecond.ets", line: 41, col: 5 });
let componentCall = new TestBuilderChild(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormSecond.ets", line: 41, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};

View File

@ -160,7 +160,7 @@ function testInnerComponent(value, parent = null) {
(parent ? parent : this).observeRecycleComponentCreation("TestBuilderReusable", (elmtId, isInitialRender, recycleNode = null) => {
ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
if (isInitialRender) {
let componentCall = recycleNode ? recycleNode : new TestBuilderReusable(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormThird.ets", line: 38, col: 5 });
let componentCall = recycleNode ? recycleNode : new TestBuilderReusable(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormThird.ets", line: 38, col: 5 });
ViewPU.createRecycle(componentCall, recycleNode !== null, "TestBuilderReusable", () => {
if (recycleNode && typeof recycleNode.aboutToReuseInternal === "function") {
recycleNode.aboutToReuseInternal();
@ -195,7 +195,7 @@ function testInnerComponent(value, parent = null) {
(parent ? parent : this).observeRecycleComponentCreation("TestBuilderReusable", (elmtId, isInitialRender, recycleNode = null) => {
ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
if (isInitialRender) {
let componentCall = recycleNode ? recycleNode : new TestBuilderReusable(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormThird.ets", line: 39, col: 5 });
let componentCall = recycleNode ? recycleNode : new TestBuilderReusable(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderTransFormThird.ets", line: 39, col: 5 });
ViewPU.createRecycle(componentCall, recycleNode !== null, "TestBuilderReusable", () => {
if (recycleNode && typeof recycleNode.aboutToReuseInternal === "function") {
recycleNode.aboutToReuseInternal();

View File

@ -75,7 +75,7 @@ function comp($$, parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, $$ = __$$__) => {
if (isInitialRender) {
let componentCall = new Child(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderVisilibity$$.ets", line: 11, col: 5 });
let componentCall = new Child(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderVisilibity$$.ets", line: 11, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};

View File

@ -51,7 +51,7 @@ function myBuilder(parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new child(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithComponent.ets", line: 4, col: 3 });
let componentCall = new child(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithComponent.ets", line: 4, col: 3 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};
@ -87,7 +87,7 @@ class Index extends ViewPU {
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new child(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithComponent.ets", line: 11, col: 5 });
let componentCall = new child(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithComponent.ets", line: 11, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};

View File

@ -61,7 +61,7 @@ function ComB(param, parent = null) {
{
(parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => {
if (isInitialRender) {
let componentCall = new ComA(parent ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithForEach.ets", line: 5, col: 5 });
let componentCall = new ComA(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, {}, undefined, elmtId, () => { }, { page: "@builderWithForEach.ets", line: 5, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};

View File

@ -115,7 +115,7 @@ class TestPage extends ViewPU {
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new TitleComp(parent ? parent : this, { title: this.__value }, undefined, elmtId, () => { }, { page: "@builderWithLinkData.ets", line: 16, col: 5 });
let componentCall = new TitleComp(typeof PUV2ViewBase !== "undefined" && parent instanceof PUV2ViewBase ? parent : this, { title: this.__value }, undefined, elmtId, () => { }, { page: "@builderWithLinkData.ets", line: 16, col: 5 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {