diff --git a/compiler/src/interop/src/process_component_build.ts b/compiler/src/interop/src/process_component_build.ts index 037efb0b8bacb4900450d2a806c195ec7691fe8a..ceb4e3641f1614eb1c00f1ef4dc369b130faf5c7 100644 --- a/compiler/src/interop/src/process_component_build.ts +++ b/compiler/src/interop/src/process_component_build.ts @@ -206,24 +206,30 @@ import { export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { + console.log("wq processComponentBuild"); let newNode: ts.MethodDeclaration; let renderNode: ts.Identifier; if (!partialUpdateConfig.partialUpdateMode) { + console.log("wq processComponentBuild1"); renderNode = ts.factory.createIdentifier(COMPONENT_RENDER_FUNCTION); } else { + console.log("wq processComponentBuild2"); renderNode = ts.factory.createIdentifier(COMPONENT_INITIAL_RENDER_FUNCTION); } if (node.body && node.body.statements && node.body.statements.length && validateRootNode(node, log)) { + console.log("wq processComponentBuild3"); const componentBlock: ts.Block = processComponentBlock(node.body, false, log); newNode = ts.factory.updateMethodDeclaration(node, ts.getModifiers(node), node.asteriskToken, renderNode, node.questionToken, node.typeParameters, node.parameters, node.type, componentBlock); if (partialUpdateConfig.partialUpdateMode && storedFileInfo.hasLocalBuilderInFile) { + console.log("wq processComponentBuild4"); componentBlock.statements.unshift(contextStackPushOrPop(ts.factory.createIdentifier(PUSH), [ts.factory.createThis()])); componentBlock.statements.push(contextStackPushOrPop(ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), [])); } } else { + console.log("wq processComponentBuild5"); newNode = ts.factory.updateMethodDeclaration(node, ts.getModifiers(node), node.asteriskToken, renderNode, node.questionToken, node.typeParameters, node.parameters, node.type, node.body); @@ -275,6 +281,7 @@ export function processComponentBlock(node: ts.Block, isLazy: boolean, log: LogI isGlobalBuilder: boolean = false, builderParamsResult: BuilderParamsResult = null, rootGlobalBuilder: boolean = false, isInRepeatTemplate: boolean = false): ts.Block { const newStatements: ts.Statement[] = []; + console.log("wq processComponentBlock"); processComponentChild(node, newStatements, log, {isAcceleratePreview: false, line: 0, column: 0, fileName: ''}, isBuilder, parent, forEachParameters, isGlobalBuilder, isTransition, builderParamsResult, isInRepeatTemplate); if (isLazy && !partialUpdateConfig.partialUpdateMode) { @@ -515,16 +522,21 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme break; } case ComponentType.arkoalaComponent: { + console.log("wq ComponentType.arkoalaComponent"); const idName: ts.Expression = checkIdInIf(item, savedParent); parent = undefined; if (!newsupplement.isAcceleratePreview) { + console.log("wq ComponentType.arkoalaComponent2"); if (item.expression && ts.isEtsComponentExpression(item.expression) && item.expression.body) { + console.log("wq ComponentType.arkoalaComponent3"); const expressionResult: ts.ExpressionStatement = processExpressionStatementChange(item, item.expression.body, log); if (expressionResult) { + console.log("wq ComponentType.arkoalaComponent4"); item = expressionResult; } } + console.log("wq ComponentType.arkoalaComponent5"); processCustomComponent(item as ts.ExpressionStatement, newStatements, log, name, isBuilder, isGlobalBuilder, idName, builderParamsResult, isInRepeatTemplate, true); } @@ -901,6 +913,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); storedFileInfo.lazyForEachInfo.isDependItem = false; + console.log("wq processNormalComponent"); processComponentChild(etsComponentResult.etsComponentNode.body, innerCompStatements, log, {isAcceleratePreview: false, line: 0, column: 0, fileName: ''}, isBuilder, parent, undefined, isGlobalBuilder, false, builderParamsResult, isInRepeatTemplate); @@ -1210,6 +1223,7 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu bindComponentAttr(node, res.identifierNode, itemRenderInnerStatements, log, true, false, immutableStatements); } storedFileInfo.lazyForEachInfo.isDependItem = false; + console.log("wq processItemComponent"); processComponentChild(etsComponentResult.etsComponentNode.body, deepItemRenderInnerStatements, log, {isAcceleratePreview: false, line: 0, column: 0, fileName: ''}, false, parent, undefined, isGlobalBuilder, false, builderParamsResult, isInRepeatTemplate); @@ -1511,6 +1525,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. } if (tabContentBody && tabContentBody.statements.length) { const newTabContentChildren: ts.Statement[] = []; + console.log("wq processTabAndNav"); processComponentChild(tabContentBody, newTabContentChildren, log, {isAcceleratePreview: false, line: 0, column: 0, fileName: ''}, false, parent, undefined, isGlobalBuilder, false, builderParamsResult, isInRepeatTemplate); const navDestinationCallback: (ts.ArrowFunction | ts.NewExpression | ts.ObjectLiteralExpression)[] = @@ -3383,6 +3398,7 @@ function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], name: st } if (isEtsComponent(node)) { if (componentCollection.arkoalaComponents.has(name)) { + console.log("wq getComponentType1"); return ComponentType.arkoalaComponent; } else if (componentCollection.customComponents.has(name)) { isCustomComponentAttributes(node, log); @@ -3391,6 +3407,7 @@ function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], name: st return ComponentType.innerComponent; } } else if (!isPartMethod(node) && componentCollection.arkoalaComponents.has(name)) { + console.log("wq getComponentType2"); return ComponentType.arkoalaComponent; } else if (!isPartMethod(node) && componentCollection.customComponents.has(name)) { isCustomComponentAttributes(node, log); diff --git a/compiler/src/interop/src/process_component_class.ts b/compiler/src/interop/src/process_component_class.ts index 6591124a8cd34bc668c9e62b033e81b96a019dc0..0474e337c5959e7740c02ba70935fcb795a40cd4 100644 --- a/compiler/src/interop/src/process_component_class.ts +++ b/compiler/src/interop/src/process_component_class.ts @@ -196,6 +196,7 @@ export type FreezeParamType = { function processMembers(members: ts.NodeArray, parentComponentName: ts.Identifier, context: ts.TransformationContext, decoratorNode: readonly ts.Decorator[], log: LogInfo[], program: ts.Program, hasPreview: boolean): ts.ClassElement[] { + console.log("wq processMembers"); const buildCount: BuildCount = { count: 0 }; let ctorNode: any = getInitConstructor(members, parentComponentName); const newMembers: ts.ClassElement[] = []; @@ -211,53 +212,68 @@ function processMembers(members: ts.NodeArray, parentComponentN parentComponentName.getText() + INTERFACE_NAME_SUFFIX, undefined, undefined, []); members.forEach((item: ts.MethodDeclaration) => { if (hasDecorator(item, COMPONENT_STYLES_DECORATOR)) { + console.log("wq processMembers"); methodDecoratorCollect(item); } }); members.forEach((item: ts.ClassElement) => { let updateItem: ts.ClassElement; if (ts.isPropertyDeclaration(item)) { + console.log("wq processMembers1"); if (isStaticProperty(item)) { + console.log("wq processMembers2"); newMembers.push(item); validateDecorators(item, log); } else { + console.log("wq processMembers3"); addPropertyMember(item, newMembers, program, parentComponentName.getText(), log); const result: UpdateResult = processMemberVariableDecorators(parentComponentName, item, ctorNode, watchMap, checkController, log, program, context, hasPreview, interfaceNode); if (result.isItemUpdate()) { + console.log("wq processMembers4"); updateItem = result.getProperity(); } else { + console.log("wq processMembers5"); updateItem = item; } if (result.getVariableGet()) { + console.log("wq processMembers6"); newMembers.push(result.getVariableGet()); } if (result.getVariableSet()) { + console.log("wq processMembers7"); newMembers.push(result.getVariableSet()); } if (result.isCtorUpdate()) { + console.log("wq processMembers8"); ctorNode = result.getCtor(); } if (result.getUpdateParams()) { + console.log("wq processMembers9"); updateParamsStatements.push(result.getUpdateParams()); } if (result.getStateVarsParams()) { + console.log("wq processMembers10"); stateVarsStatements.push(result.getStateVarsParams()); } if (result.isDeleteParams()) { + console.log("wq processMembers11"); deleteParamsStatements.push(item); } if (result.getControllerSet()) { + console.log("wq processMembers12"); newMembers.push(result.getControllerSet()); } processPropertyUnchanged(result, purgeVariableDepStatements); } } if (ts.isMethodDeclaration(item) && item.name) { + console.log("wq processMembers13"); updateItem = processComponentMethod(item, context, log, buildCount); } if (updateItem) { + console.log("wq processMembers14"); newMembers.push(updateItem); } }); @@ -265,12 +281,14 @@ function processMembers(members: ts.NodeArray, parentComponentN validateBuildMethodCount(buildCount, parentComponentName, log); validateHasControllerAndControllerCount(parentComponentName, checkController, log); if (storedFileInfo.getCurrentArkTsFile().recycleComponents.has(parentComponentName.getText())) { + console.log("wq processMembers15"); newMembers.unshift(addDeleteParamsFunc(deleteParamsStatements, true)); } newMembers.unshift(addDeleteParamsFunc(deleteParamsStatements)); addIntoNewMembers(newMembers, parentComponentName, updateParamsStatements, purgeVariableDepStatements, rerenderStatements, stateVarsStatements); if (partialUpdateConfig.partialUpdateMode) { + console.log("wq processMembers16"); const creezeParam: FreezeParamType = { componentFreezeParam: undefined }; @@ -279,8 +297,11 @@ function processMembers(members: ts.NodeArray, parentComponentN isFreezeComponent ? decoratorComponentParam(creezeParam) : [], true); } newMembers.unshift(addConstructor(ctorNode, watchMap, parentComponentName)); + console.log("wq processMembers entryComponent is %{public}s",componentCollection.entryComponent); + console.log("wq processMembers parentComponentName is %{public}s",parentComponentName.escapedText.toString()); if (componentCollection.entryComponent === parentComponentName.escapedText.toString() && partialUpdateConfig.partialUpdateMode && projectConfig.minAPIVersion > 10) { + console.log("wq processMembers17"); newMembers.push(getEntryNameFunction(componentCollection.entryComponent)); } log.push(...Array.from(PropMapManager.logInfoMap.values()).flat()); @@ -559,6 +580,7 @@ export interface builderConditionType { } export function processComponentMethod(node: ts.MethodDeclaration, context: ts.TransformationContext, log: LogInfo[], buildCount: BuildCount): ts.MethodDeclaration { + console.log("wq processComponentMethod"); let updateItem: ts.MethodDeclaration = node; const name: string = node.name.getText(); const customBuilder: ts.Decorator[] = []; @@ -567,16 +589,20 @@ export function processComponentMethod(node: ts.MethodDeclaration, context: ts.T isLocalBuilder: false }; if (builderParamObjectCollection.get(componentCollection.currentClassName)) { + console.log("wq processComponentMethod1"); storedFileInfo.builderLikeCollection = new Set([...builderParamObjectCollection.get(componentCollection.currentClassName), ...CUSTOM_BUILDER_METHOD]); } else { + console.log("wq processComponentMethod2"); storedFileInfo.builderLikeCollection = CUSTOM_BUILDER_METHOD; } if (name === COMPONENT_BUILD_FUNCTION) { + console.log("wq processComponentMethod3"); storedFileInfo.processBuilder = false; storedFileInfo.processGlobalBuilder = false; buildCount.count = buildCount.count + 1; if (node.parameters.length) { + console.log("wq processComponentMethod4"); log.push({ type: LogType.ERROR, message: `The 'build' method can not have arguments.`, @@ -587,14 +613,18 @@ export function processComponentMethod(node: ts.MethodDeclaration, context: ts.T const buildNode: ts.MethodDeclaration = processComponentBuild(node, log); updateItem = processBuildMember(buildNode, context, log); } else if (node.body && ts.isBlock(node.body)) { + console.log("wq processComponentMethod4"); if (name === COMPONENT_TRANSITION_FUNCTION) { + console.log("wq processComponentMethod6"); updateItem = ts.factory.updateMethodDeclaration(node, ts.getModifiers(node), node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, processComponentBlock(node.body, false, log, true)); } else if (isBuilderOrLocalBuilder(node, builderCondition, customBuilder)) { + console.log("wq processComponentMethod7"); storedFileInfo.processBuilder = true; storedFileInfo.processGlobalBuilder = false; if (builderCondition.isLocalBuilder) { + console.log("wq processComponentMethod8"); storedFileInfo.processLocalBuilder = true; } CUSTOM_BUILDER_METHOD.add(name); @@ -602,15 +632,18 @@ export function processComponentMethod(node: ts.MethodDeclaration, context: ts.T builderTypeParameter.params = getPossibleBuilderTypeParameter(node.parameters); const parameters: ts.NodeArray = ts.factory.createNodeArray(Array.from(node.parameters)); if (!builderCondition.isLocalBuilder) { + console.log("wq processComponentMethod9"); parameters.push(createParentParameter()); } if (projectConfig.optLazyForEach) { + console.log("wq processComponentMethod10"); parameters.push(initializeMYIDS()); } const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined; const componentBlock: ts.Block = processComponentBlock(node.body, false, log, false, true); if (partialUpdateConfig.partialUpdateMode && builderCondition.isLocalBuilder && node.body.statements.length) { + console.log("wq processComponentMethod11"); componentBlock.statements.unshift(globalBuilderParamAssignment()); } let builderNode: ts.MethodDeclaration | ts.PropertyDeclaration = ts.factory.updateMethodDeclaration(node, @@ -620,20 +653,25 @@ export function processComponentMethod(node: ts.MethodDeclaration, context: ts.T builderTypeParameter.params = []; updateItem = processBuildMember(builderNode, context, log, true); if (builderCondition.isLocalBuilder) { + console.log("wq processComponentMethod12"); checkDecoratorMethod(node, modifiers, log); updateItem = localBuilderNode(node, updateItem.body); } storedFileInfo.processBuilder = false; storedFileInfo.processLocalBuilder = false; } else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { + console.log("wq processComponentMethod13"); if (node.parameters && node.parameters.length === 0) { + console.log("wq processComponentMethod"); if (ts.isBlock(node.body) && node.body.statements && node.body.statements.length) { + console.log("wq processComponentMethod14"); INNER_STYLE_FUNCTION.set(name, node.body); STYLES_ATTRIBUTE.add(name); BUILDIN_STYLE_NAMES.add(name); decoratorParamSet.add(STYLES); } } else { + console.log("wq processComponentMethod15"); log.push({ type: LogType.ERROR, message: `'@Styles' decorated functions and methods cannot have arguments.`, diff --git a/compiler/src/interop/src/process_component_member.ts b/compiler/src/interop/src/process_component_member.ts index c41bcda12ea02ef0337d0263763147fab0f2ca04..cc3cc4c48592510b9277dd8de4686c1d9b00c1a4 100644 --- a/compiler/src/interop/src/process_component_member.ts +++ b/compiler/src/interop/src/process_component_member.ts @@ -124,6 +124,7 @@ import { isAllowedTypeForBasic, isFunctionType } from './process_custom_component'; +import processStructComponentV2 from './process_struct_componentV2'; export type ControllerType = { hasController: boolean; unassignedControllerSet: Set; @@ -926,36 +927,66 @@ export function createViewCreate(node: ts.NewExpression | ts.Identifier): ts.Cal export function createCustomComponentNewExpression(node: ts.CallExpression, name: string, isBuilder: boolean = false, isGlobalBuilder: boolean = false, isCutomDialog: boolean = false): ts.NewExpression { + console.log("wq createCustomComponentNewExpression node.arguments.length1 is %{public}d",node.arguments.length); const newNode: ts.NewExpression = ts.factory.createNewExpression(node.expression, node.typeArguments, node.arguments.length ? node.arguments : []); return addCustomComponentId(newNode, node, name, isBuilder, isGlobalBuilder, isCutomDialog); } + +// v1: +// wq addCustomComponentId2 +// wq addCustomComponentId2 +// wq addCustomComponentId5 +// wq addCustomComponentId6 +// wq addCustomComponentId7 +// wq addCustomComponentId9 +// wq addCustomComponentId11 node.arguments.length1 is %{public}d 6 + +// v2: +// wq addCustomComponentId2 +// wq addCustomComponentId11 node.arguments.length1 is %{public}d 0 + function addCustomComponentId(node: ts.NewExpression, oldNode: ts.CallExpression, componentName: string, isBuilder: boolean = false, isGlobalBuilder: boolean = false, - isCutomDialog: boolean = false): ts.NewExpression { + isCutomDialog: boolean = false): ts.NewExpression { + // const isV2Component = processStructComponentV2.getOrCreateStructInfo(componentNam + // e).isComponentV2 ; + console.log("wq addCustomComponentId"); const posOfNode = transformLog.sourceFile.getLineAndCharacterOfPosition(getRealNodePos(node)); const line: number = posOfNode.line + 1; const col: number = posOfNode.character + 1; +// if (isV2Component && !componentCollection.customComponents.has(componentName)) { +// componentCollection.customComponents.add(componentName); +// console.log(`wq addCustomComponentId: V2组件 ${componentName} 已补充到 componentCollection.customComponents`); +// } for (const item of componentCollection.customComponents) { + console.log("wq addCustomComponentId2"); componentInfo.componentNames.add(item); } componentInfo.componentNames.forEach((name: string) => { let argumentsArray: ts.Expression[]; if (node.arguments && node.arguments.length) { + console.log("wq addCustomComponentId3"); argumentsArray = Array.from(node.arguments); if (partialUpdateConfig.partialUpdateMode && node.arguments.length === 1) { + console.log("wq addCustomComponentId4"); manageLocalStorageComponents(oldNode, argumentsArray); } } + console.log("wq componentName componentName is %{public}s and name is %{public}s",componentName,name); if (componentName === name) { + console.log("wq addCustomComponentId5"); if (!argumentsArray) { + console.log("wq addCustomComponentId6"); argumentsArray = [ts.factory.createObjectLiteralExpression([], true)]; if (partialUpdateConfig.partialUpdateMode) { + console.log("wq addCustomComponentId7"); argumentsArray.push(ts.factory.createIdentifier(COMPONENT_IF_UNDEFINED)); } } if (!partialUpdateConfig.partialUpdateMode) { + console.log("wq addCustomComponentId8"); ++componentInfo.id; argumentsArray.unshift(isBuilder ? ts.factory.createBinaryExpression( ts.factory.createStringLiteral(path.basename(transformLog.sourceFile.fileName, EXTNAME_ETS) + '_'), @@ -963,6 +994,7 @@ function addCustomComponentId(node: ts.NewExpression, oldNode: ts.CallExpression ts.factory.createStringLiteral(componentInfo.id.toString()), isBuilder ? parentConditionalExpression() : ts.factory.createThis()); } else { + console.log("wq addCustomComponentId9"); argumentsArray.unshift((isGlobalBuilder || storedFileInfo.processLocalBuilder) ? parentConditionalExpression() : ts.factory.createThis()); argumentsArray.push(isCutomDialog ? ts.factory.createPrefixUnaryExpression( ts.SyntaxKind.MinusToken, @@ -972,10 +1004,12 @@ function addCustomComponentId(node: ts.NewExpression, oldNode: ts.CallExpression node = ts.factory.updateNewExpression(node, node.expression, node.typeArguments, argumentsArray); } else if (argumentsArray) { + console.log("wq addCustomComponentId10"); node = ts.factory.updateNewExpression(node, node.expression, node.typeArguments, argumentsArray); } }); + console.log("wq addCustomComponentId11 node.arguments.length1 is %{public}d",node.arguments.length); return node; } diff --git a/compiler/src/interop/src/process_custom_component.ts b/compiler/src/interop/src/process_custom_component.ts index 71d9aa2b7088dc33be6b2f88370c8ff1bacb4640..d72b86fa6d5a804b6798ce9feb538683efc0d63c 100644 --- a/compiler/src/interop/src/process_custom_component.ts +++ b/compiler/src/interop/src/process_custom_component.ts @@ -140,6 +140,7 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen log: LogInfo[], name: string, isBuilder: boolean = false, isGlobalBuilder: boolean = false, idName: ts.Expression = undefined, builderParamsResult: BuilderParamsResult = null, isInRepeatTemplate: boolean = false, isArkoala: boolean = false): void { + console.log("wq processCustomComponent"); decoractorMap = new Map( [[COMPONENT_STATE_DECORATOR, stateCollection], [COMPONENT_LINK_DECORATOR, linkCollection], @@ -149,6 +150,7 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen [COMPONENT_OBJECT_LINK_DECORATOR, objectLinkCollection]]); const componentNode: ts.CallExpression = getCustomComponentNode(node); if (componentNode) { + console.log("wq processCustomComponent 2"); const parentComponentType: ParentType = componentCollection.currentClassName ? getParentComponentType(componentCollection.currentClassName) : getParentComponentType(''); const isRecycleComponent: boolean = isRecycle(name); @@ -163,10 +165,12 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen let argumentsArray: ts.PropertyAssignment[]; const componentAttrInfo: ComponentAttrInfo = { reuseId: null, hasIdAttr: false, attrCount: 0, reuse: '' }; if (isHasChild(componentNode)) { + console.log("wq processCustomComponent3"); // @ts-ignore argumentsArray = componentNode.arguments[0].properties.slice(); argumentsArray.forEach((item: ts.PropertyAssignment, index: number) => { if (isToChange(item, name)) { + console.log("wq processCustomComponent4"); ischangeNode = true; const propertyAssignmentNode: ts.PropertyAssignment = ts.factory.updatePropertyAssignment( item, item.name, changeNodeFromCallToArrow(item.initializer as ts.CallExpression)); @@ -174,6 +178,7 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen } }); if (ischangeNode) { + console.log("wq processCustomComponent5"); const newNode: ts.ExpressionStatement = ts.factory.updateExpressionStatement(node, ts.factory.createNewExpression(componentNode.expression, componentNode.typeArguments, [ts.factory.createObjectLiteralExpression(argumentsArray, true)])); @@ -183,11 +188,14 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen } let judgeIdStart: number; if (partialUpdateConfig.partialUpdateMode && idName) { + console.log("wq processCustomComponent6"); judgeIdStart = newStatements.length; } let needCommon: boolean = false; if (hasChainCall) { + console.log("wq processCustomComponent7"); if (partialUpdateConfig.partialUpdateMode) { + console.log("wq processCustomComponent8"); const commomComponentNode: ts.Statement[] = [ts.factory.createExpressionStatement( createFunction(ts.factory.createIdentifier(COMPONENT_COMMON), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))]; @@ -196,14 +204,17 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen log, true, false, immutableStatements, false, componentAttrInfo, isReuseComponentInV2); needCommon = commomComponentNode.length > 1 || immutableStatements.length > 0; if (componentAttrInfo.hasIdAttr && componentAttrInfo.attrCount === 1) { + console.log("wq processCustomComponent9"); commomComponentNode[0] = createCommonIdAttrNode(); } if (needCommon) { + console.log("wq processCustomComponent10"); newStatements.push(createComponentCreationStatement(componentAttributes(COMPONENT_COMMON), commomComponentNode, COMPONENT_COMMON, isGlobalBuilder, false, undefined, immutableStatements, builderParamsResult, isRecycleComponent)); } } else { + console.log("wq processCustomComponent11"); newStatements.push(ts.factory.createExpressionStatement( createFunction(ts.factory.createIdentifier(COMPONENT_COMMON), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))); @@ -211,19 +222,24 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen } } if (isRecycleComponent && partialUpdateConfig.partialUpdateMode) { + console.log("wq processCustomComponent12"); newStatements.push(createRecycleComponent(isGlobalBuilder)); } + console.log("wq processCustomComponent newNode length is %{public}d",customComponentNewExpression.arguments.length); addCustomComponent(node, newStatements, customComponentNewExpression, log, name, componentNode, isBuilder, isGlobalBuilder, isRecycleComponent, componentAttrInfo, builderParamsResult, isReuseComponentInV2, isArkoala); if (hasChainCall && (!partialUpdateConfig.partialUpdateMode || needCommon)) { + console.log("wq processCustomComponent13"); newStatements.push(ts.factory.createExpressionStatement( createFunction(ts.factory.createIdentifier(COMPONENT_COMMON), ts.factory.createIdentifier(COMPONENT_POP_FUNCTION), null))); } if (isRecycleComponent && partialUpdateConfig.partialUpdateMode) { + console.log("wq processCustomComponent14"); newStatements.push(componentAttributes(COMPONENT_RECYCLE)); } if (partialUpdateConfig.partialUpdateMode && idName) { + console.log("wq processCustomComponent15"); newStatements.splice(judgeIdStart, newStatements.length - judgeIdStart, ifRetakeId(newStatements.slice(judgeIdStart), idName)); } @@ -320,7 +336,9 @@ function addCustomComponent(node: ts.ExpressionStatement, newStatements: ts.Stat isBuilder: boolean, isGlobalBuilder: boolean, isRecycleComponent: boolean, componentAttrInfo: ComponentAttrInfo, builderParamsResult: BuilderParamsResult, isReuseComponentInV2: boolean, isArkoala: boolean = false): void { + console.log("wq addCustomComponent1"); if (ts.isNewExpression(newNode)) { + console.log("wq addCustomComponent2"); const propertyArray: ts.ObjectLiteralElementLike[] = []; validateCustomComponentPrams(componentNode, name, propertyArray, log, isBuilder); addCustomComponentStatements(node, newStatements, newNode, name, propertyArray, componentNode, @@ -334,12 +352,15 @@ function addCustomComponentStatements(node: ts.ExpressionStatement, newStatement isRecycleComponent: boolean, componentAttrInfo: ComponentAttrInfo, builderParamsResult: BuilderParamsResult, log: LogInfo[], isReuseComponentInV2: boolean, isArkoala: boolean = false): void { + console.log("wq addCustomComponentStatements1"); if (!partialUpdateConfig.partialUpdateMode) { + console.log("wq addCustomComponentStatements2"); const id: string = componentInfo.id.toString(); newStatements.push(createFindChildById(id, name, isBuilder), createCustomComponentIfStatement(id, ts.factory.updateExpressionStatement(node, createViewCreate(newNode)), ts.factory.createObjectLiteralExpression(props, true), name)); } else { + console.log("wq addCustomComponentStatements3"); newStatements.push(createCustomComponent(newNode, name, componentNode, isGlobalBuilder, isBuilder, isRecycleComponent, componentAttrInfo, builderParamsResult, log, isReuseComponentInV2, isArkoala)); } @@ -583,10 +604,13 @@ function createCustomComponent(newNode: ts.NewExpression, name: string, componen isGlobalBuilder: boolean, isBuilder: boolean, isRecycleComponent: boolean, componentAttrInfo: ComponentAttrInfo, builderParamsResult: BuilderParamsResult, log: LogInfo[], isReuseComponentInV2:boolean, isArkoala = false): ts.Block { + console.log("wq createCustomComponent1"); let componentParameter: ts.ObjectLiteralExpression; if (componentNode.arguments && componentNode.arguments.length) { + console.log("wq createCustomComponent2"); componentParameter = ts.factory.createObjectLiteralExpression(createChildElmtId(componentNode, name, log), true); } else { + console.log("wq createCustomComponent3"); componentParameter = ts.factory.createObjectLiteralExpression([], false); } const arrowArgArr: ts.ParameterDeclaration[] = [ @@ -603,18 +627,21 @@ function createCustomComponent(newNode: ts.NewExpression, name: string, componen isBuilder, isRecycleComponent, componentAttrInfo, log, isArkoala) ]; if (isRecycleComponent) { + console.log("wq createCustomComponent4"); arrowArgArr.push(ts.factory.createParameterDeclaration( undefined, undefined, ts.factory.createIdentifier(RECYCLE_NODE), undefined, undefined, ts.factory.createNull() )); } else if (partialUpdateConfig.optimizeComponent && isGlobalBuilder && builderParamsResult && builderParamsResult.firstParam) { + console.log("wq createCustomComponent5"); const paramName: ts.Identifier = builderParamsResult.firstParam.name as ts.Identifier; arrowArgArr.push(ts.factory.createParameterDeclaration(undefined, undefined, paramName, undefined, undefined, ts.factory.createIdentifier(`__${paramName.escapedText.toString()}__`) )); } if (isRecycleComponent || !partialUpdateConfig.optimizeComponent) { + console.log("wq createCustomComponent6"); arrowBolck.unshift(createViewStackProcessorStatement(STARTGETACCESSRECORDINGFOR, ELMTID)); arrowBolck.push(createViewStackProcessorStatement(STOPGETACCESSRECORDING)); } @@ -624,9 +651,11 @@ function createCustomComponent(newNode: ts.NewExpression, name: string, componen ts.factory.createBlock(arrowBolck, true)) ]; if (isRecycleComponent) { + console.log("wq createCustomComponent7"); componentAttrInfo.reuseId ? observeArgArr.unshift(componentAttrInfo.reuseId) : observeArgArr.unshift(ts.factory.createStringLiteral(name)); } else if (partialUpdateConfig.optimizeComponent) { + console.log("wq createCustomComponent8"); observeArgArr.push(componentPop(name)); } const reuseOrCreateArgArr: ts.ObjectLiteralExpression[] = [ts.factory.createObjectLiteralExpression( @@ -799,7 +828,9 @@ function splitComponentParams(componentNode: ts.CallExpression, isBuilder: boole function createIfCustomComponent(newNode: ts.NewExpression, componentNode: ts.CallExpression, componentParameter: ts.ObjectLiteralExpression, name: string, isGlobalBuilder: boolean, isBuilder: boolean, isRecycleComponent: boolean, componentAttrInfo: ComponentAttrInfo, log: LogInfo[], isArkoala: boolean = false): ts.IfStatement { + console.log("wq createIfCustomComponent1"); if (isArkoala) { + console.log("wq createIfCustomComponent2"); return ts.factory.createIfStatement( ts.factory.createIdentifier(ISINITIALRENDER), ts.factory.createBlock( @@ -1112,23 +1143,30 @@ function validateCustomComponentPrams(node: ts.CallExpression, name: string, } function getCustomComponentNode(node: ts.ExpressionStatement): ts.CallExpression { + console.log("wq getCustomComponentNode"); let temp: any = node.expression; let child: any = null; let componentNode: any = null; while (temp) { + console.log("wq getCustomComponentNode1"); if (ts.isIdentifier(temp)) { + console.log("wq getCustomComponentNode2"); child = temp; break; } temp = temp.expression; } if (child) { + console.log("wq getCustomComponentNode3"); let parent = child.parent; while (parent) { + console.log("wq getCustomComponentNode4"); if (ts.isExpressionStatement(parent)) { + console.log("wq getCustomComponentNode5"); break; } if (ts.isCallExpression(parent) || ts.isEtsComponentExpression(parent)) { + console.log("wq getCustomComponentNode6"); componentNode = parent; break; } diff --git a/compiler/src/interop/src/process_import.ts b/compiler/src/interop/src/process_import.ts index 8ca3073c3a7d8118f3354f16524e75efa63cb733..5a57d5379501317218103c69d6805d802adf6c0f 100644 --- a/compiler/src/interop/src/process_import.ts +++ b/compiler/src/interop/src/process_import.ts @@ -193,6 +193,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP addDependencies(node, defaultNameFromParent, asNameFromParent, isDETS, structDecorator); isExportEntry(node, log, entryCollection, exportCollection, defaultCollection, fileResolvePath, sourceFile); if (asExportCollection.has(node.name.getText())) { + console.log("wq visitAllNode"); componentCollection.customComponents.add(asExportCollection.get(node.name.getText())); if (isDETS) { storedFileInfo.getCurrentArkTsFile().compFromDETS.add(asExportCollection.get(node.name.getText())); @@ -209,6 +210,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP if (!defaultNameFromParent && hasCollection(node.name)) { addDefaultExport(node, isDETS, structDecorator); } else if (defaultNameFromParent && asNameFromParent.has(defaultNameFromParent)) { + console.log("wq visitAllNode1"); componentCollection.customComponents.add(asNameFromParent.get(defaultNameFromParent)); if (isDETS) { storedFileInfo.getCurrentArkTsFile().compFromDETS.add(asNameFromParent.get(defaultNameFromParent)); @@ -219,6 +221,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP } } if (defaultCollection.has(node.name.getText())) { + console.log("wq visitAllNode2"); componentCollection.customComponents.add(CUSTOM_COMPONENT_DEFAULT); if (isDETS) { storedFileInfo.getCurrentArkTsFile().compFromDETS.add(CUSTOM_COMPONENT_DEFAULT); @@ -237,6 +240,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP if (ts.isExportAssignment(node) && node.expression && ts.isIdentifier(node.expression) && hasCollection(node.expression)) { if (defaultNameFromParent) { + console.log("wq visitAllNode3"); const propertiesName: string = node.expression.escapedText.toString(); setDependencies(defaultNameFromParent, undefined, linkCollection.get(propertiesName), propertyCollection.get(propertiesName), propCollection.get(propertiesName), @@ -273,6 +277,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP if (asNameFromParent.has(asExportName)) { asExportName = asNameFromParent.get(asExportName); } + console.log("wq visitAllNode4"); setDependencies(asExportName, undefined, linkCollection.get(asExportPropertyName), propertyCollection.get(asExportPropertyName), propCollection.get(asExportPropertyName), @@ -395,6 +400,7 @@ function addDependencies(node: ts.StructDeclaration, defaultNameFromParent: stri if (defaultNameFromParent && modifiers && modifiers.length >= MODIFIER_LENGTH && modifiers[0] && modifiers[1] && modifiers[0].kind === ts.SyntaxKind.ExportKeyword && modifiers[1].kind === ts.SyntaxKind.DefaultKeyword) { + console.log("wq addDependencies"); setDependencies(defaultNameFromParent, undefined, ComponentSet.links, ComponentSet.properties, ComponentSet.props, ComponentSet.builderParams, ComponentSet.states, ComponentSet.regulars, ComponentSet.storageProps, ComponentSet.storageLinks, ComponentSet.provides, @@ -402,6 +408,7 @@ function addDependencies(node: ts.StructDeclaration, defaultNameFromParent: stri ComponentSet.localStorageProp, ComponentSet.builderParamData, ComponentSet.propData, isDETS, structDecorator); } else if (asNameFromParent.has(componentName)) { + console.log("wq addDependencies1"); setDependencies(asNameFromParent.get(componentName), undefined, ComponentSet.links, ComponentSet.properties, ComponentSet.props, ComponentSet.builderParams, ComponentSet.states, ComponentSet.regulars, ComponentSet.storageProps, ComponentSet.storageLinks, ComponentSet.provides, @@ -409,6 +416,7 @@ function addDependencies(node: ts.StructDeclaration, defaultNameFromParent: stri ComponentSet.localStorageProp, ComponentSet.builderParamData, ComponentSet.propData, isDETS, structDecorator); } else { + console.log("wq addDependencies2"); setDependencies(componentName, undefined, ComponentSet.links, ComponentSet.properties, ComponentSet.props, ComponentSet.builderParams, ComponentSet.states, ComponentSet.regulars, ComponentSet.storageProps, ComponentSet.storageLinks, ComponentSet.provides, @@ -428,6 +436,7 @@ function addDefaultExport(node: ts.StructDeclaration | ts.ExportAssignment, isDE } else { return; } + console.log("wq addDefaultExport"); setDependencies(CUSTOM_COMPONENT_DEFAULT, undefined, linkCollection.has(CUSTOM_COMPONENT_DEFAULT) ? new Set([...linkCollection.get(CUSTOM_COMPONENT_DEFAULT), ...linkCollection.get(name)]) : @@ -523,8 +532,10 @@ function setDependencies(component: string, asComponentName: string, linkArray: storedFileInfo.overallBuilderParamCollection.set(component, builderParamArray); } builderParamObjectCollection.set(component, builderParamArray); + console.log("wq setDependencies"); componentCollection.customComponents.add(component); if (isDETS) { + console.log("wq setDependencies isDETS"); storedFileInfo.getCurrentArkTsFile().compFromDETS.add(component); } if (structDecorator.hasRecycle) { @@ -767,6 +778,7 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string // import xxx from 'xxx' if (node.importClause && node.importClause.name && ts.isIdentifier(node.importClause.name)) { + console.log("wq processImportModule"); getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.name, pageInfo, share); } @@ -776,6 +788,7 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string node.importClause.namedBindings.elements) { node.importClause.namedBindings.elements.forEach((importSpecifier: ts.ImportSpecifier) => { if (ts.isImportSpecifier(importSpecifier) && importSpecifier.name && ts.isIdentifier(importSpecifier.name)) { + console.log("wq processImportModule2"); getDefinedNode(importSymbol, realSymbol, originNode, importSpecifier.name, pageInfo, share); } }); @@ -785,12 +798,14 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string if (node.importClause && node.importClause.namedBindings && ts.isNamespaceImport(node.importClause.namedBindings) && node.importClause.namedBindings.name && ts.isIdentifier(node.importClause.namedBindings.name)) { + console.log("wq processImportModule3"); storedFileInfo.isAsPageImport = true; getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.namedBindings.name, pageInfo, share); } } function getFileVersion(originNode: ts.Node): string | undefined { + console.log("wq getFileVersion"); const fileName = originNode.getSourceFile().fileName; const languageVersionversion = FileManager.getInstance().getLanguageVersionByFilePath(fileName); return languageVersionversion?.languageVersion; @@ -820,6 +835,7 @@ function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNo } } const isArkoala = getFileVersion(originNode) === ARKTS_1_2; + console.log("wq isArkoala is %{public}d",isArkoala); processImportNode(originNode, usedNode, false, null, pageInfo, share, isArkoala); } } @@ -837,6 +853,7 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex } } } + console.log("wq getIntegrationNodeInfo"); processImportNode(originNode, usedNode, true, usedSymbol[0], pageInfo, share); } } @@ -881,6 +898,7 @@ function processImportNode(originNode: ts.Node, usedNode: ts.Identifier, importI let needCollection: boolean = true; const originFile: string = originNode.getSourceFile() ? originNode.getSourceFile().fileName : undefined; if (ts.isStructDeclaration(originNode) && ts.isIdentifier(originNode.name)) { + console.log("wq processImportNode"); parseComponentInImportNode(originNode, name, asComponentName, structDecorator, originFile, isArkoala); } else if (isObservedClass(originNode)) { observedClassCollection.add(name); @@ -915,6 +933,7 @@ function getRealPath(filePath: string): string { function setComponentCollectionInfo(name: string, componentSet: IComponentSet, isDETS: boolean, structDecorator: structDecoratorResult, asComponentName: string): void { + console.log("wq setComponentCollectionInfo"); setDependencies(name, asComponentName, componentSet.links, componentSet.properties, componentSet.props, componentSet.builderParams, componentSet.states, componentSet.regulars, componentSet.storageProps, componentSet.storageLinks, componentSet.provides, @@ -946,33 +965,54 @@ function setComponentCollectionInfo(name: string, componentSet: IComponentSet, i function parseComponentInImportNode(originNode: ts.StructDeclaration, name: string, asComponentName: string, structDecorator: structDecoratorResult, originFile: string, isArkoala: boolean = false): void { - if (!isArkoala) { - componentCollection.customComponents.add(name); - } else { + console.log("wq parseComponentInImportNode name is %{public}s",name); + componentCollection.customComponents.add(name); + // if (!isArkoala) { + // console.log("wq parseComponentInImportNode1"); + // componentCollection.customComponents.add(name); + // } else { + // console.log("wq parseComponentInImportNode2"); + // const filePath = originNode.getSourceFile().fileName; + // console.log("wq filePath is %{public}s", filePath); + // componentCollection.arkoalaComponents.set(name, filePath); + // //console.log("wq parseComponentInImportNode arkoalaComponents name is %{public}s",componentCollection.arkoalaComponents) + // } + if (isArkoala) { + console.log("wq parseComponentInImportNode1"); const filePath = originNode.getSourceFile().fileName; + console.log("wq filePath is %{public}s", filePath); componentCollection.arkoalaComponents.set(name, filePath); } const structInfo: StructInfo = asComponentName ? processStructComponentV2.getOrCreateStructInfo(asComponentName) : processStructComponentV2.getOrCreateStructInfo(name); if (isComponentV2(originNode)) { + console.log("wq parseComponentInImportNode3"); parseComponentV2InImportNode(originNode, name, originFile, structInfo); + //componentCollection.customComponents.add(name); return; } if (isCustomDialogClass(originNode)) { + console.log("wq parseComponentInImportNode4"); structInfo.isCustomDialog = true; componentCollection.customDialogs.add(name); } if (isCustomComponent(originNode, structDecorator)) { + console.log("wq parseComponentInImportNode5"); structInfo.isComponentV1 = true; let isDETS: boolean = false; const componentSet: IComponentSet = getComponentSet(originNode, false); while (originNode) { + console.log("wq parseComponentInImportNode6"); + if (ts.isSourceFile(originNode) && /\.d\.ets$/.test(originNode.fileName)) { + console.log("wq isCustomComponent isSourceFile"); isDETS = true; } originNode = originNode.parent; } + console.log("wq parseComponentInImportNode7"); + setComponentCollectionInfo(name, componentSet, isDETS, structDecorator, asComponentName); } } @@ -982,6 +1022,7 @@ function parseComponentV2InImportNode(node: ts.StructDeclaration, name: string, structInfo.isComponentV2 = true; const isDETS: boolean = originFile && /\.d\.ets$/.test(originFile); if (isDETS) { + console.log("wq parseComponentV2InImportNode"); storedFileInfo.getCurrentArkTsFile().compFromDETS.add(name); } if (isReusableV2(node)) { diff --git a/compiler/src/interop/src/process_interop_component.ts b/compiler/src/interop/src/process_interop_component.ts index d52a7f3f347e01da8140f07c3f0c90adb8689ed3..3e3ea09d8b21bc64fe19f6f93c38562c2f2431c2 100644 --- a/compiler/src/interop/src/process_interop_component.ts +++ b/compiler/src/interop/src/process_interop_component.ts @@ -16,9 +16,11 @@ import ts from 'typescript'; import { componentCollection } from './validate_ui_syntax'; import { COMPATIBLESTATICCOMPONENT, COMPONENT_POP_FUNCTION, GLOBAL_THIS, PUSH, STATICPOINTER, VIEWSTACKPROCESSOR } from './pre_define'; +import processStructComponentV2 from './process_struct_componentV2'; function generateGetClassStatements(): ts.Statement[] { + console.log("wq generateGetClassStatements"); const statements: ts.Statement[] = []; for (const element of componentCollection.arkoalaComponents) { const byteCodePath = generateBytecodePathFragement(element[0], element[1]); @@ -55,12 +57,14 @@ function generateGetClassStatements(): ts.Statement[] { * @returns const __Options_Child = (globalThis as any).Panda.getClass(...); */ export function insertGetOptionsAtTop(sourceFile: ts.SourceFile): ts.SourceFile { + console.log("wq insertGetOptionsAtTop"); const getClassStatements = generateGetClassStatements(); const newStatements = [...getClassStatements, ...sourceFile.statements]; return ts.factory.updateSourceFile(sourceFile, newStatements); } export function generateBytecodePathFragement(className: string, filePath: string): string { + console.log("wq generateBytecodePathFragement"); const regex = /.*declgenV1\/(.*?)\.d\.ets$/; const match = filePath.match(regex); @@ -81,9 +85,34 @@ export function generateBytecodePathFragement(className: string, filePath: strin * @returns (() => { const result = new Child(); result[key] = value; return result; })() */ export function transformObjectExpression( - objectExpr: ts.ObjectExpression, + objectExpr: ts.ObjectExpression | null |undefined, options: string ): ts.Expression { + if (!objectExpr) { + const emptyNewExpr = ts.factory.createNewExpression( + ts.factory.createIdentifier(options), + undefined, + [] + ); + return ts.factory.createCallExpression( + ts.factory.createParenthesizedExpression( + ts.factory.createArrowFunction( + undefined, + undefined, + [], + undefined, + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + ts.factory.createBlock([ + ts.factory.createReturnStatement(emptyNewExpr) + ], true) + ) + ), + undefined, + [] + ); + } + + console.log("wq transformObjectExpression"); const newExpression = ts.factory.createNewExpression( ts.factory.createIdentifier(options), undefined, @@ -184,8 +213,25 @@ function makeStaticFactory(name: string): ts.arrowFunction { * @returns let staticPointer = compatibleStaticComponent(() => { return new Child(); }); */ export function createStaticComponent(name: string, newNode: ts.NewExpression): ts.VariableStatement { - const argument = newNode.arguments; - const options = argument.length > 2 ? argument[1] : undefined; + console.log("wq createStaticComponent name is %{public}s",name); + const isV2Component = processStructComponentV2.getOrCreateStructInfo(name).isComponentV2; + const argument = newNode.arguments || []; + let options; + if (isV2Component) { + if (argument.length === 0) { + options = ts.factory.createObjectLiteralExpression([], false); + } else if (argument.length === 1) { + const props = argument[0]; + const optionsProp = props.properties?.find( + prop => prop.name?.text === 'options' && prop.initializer?.kind === 186 + ); + options = optionsProp ? optionsProp.initializer : ts.factory.createObjectLiteralExpression([], false); + } else { + options = argument[1]; + } + } else { + options = argument.length >= 2 ? argument[1] : undefined; + } return ts.factory.createVariableStatement( undefined, ts.factory.createVariableDeclarationList( diff --git a/compiler/src/interop/src/process_struct_componentV2.ts b/compiler/src/interop/src/process_struct_componentV2.ts index 17baf35db8be0e6ec7b6a0c2d9a7fd763d20cf49..f3c5d8701e9c8e5118b1737c661886b6bf993303 100644 --- a/compiler/src/interop/src/process_struct_componentV2.ts +++ b/compiler/src/interop/src/process_struct_componentV2.ts @@ -177,6 +177,7 @@ function createReusableV2ReflectFunction(): ts.FunctionDeclaration { function processStructMembersV2(node: ts.StructDeclaration, context: ts.TransformationContext, log: LogInfo[]): ts.ClassElement[] { + console.log("wq processStructMembersV2"); const structName: string = node.name.getText(); const newMembers: ts.ClassElement[] = []; const buildCount: BuildCount = { count: 0 }; diff --git a/compiler/src/interop/src/process_ui_syntax.ts b/compiler/src/interop/src/process_ui_syntax.ts index af7a263a0f1fae6b3839bcc86e265e187929261d..b85d9c9d7ba38e17f7f52ef27ca1d726d7349e77 100644 --- a/compiler/src/interop/src/process_ui_syntax.ts +++ b/compiler/src/interop/src/process_ui_syntax.ts @@ -182,6 +182,7 @@ import { insertGetOptionsAtTop } from './process_interop_component'; export function processUISyntax(program: ts.Program, ut = false, parentEvent?: CompileEvent, filePath: string = '', share: object = null, metaInfo: Object = {}): Function { + console.log("wq processUISyntax"); let entryNodeKey: ts.Expression; let eventProcessUISyntax: CompileEvent = undefined; return (context: ts.TransformationContext) => { @@ -296,6 +297,7 @@ export function processUISyntax(program: ts.Program, ut = false, if (projectConfig.compileMode === 'esmodule' && process.env.compileTool === 'rollup' && ts.isImportDeclaration(node)) { const eventProcessImport = createAndStartEvent(eventProcessUISyntax, 'processImport'); + console.log("wq processAllNodes "); processImportModule(node, pageFile, transformLog.errors, share); stopEvent(eventProcessImport); } else if ((projectConfig.compileMode !== 'esmodule' || process.env.compileTool !== 'rollup') && @@ -304,12 +306,15 @@ export function processUISyntax(program: ts.Program, ut = false, processImport(node, pagesDir, transformLog.errors); } if (ts.isStructDeclaration(node)) { + console.log("wq processAllNodes isStructDeclaration"); // This processing aims to parse InsightIntentDecorator. node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax, transformLog.errors); hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); const eventProcessComponentClass = createAndStartEvent(eventProcessUISyntax, 'processComponentClass'); + console.log("wq isComponentV2 is %{public}d",processStructComponentV2.getOrCreateStructInfo(componentCollection.currentClassName).isComponentV2); + console.log("wq currentClassName is %{public}s",componentCollection.currentClassName); node = processStructComponentV2.getOrCreateStructInfo(componentCollection.currentClassName).isComponentV2 ? processStructComponentV2.processStructComponentV2(node, transformLog.errors, context, StateManagementV2) : processComponentClass(node, context, transformLog.errors, program); diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index c41bcda12ea02ef0337d0263763147fab0f2ca04..a5dacdc05a52154abbbe3b30390f47a1cd48202b 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -938,6 +938,7 @@ function addCustomComponentId(node: ts.NewExpression, oldNode: ts.CallExpression const line: number = posOfNode.line + 1; const col: number = posOfNode.character + 1; for (const item of componentCollection.customComponents) { + console.log("wq 1.1 addCustomComponentId"); componentInfo.componentNames.add(item); } componentInfo.componentNames.forEach((name: string) => { @@ -949,6 +950,7 @@ function addCustomComponentId(node: ts.NewExpression, oldNode: ts.CallExpression } } if (componentName === name) { + console.log("wq 1.1 addCustomComponentId1"); if (!argumentsArray) { argumentsArray = [ts.factory.createObjectLiteralExpression([], true)]; if (partialUpdateConfig.partialUpdateMode) { diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 2eac04c5460ceffcfedfabd30e6ac66231acde02..95486f659dd872fe8beff9881a92674dc0e76d73 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -811,6 +811,7 @@ function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNo return; } } + console.log("wq getDefinedNode"); processImportNode(originNode, usedNode, false, null, pageInfo, share); } } @@ -942,6 +943,7 @@ function parseComponentInImportNode(originNode: ts.StructDeclaration, name: stri processStructComponentV2.getOrCreateStructInfo(asComponentName) : processStructComponentV2.getOrCreateStructInfo(name); if (isComponentV2(originNode)) { + console.log("wq 1.1 parseComponentInImportNode"); parseComponentV2InImportNode(originNode, name, originFile, structInfo); return; } @@ -959,6 +961,7 @@ function parseComponentInImportNode(originNode: ts.StructDeclaration, name: stri } originNode = originNode.parent; } + console.log("wq 1.1 parseComponentInImportNode2"); setComponentCollectionInfo(name, componentSet, isDETS, structDecorator, asComponentName); } }