From 3454475354fb88b995a87078e5805c48c4339660 Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Tue, 12 Jul 2022 19:58:10 +0800 Subject: [PATCH 1/3] wangyongfei6@huawei.com modify errorfile path tip Signed-off-by: yfwang6 Change-Id: I4470f5c63cbffefba390368f7c3c23082fcd3114 --- compiler/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/main.js b/compiler/main.js index aa58d3b..d02025e 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -102,7 +102,8 @@ function loadEntryObj(projectConfig) { if (fs.existsSync(fileName)) { projectConfig.entryObj['./' + sourcePath] = fileName + '?entry'; } else { - throw Error(`\u001b[31m ERROR: page '${fileName}' does not exist. \u001b[39m`).message; + const errorFileName = path.resolve(projectConfig.projectPath, sourcePath + '.ets'); + throw Error(`\u001b[31m ERROR: page '${errorFileName}' does not exist. \u001b[39m`).message; } }); } else { From f606914354fa730fd858ad05ed8e9ddfec0f1dcc Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Fri, 15 Jul 2022 15:03:38 +0800 Subject: [PATCH 2/3] wangyongfei6@huawei.com modify errorfile path tip Signed-off-by: yfwang6 Change-Id: Id443196028c8f32bcd6819296ad7b125b7e4b285 --- compiler/main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index d02025e..443d2b7 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -98,12 +98,11 @@ function loadEntryObj(projectConfig) { const pages = manifest.pages; pages.forEach((element) => { const sourcePath = element.replace(/^\.\/ets\//, ''); - const fileName = projectConfig.projectPath + path.sep + sourcePath + '.ets'; + const fileName = path.resolve(projectConfig.projectPath, sourcePath + '.ets'); if (fs.existsSync(fileName)) { projectConfig.entryObj['./' + sourcePath] = fileName + '?entry'; } else { - const errorFileName = path.resolve(projectConfig.projectPath, sourcePath + '.ets'); - throw Error(`\u001b[31m ERROR: page '${errorFileName}' does not exist. \u001b[39m`).message; + throw Error(`\u001b[31m ERROR: page '${fileName}' does not exist. \u001b[39m`).message; } }); } else { From f6c57c4b6b43f1ab2ccbb45b86731d1a921883ff Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Sat, 16 Jul 2022 20:24:09 +0800 Subject: [PATCH 3/3] houhaoyu@huawei.com Signed-off-by: houhaoyu Change-Id: Id8bf94a5e971c3e3fc69a698182bdc1ed110a750 --- compiler/src/component_map.ts | 3 - compiler/src/process_component_build.ts | 103 ++------------------ compiler/src/process_import.ts | 58 +---------- compiler/src/process_ui_syntax.ts | 65 +++--------- compiler/src/validate_ui_syntax.ts | 41 ++------ compiler/test/pages/BaseComponent.ets | 3 +- compiler/test/pages/DivideComponent.ets | 3 +- compiler/test/ut/import/importExportNest.ts | 30 +----- 8 files changed, 38 insertions(+), 268 deletions(-) diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index cc9dc4a..fe9f600 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -77,9 +77,6 @@ export interface ExtendParamterInterfance { } export const EXTEND_ATTRIBUTE: Map> = new Map(); export const STYLES_ATTRIBUTE: Set = new Set(); -export const BUILDER_MIX_EXTEND_RESPECTIVE: Map> = new Map(); -export const BUILDER_MIX_EXTEND: Set = new Set(); -export const BUILDER_MIX_STYLES: Set = new Set(); export const INTERFACE_NODE_SET: Set = new Set(); diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 79e6a03..c427533 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -74,10 +74,7 @@ import { INNER_STYLE_FUNCTION, GLOBAL_STYLE_FUNCTION, COMMON_ATTRS, - CUSTOM_BUILDER_PROPERTIES, - BUILDER_MIX_EXTEND, - BUILDER_MIX_EXTEND_RESPECTIVE, - BUILDER_MIX_STYLES + CUSTOM_BUILDER_PROPERTIES } from './component_map'; import { componentCollection, @@ -135,17 +132,8 @@ export function processComponentBlock(node: ts.Block, isLazy: boolean, log: LogI function validateRootNode(node: ts.MethodDeclaration, log: LogInfo[]): boolean { let isValid: boolean = false; - const bodyStatements: ts.NodeArray = node.body.statements; - let length: number = bodyStatements.length; - bodyStatements.map(node => { - const nodeName: string = node.expression && node.expression.expression && - node.expression.expression.escapedText || undefined; - if (BUILDER_MIX_STYLES.has(nodeName) || BUILDER_MIX_EXTEND.has(nodeName)) { - length--; - } - }); - if (length === 1) { - const statement: ts.Statement = bodyStatements[0]; + if (node.body.statements.length === 1) { + const statement: ts.Statement = node.body.statements[0]; if (ts.isIfStatement(statement) || validateFirstNode(statement)) { isValid = true; } @@ -156,7 +144,7 @@ function validateRootNode(node: ts.MethodDeclaration, log: LogInfo[]): boolean { log.push({ type: LogType.ERROR, message: `There should have a root container component.`, - pos: bodyStatements.pos + pos: node.body.statements.pos }); } return isValid; @@ -232,17 +220,13 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme sourceNode = ts.createSourceFile('', node.getText(), ts.ScriptTarget.Latest, true, ts.ScriptKind.ETS, compilerOptions); } if (node.statements.length) { - let lastName: string; - let lastExpression: ts.Statement; - node.statements.forEach((item, index) => { + node.statements.forEach((item) => { if (ts.isExpressionStatement(item)) { checkEtsComponent(item, log); const name: string = getName(item); switch (getComponentType(item, log, name)) { case ComponentType.innerComponent: processInnerComponent(item, newStatements, log); - lastName = name; - lastExpression = item; break; case ComponentType.customComponent: if (!newsupplement.isAcceleratePreview) { @@ -254,34 +238,18 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme } } processCustomComponent(item as ts.ExpressionStatement, newStatements, log, name); - lastName = name; - lastExpression = item; } break; case ComponentType.forEachComponent: processForEachComponent(item, newStatements, log); - lastName = name; - lastExpression = item; break; case ComponentType.customBuilderMethod: case ComponentType.builderParamMethod: newStatements.push(item); - lastName = name; - lastExpression = item; - break; - case ComponentType.builderMixExtendMethod: - processMixBuilder(lastName, name, index, lastExpression, log, newStatements, item, - ComponentType.builderMixExtendMethod); - break; - case ComponentType.builderMixStylesMethod: - processMixBuilder(lastName, name, index, lastExpression, log, newStatements, item, - ComponentType.builderMixStylesMethod); break; } } else if (ts.isIfStatement(item)) { processIfStatement(item, newStatements, log); - lastName = 'if'; - lastExpression = undefined; } else if (!ts.isBlock(item)) { log.push({ type: LogType.ERROR, @@ -299,51 +267,6 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme }; } -function processMixBuilder(lastName: string, name: string, index: number, lastExpression: ts.Statement, log: LogInfo[], - newStatements: ts.Statement[], item: ts.Statement, type: ComponentType): void { - let isMixExtend: boolean; - if (type === ComponentType.builderMixExtendMethod) { - isMixExtend = true; - } else { - isMixExtend = false; - } - if (lastName) { - if (index && (isMixExtend ? BUILDER_MIX_EXTEND_RESPECTIVE.get(lastName) && - BUILDER_MIX_EXTEND_RESPECTIVE.get(lastName).has(name) : true) && - (getComponentType(lastExpression as ts.ExpressionStatement, log, lastName) === - ComponentType.innerComponent || (isMixExtend ? undefined : getComponentType( - lastExpression as ts.ExpressionStatement, log, lastName) === ComponentType.customComponent))) { - if (newStatements.length && checkPop(newStatements[newStatements.length - 1])) { - newStatements.splice(newStatements.length - 1, 0, item); - } else { - newStatements.push(item); - } - } else { - log.push({ - type: LogType.ERROR, - message: `@Builder & ${isMixExtend ? '@Extend' : '@Styles'} function '${name}' cannot decorate '${lastName}'`, - pos: item.getStart() - }); - } - } else { - log.push({ - type: LogType.ERROR, - message: `@Builder & ${isMixExtend ? '@Extend' : '@Styles'} function '${name}' should decorate a Component`, - pos: item.getStart() - }); - } -} - -function checkPop(node: ts.Statement): boolean { - if (ts.isExpressionStatement(node) && node.expression && ts.isCallExpression(node.expression) && - node.expression.expression && ts.isPropertyAccessExpression(node.expression.expression) && - node.expression.expression.name && ts.isIdentifier(node.expression.expression.name) && - node.expression.expression.name.escapedText.toString() === COMPONENT_POP_FUNCTION) { - return true; - } - return false; -} - function processExpressionStatementChange(node: ts.ExpressionStatement, nextNode: ts.Block, log: LogInfo[]): ts.ExpressionStatement { let name: string; @@ -1034,12 +957,6 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, statements.push(ts.factory.createExpressionStatement( createFunction(identifierNode, node, argumentsArr))); lastStatement.kind = true; - } else if (BUILDER_MIX_EXTEND.has(propName) || BUILDER_MIX_STYLES.has(propName)) { - log.push({ - type: LogType.ERROR, - message: `'${propName}' is a function, not attribute.`, - pos: node.getStart() - }); } else { if (isStylesAttr) { if (!COMMON_ATTRS.has(propName)) { @@ -1321,9 +1238,7 @@ enum ComponentType { customComponent, forEachComponent, customBuilderMethod, - builderParamMethod, - builderMixExtendMethod, - builderMixStylesMethod + builderParamMethod } function isEtsComponent(node: ts.ExpressionStatement): boolean { @@ -1352,10 +1267,6 @@ function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], return ComponentType.forEachComponent; } else if (CUSTOM_BUILDER_METHOD.has(name)) { return ComponentType.customBuilderMethod; - } else if (BUILDER_MIX_EXTEND.has(name)) { - return ComponentType.builderMixExtendMethod; - } else if (BUILDER_MIX_STYLES.has(name)) { - return ComponentType.builderMixStylesMethod; } else if (builderParamObjectCollection.get(componentCollection.currentClassName) && builderParamObjectCollection.get(componentCollection.currentClassName).has(name)) { return ComponentType.builderParamMethod; @@ -1398,4 +1309,4 @@ function checkEtsComponent(node: ts.ExpressionStatement, log: LogInfo[]): void { log ); } -} \ No newline at end of file +} diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index d251a29..0361f27 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -27,9 +27,7 @@ import { CUSTOM_COMPONENT_DEFAULT, CUSTOM_DECORATOR_NAME, COMPONENT_DECORATOR_ENTRY, - COMPONENT_BUILDER_DECORATOR, - COMPONENT_EXTEND_DECORATOR, - COMPONENT_STYLES_DECORATOR + COMPONENT_BUILDER_DECORATOR } from './pre_define'; import { propertyCollection, @@ -50,13 +48,7 @@ import { import { hasDecorator, LogInfo, LogType, repeatLog } from './utils'; import { projectConfig } from '../main'; import { isOhmUrl, resolveSourceFile } from './resolve_ohm_url'; -import { - BUILDER_MIX_STYLES, - BUILDER_MIX_EXTEND, - BUILDER_MIX_EXTEND_RESPECTIVE, - CUSTOM_BUILDER_METHOD -} from './component_map'; -import { isExtendFunction } from './process_ui_syntax'; +import { CUSTOM_BUILDER_METHOD } from './component_map'; const IMPORT_FILE_ASTCACHE: Map = new Map(); @@ -170,16 +162,8 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP } } if (ts.isFunctionDeclaration(node) && hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) { - if (hasDecorator(node, COMPONENT_EXTEND_DECORATOR)) { - collectSpecialFunctionNode(node, asNameFromParent, defaultNameFromParent, defaultCollection, - asExportCollection, BUILDER_MIX_EXTEND, BUILDER_MIX_EXTEND_RESPECTIVE); - } else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { - collectSpecialFunctionNode(node, asNameFromParent, defaultNameFromParent, defaultCollection, - asExportCollection, BUILDER_MIX_STYLES); - } else { - collectSpecialFunctionNode(node, asNameFromParent, defaultNameFromParent, defaultCollection, - asExportCollection, CUSTOM_BUILDER_METHOD); - } + collectSpecialFunctionNode(node, asNameFromParent, defaultNameFromParent, defaultCollection, + asExportCollection, CUSTOM_BUILDER_METHOD); } if (ts.isExportAssignment(node) && node.expression && ts.isIdentifier(node.expression) && hasCollection(node.expression)) { @@ -276,52 +260,20 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP function collectSpecialFunctionNode(node: ts.FunctionDeclaration, asNameFromParent: Map, defaultNameFromParent: string, defaultCollection: Set, asExportCollection: Map, - collection: Set, specialCollection?: Map>): void { + collection: Set): void { const name: string = node.name.getText(); let componentName: string; if (asNameFromParent.has(name)) { collection.add(asNameFromParent.get(name)); - if (specialCollection) { - componentName = isExtendFunction(node); - if (specialCollection.get(componentName)) { - specialCollection.get(componentName).add(asNameFromParent.get(name)); - } else { - specialCollection.set(componentName, new Set([asNameFromParent.get(name)])); - } - } } else if (node.modifiers && node.modifiers.length >= 2 && node.modifiers[0] && node.modifiers[0].kind === ts.SyntaxKind.ExportKeyword && node.modifiers[1] && node.modifiers[1].kind === ts.SyntaxKind.DefaultKeyword && defaultNameFromParent && asNameFromParent.has(defaultNameFromParent)) { collection.add(asNameFromParent.get(defaultNameFromParent)); - if (specialCollection) { - componentName = isExtendFunction(node); - if (specialCollection.get(componentName)) { - specialCollection.get(componentName).add(asNameFromParent.get(name)); - } else { - specialCollection.set(componentName, new Set([asNameFromParent.get(name)])); - } - } } else if (defaultCollection.has(name)) { collection.add(CUSTOM_COMPONENT_DEFAULT); - if (specialCollection) { - componentName = isExtendFunction(node); - if (specialCollection.get(componentName)) { - specialCollection.get(componentName).add(CUSTOM_COMPONENT_DEFAULT); - } else { - specialCollection.set(componentName, new Set([CUSTOM_COMPONENT_DEFAULT])); - } - } } else if (asExportCollection.has(name)) { collection.add(asExportCollection.get(name)); - if (specialCollection) { - componentName = isExtendFunction(node); - if (specialCollection.get(componentName)) { - specialCollection.get(componentName).add(asExportCollection.get(name)); - } else { - specialCollection.set(componentName, new Set([asExportCollection.get(name)])); - } - } } } diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 4be191b..d7b43a3 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -134,21 +134,7 @@ export function processUISyntax(program: ts.Program, ut = false): Function { }); INNER_STYLE_FUNCTION.clear(); } else if (ts.isFunctionDeclaration(node)) { - if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { - if (!hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) { - if (node.parameters.length === 0) { - node = undefined; - } else { - transformLog.errors.push({ - type: LogType.ERROR, - message: `@Styles can't have parameters.`, - pos: node.getStart() - }); - } - } else { - node = processStyles(node, transformLog.errors); - } - } else if (hasDecorator(node, COMPONENT_EXTEND_DECORATOR)) { + if (hasDecorator(node, COMPONENT_EXTEND_DECORATOR)) { node = processExtend(node, transformLog.errors); } else if (hasDecorator(node, COMPONENT_BUILDER_DECORATOR) && node.name && node.body && ts.isBlock(node.body)) { @@ -156,6 +142,16 @@ export function processUISyntax(program: ts.Program, ut = false): Function { node = ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, processComponentBlock(node.body, false, transformLog.errors)); + } else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { + if (node.parameters.length === 0) { + node = undefined; + } else { + transformLog.errors.push({ + type: LogType.ERROR, + message: `@Styles can't have parameters.`, + pos: node.getStart() + }); + } } } else if (isResource(node)) { node = processResourceData(node as ts.CallExpression); @@ -425,32 +421,6 @@ function processAnimateTo(node: ts.CallExpression): ts.CallExpression { node.typeArguments, node.arguments); } -function processStyles(node: ts.FunctionDeclaration, log: LogInfo[]): ts.FunctionDeclaration { - const componentName: string = COMPONENT_COMMON; - if (node.body && node.body.statements.length) { - const statementArray: ts.Statement[] = []; - const attrSet: ts.CallExpression = node.body.statements[0].expression; - const changeCompName: ts.ExpressionStatement = ts.factory.createExpressionStatement(processStylesBody(attrSet)); - bindComponentAttr(changeCompName as ts.ExpressionStatement, - ts.factory.createIdentifier(componentName), statementArray, log); - const stylesFunctionName: string = node.name.getText(); - return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken, - ts.factory.createIdentifier(stylesFunctionName), node.typeParameters, - node.parameters, node.type, ts.factory.updateBlock(node.body, statementArray)); - } -} - -function processStylesBody(node: ts.Node): ts.Expression { - switch (node.kind) { - case ts.SyntaxKind.CallExpression: - return ts.factory.createCallExpression(processStylesBody(node.expression), undefined, node.arguments); - case ts.SyntaxKind.PropertyAccessExpression: - return ts.factory.createPropertyAccessExpression(processStylesBody(node.expression), node.name); - case ts.SyntaxKind.Identifier: - return ts.factory.createIdentifier(node.escapedText.toString().replace(INSTANCE, '')); - } -} - function processExtend(node: ts.FunctionDeclaration, log: LogInfo[]): ts.FunctionDeclaration { const componentName: string = isExtendFunction(node); if (componentName && node.body && node.body.statements.length) { @@ -460,16 +430,11 @@ function processExtend(node: ts.FunctionDeclaration, log: LogInfo[]): ts.Functio bindComponentAttr(changeCompName as ts.ExpressionStatement, ts.factory.createIdentifier(componentName), statementArray, log); let extendFunctionName: string; - const prefixCompName: string = '__' + componentName + '__'; - if (!hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) { - if (node.name.getText().startsWith(prefixCompName)) { - extendFunctionName = node.name.getText(); - } else { - extendFunctionName = prefixCompName + node.name.getText(); - collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.escapedText.toString()); - } - } else { + if (node.name.getText().startsWith('__' + componentName + '__')) { extendFunctionName = node.name.getText(); + } else { + extendFunctionName = '__' + componentName + '__' + node.name.getText(); + collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.escapedText.toString()); } return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken, ts.factory.createIdentifier(extendFunctionName), node.typeParameters, diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 4f8556c..41ec9fa 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -61,10 +61,7 @@ import { EXTEND_ATTRIBUTE, GLOBAL_STYLE_FUNCTION, STYLES_ATTRIBUTE, - CUSTOM_BUILDER_METHOD, - BUILDER_MIX_EXTEND, - BUILDER_MIX_EXTEND_RESPECTIVE, - BUILDER_MIX_STYLES + CUSTOM_BUILDER_METHOD } from './component_map'; import { LogType, @@ -338,16 +335,9 @@ function visitAllNode(node: ts.Node, sourceFileNode: ts.SourceFile, allComponent } if ((ts.isMethodDeclaration(node) || ts.isFunctionDeclaration(node)) && hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) { - if (hasDecorator(node, COMPONENT_EXTEND_DECORATOR) && ts.isFunctionDeclaration(node)) { - const componentName: string = isExtendFunction(node); - BUILDER_MIX_EXTEND.add(node.name.getText()); - collectExtend(BUILDER_MIX_EXTEND_RESPECTIVE, componentName, node.name.getText()); - } else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { - BUILDER_MIX_STYLES.add(node.name.getText()); - } else { CUSTOM_BUILDER_METHOD.add(node.name.getText()); - } - } else if (ts.isFunctionDeclaration(node) && isExtendFunction(node)) { + } + if (ts.isFunctionDeclaration(node) && isExtendFunction(node)) { const componentName: string = isExtendFunction(node); collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.getText()); } else if (ts.isFunctionDeclaration(node) && hasDecorator(node, COMPONENT_STYLES_DECORATOR)) { @@ -453,19 +443,10 @@ function hasNonSingleChild(node: ts.EtsComponentExpression, allComponentNames: S return false; } if (BlockNode && BlockNode.statements) { - let length: number = BlockNode.statements.length; + const length: number = BlockNode.statements.length; if (!length) { return false; } - BlockNode.statements.map(node => { - const nodeName: string = ts.isExpressionStatement(node) && - ts.isCallExpression(node.expression) && - ts.isIdentifier(node.expression.expression) ? - node.expression.expression.escapedText.toString() : ''; - if (BUILDER_MIX_STYLES.has(nodeName) || BUILDER_MIX_EXTEND.has(nodeName)) { - length--; - } - }); if (length > 3) { return true; } @@ -597,13 +578,13 @@ function isNonspecificChildBlock(blockNode: ts.Block, specificChildSet: Set export function preprocessNewExtend(content: string, extendCollection?: Set): string { const REG_EXTEND: RegExp = /@Extend\s*\([^\)]+\)\s*function\s+([^\(\s]+)\s*\(/gm; - content.replace(REG_EXTEND, (item, item1) => { + return content.replace(REG_EXTEND, (item, item1) => { if (extendCollection) { extendCollection.add(item1); } return item; }); - const REG_BUILDER_EXTEND: RegExp = /@Builder\s*@Extend\s*\([^\)]+\)\s*function\s+([^\(\s]+)\s*\(/gm; - content.replace(REG_BUILDER_EXTEND, (item, item1) => { - if (extendCollection) { - extendCollection.delete(item1); - } - return item; - }); - return content; } function getPackageInfo(configFile: string): Array { diff --git a/compiler/test/pages/BaseComponent.ets b/compiler/test/pages/BaseComponent.ets index 112a5bc..0dab310 100644 --- a/compiler/test/pages/BaseComponent.ets +++ b/compiler/test/pages/BaseComponent.ets @@ -14,9 +14,8 @@ */ @Builder -@Extend(Text) function textExtend(fontsize: number){ - .fontSize(fontsize) + Text('Builder').fontSize(fontsize) } @Component diff --git a/compiler/test/pages/DivideComponent.ets b/compiler/test/pages/DivideComponent.ets index e55cd61..914d02f 100644 --- a/compiler/test/pages/DivideComponent.ets +++ b/compiler/test/pages/DivideComponent.ets @@ -14,9 +14,8 @@ */ @Builder -@Styles function textStyles(){ - .backgroundColor(Color.Red) + Text('Builder').backgroundColor(Color.Red) } @Component diff --git a/compiler/test/ut/import/importExportNest.ts b/compiler/test/ut/import/importExportNest.ts index f1c5dd6..69b1068 100644 --- a/compiler/test/ut/import/importExportNest.ts +++ b/compiler/test/ut/import/importExportNest.ts @@ -38,10 +38,8 @@ struct ImportTest { Text(this.testText2) tStyles() Button(this.testText3) - globalExtend(Color.Blue) Text(this.testText4) .fontSize(50) - globalStyles() Base({ testStr: $testState1, @@ -55,20 +53,6 @@ struct ImportTest { } } } - -@Builder -@Extend(Button) -function globalExtend(color: Color | string){ - .backgroundColor(color) - .width(100) - .height(30) -} - -@Builder -@Styles -function globalStyles(){ - .backgroundColor('#abcdef') -} ` exports.expectResult = @@ -188,17 +172,15 @@ class ImportTest extends View { Column.create(); Text.create(this.testText1); Text.fontSize(50); + Text.pop(); ImportNestAll_1.tExtend(20); - Text.pop(); Text.create(this.testText2); - ImportNestAll_1.tStyles(); Text.pop(); + ImportNestAll_1.tStyles(); Button.createWithLabel(this.testText3); - globalExtend(Color.Blue); Button.pop(); Text.create(this.testText4); Text.fontSize(50); - globalStyles(); Text.pop(); let earlierCreatedChild_2 = this.findChildById("2"); if (earlierCreatedChild_2 == undefined) { @@ -226,13 +208,5 @@ class ImportTest extends View { Column.pop(); } } -function globalExtend(color) { - Button.backgroundColor(color); - Button.width(100); - Button.height(30); -} -function globalStyles() { - __Common__.backgroundColor('#abcdef'); -} loadDocument(new ImportTest("1", undefined, {})); `