From d30edd58eff792a9719faa58c4c57c2f7a1a18b6 Mon Sep 17 00:00:00 2001 From: VictorS67 Date: Tue, 8 Jul 2025 19:58:30 +0800 Subject: [PATCH] revert repeat special fix Signed-off-by: VictorS67 Change-Id: I52dea3bfacfeef3aef2a1b2651034c7315fc1bef --- .../builder-lambda-translators/factory.ts | 20 +++---------------- .../builder-lambda-translators/utils.ts | 18 ----------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts index 4aede6309..55997c0c3 100644 --- a/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts @@ -43,7 +43,6 @@ import { builderLambdaType, BuilderLambdaSecondLastArgInfo, buildSecondLastArgInfo, - checkIsSpecialComponentAttributeFromType, } from './utils'; import { isDecoratorIntrinsicAnnotation } from '../property-translators/utils'; import { factory as PropertyFactory } from '../property-translators/factory'; @@ -178,26 +177,13 @@ export class factory { static createStyleArgInBuilderLambda( lambdaBody: arkts.Expression | undefined, typeNode: arkts.TypeNode | undefined, - moduleName: string, - typeArgument?: arkts.TypeNode + moduleName: string ): arkts.UndefinedLiteral | arkts.ArrowFunctionExpression { if (!lambdaBody) { return arkts.factory.createUndefinedLiteral(); } collectComponentAttributeImport(typeNode, moduleName); - let safeType: arkts.TypeNode | undefined; - if (checkIsSpecialComponentAttributeFromType(typeNode, typeArgument)) { - safeType = arkts.factory.updateTypeReference( - typeNode, - arkts.factory.updateTypeReferencePart( - typeNode.part!, - typeNode.part!.name!, - arkts.factory.createTSTypeParameterInstantiation([typeArgument!.clone()]) - ) - ); - } else { - safeType = isSafeType(typeNode) ? typeNode : undefined; - } + const safeType: arkts.TypeNode | undefined = isSafeType(typeNode) ? typeNode : undefined; const styleLambdaParam: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_ARROW_PARAM_NAME, safeType), @@ -393,7 +379,7 @@ export class factory { const { isFunctionCall, params, returnType, moduleName } = declInfo; const type: arkts.Identifier | undefined = builderLambdaType(leaf); const args: (arkts.AstNode | undefined)[] = [ - this.createStyleArgInBuilderLambda(lambdaBody, returnType, moduleName, leaf.typeArguments?.at(0)), + this.createStyleArgInBuilderLambda(lambdaBody, returnType, moduleName), ]; const secondLastArgInfo = buildSecondLastArgInfo(type, isFunctionCall); const isTrailingCall = leaf.isTrailingCall; diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts index f4975507f..ab738bc3d 100644 --- a/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts @@ -360,24 +360,6 @@ export function callIsGoodForBuilderLambda(leaf: arkts.CallExpression): boolean return arkts.isIdentifier(node) || arkts.isMemberExpression(node); } -// quick-fix: make `Repeat` component as special return type check. -// This is a temporary solution -export function checkIsSpecialComponentAttributeFromType( - typeNode: arkts.TypeNode | undefined, - typeArgument?: arkts.TypeNode -): typeNode is arkts.ETSTypeReference { - if (!typeNode || !typeArgument) { - return false; - } - if (!arkts.isETSTypeReference(typeNode) || !typeNode.part || !typeNode.part.name) { - return false; - } - if (!arkts.isIdentifier(typeNode.part.name)) { - return false; - } - return typeNode.part.name.name === 'RepeatAttribute'; -} - export function isSafeType(type: arkts.TypeNode | undefined): boolean { if (!type) { return false; -- Gitee