From e794d314ae0eb07208e1da45aae7ccc71d6eeb2c Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Sun, 16 Jan 2022 16:39:10 +0800 Subject: [PATCH] houhaoyu@huawe.com Signed-off-by: houhaoyu Change-Id: I7c001e1741d34f26cb4e1415077d43ed9dcfab27 --- compiler/src/compile_info.ts | 7 ++++--- compiler/src/process_component_build.ts | 23 +++++++++++++++++++---- compiler/src/process_ui_syntax.ts | 2 ++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 805cbd928..bf509f0e5 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -43,6 +43,7 @@ import { appComponentCollection } from './process_component_build'; import { projectConfig } from '../main'; import { circularFile } from './utils'; import { MODULE_SHARE_PATH, BUILD_SHARE_PATH } from './pre_define'; +import { COMMON_ATTRS } from './component_map'; configure({ appenders: { 'ETS': {type: 'stderr', layout: {type: 'messagePassThrough'}}}, @@ -256,12 +257,12 @@ export class ResultStates { const componentNameReg: RegExp = /'typeof\s*(\$?[_a-zA-Z0-9]+)' is not callable/; const stateInfoReg: RegExp = /Property\s*'(\$[_a-zA-Z0-9]+)' does not exist on type/; const extendInfoReg: RegExp = - /Property\s*'([_a-zA-Z0-9]+)' does not exist on type\s*'([_a-zA-Z0-9]+)(Attribute|Interface)'\./; - if (this.matchMessage(message, props, propInfoReg) || + /Property\s*'([_a-zA-Z0-9]+)' does not exist on type\s*'([_a-zA-Z0-9]+)(Attribute|Interface)?'\./; + if (this.matchMessage(message, props.concat([...STYLES_ATTRIBUTE]), propInfoReg) || this.matchMessage(message, [...componentCollection.customComponents], componentNameReg) || this.matchMessage(message, props, stateInfoReg) || this.matchMessage(message, EXTEND_ATTRIBUTE, extendInfoReg, true) || - this.matchMessage(message, [...STYLES_ATTRIBUTE], extendInfoReg)) { + this.matchMessage(message, [...STYLES_ATTRIBUTE, ...COMMON_ATTRS], extendInfoReg)) { return false; } return true; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index a2d4acc69..da3beb502 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -77,7 +77,7 @@ import { createFunction } from './utils'; import { projectConfig } from '../main'; -import { transformLog } from './process_ui_syntax'; +import { transformLog, contextGlobal } from './process_ui_syntax'; import { props } from './compile_info'; export const appComponentCollection: Set = new Set(); @@ -526,7 +526,7 @@ function updateArgumentFor$$(argument: any): ts.Expression { function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[], - isStylesAttr): void { + isStylesAttr: boolean): void { const propName: string = node.getText(); if (propName === ATTRIBUTE_ANIMATION) { if (!lastStatement.statement) { @@ -565,6 +565,7 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, GLOBAL_STYLE_FUNCTION.get(propName) || INNER_STYLE_FUNCTION.get(propName); bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, statements, log, false, true); + lastStatement.kind = true; } else if (propName === BIND_POPUP && temp.arguments.length === 2 && temp.arguments[0].getText().match(/^\$\$(.|\n)+/)) { const argumentsArr: ts.Expression[] = []; @@ -575,8 +576,13 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, createFunction(identifierNode, node, argumentsArr))); lastStatement.kind = true; } else { - if (isStylesAttr && !COMMON_ATTRS.has(propName)) { - validateStateStyleSyntax(temp, log); + if (isStylesAttr) { + if (!COMMON_ATTRS.has(propName)) { + validateStateStyleSyntax(temp, log); + } + for (let i=0; i traverseStylesAttr(childNode), contextGlobal); +} + function generateObjectFor$$(varExp: ts.Expression): ts.ObjectLiteralExpression { return ts.factory.createObjectLiteralExpression( [ diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index a4628675c..481074b65 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -61,9 +61,11 @@ import { import { resources } from '../main'; export const transformLog: FileLog = new FileLog(); +export let contextGlobal: ts.TransformationContext; export function processUISyntax(program: ts.Program, ut = false): Function { return (context: ts.TransformationContext) => { + contextGlobal = context; let pagesDir: string; return (node: ts.SourceFile) => { pagesDir = path.resolve(path.dirname(node.fileName)); -- Gitee