mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-25 06:05:39 -04:00
Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I7c001e1741d34f26cb4e1415077d43ed9dcfab27
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<string> = 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<temp.arguments.length; i++) {
|
||||
temp.arguments[i] = traverseStylesAttr(temp.arguments[i]);
|
||||
}
|
||||
}
|
||||
statements.push(ts.factory.createExpressionStatement(
|
||||
createFunction(identifierNode, node, temp.arguments)));
|
||||
@@ -584,6 +590,15 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any,
|
||||
}
|
||||
}
|
||||
|
||||
function traverseStylesAttr(node: ts.Node): ts.Node {
|
||||
if (ts.isStringLiteral(node)) {
|
||||
node = ts.factory.createStringLiteral(node.text);
|
||||
} else if (ts.isNumericLiteral(node)) {
|
||||
node = ts.factory.createNumericLiteral(node.text);
|
||||
}
|
||||
return ts.visitEachChild(node, childNode => traverseStylesAttr(childNode), contextGlobal);
|
||||
}
|
||||
|
||||
function generateObjectFor$$(varExp: ts.Expression): ts.ObjectLiteralExpression {
|
||||
return ts.factory.createObjectLiteralExpression(
|
||||
[
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user