mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-18 16:04:32 -04:00
houhaoyu
fix stateStyles Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I55066b18f7efaa733f91a133bc4a1ab2c6e0b18b
This commit is contained in:
@@ -256,12 +256,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)'\./;
|
||||
/Property\s*'([_a-zA-Z0-9]+)' does not exist on type\s*'([_a-zA-Z0-9]+)'\./;
|
||||
if (this.matchMessage(message, props, 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], extendInfoReg)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -75,7 +75,7 @@ export interface ExtendParamterInterfance {
|
||||
parameterCount: number
|
||||
}
|
||||
export const EXTEND_ATTRIBUTE: Map<string, Set<ExtendParamterInterfance>> = new Map();
|
||||
export const STYLES_ATTRIBUTE: string[] = [];
|
||||
export const STYLES_ATTRIBUTE: Set<string> = new Set();
|
||||
|
||||
export const JS_BIND_COMPONENTS: Set<string> = new Set([
|
||||
...GESTURE_TYPE_NAMES, 'Gesture',
|
||||
|
||||
@@ -184,4 +184,3 @@ export const BUILD_SHARE_PATH: string = '../share';
|
||||
export const THIS: string = 'this';
|
||||
export const STYLES: string = 'Styles';
|
||||
export const VISUAL_STATE: string = 'visualState';
|
||||
export const VIEW_STACK_PROCESSOR: string = 'ViewStackProcessor';
|
||||
|
||||
@@ -46,8 +46,7 @@ import {
|
||||
COMPONENT_DEBUGLINE_FUNCTION,
|
||||
ATTRIBUTE_STATESTYLES,
|
||||
THIS,
|
||||
VISUAL_STATE,
|
||||
VIEW_STACK_PROCESSOR
|
||||
VISUAL_STATE
|
||||
} from './pre_define';
|
||||
import {
|
||||
INNER_COMPONENT_NAMES,
|
||||
@@ -517,9 +516,10 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any,
|
||||
validateStateStyleSyntax(temp, log);
|
||||
}
|
||||
} else if (GLOBAL_STYLE_FUNCTION.has(propName) || INNER_STYLE_FUNCTION.has(propName)) {
|
||||
bindComponentAttr((GLOBAL_STYLE_FUNCTION.get(propName).statements[0] ||
|
||||
INNER_STYLE_FUNCTION.get(propName).statements[0]) as ts.ExpressionStatement,
|
||||
identifierNode, statements, log, false, true);
|
||||
const styleBlock: ts.Block =
|
||||
GLOBAL_STYLE_FUNCTION.get(propName) || INNER_STYLE_FUNCTION.get(propName);
|
||||
bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode,
|
||||
statements, log, false, true);
|
||||
} else {
|
||||
if (isStylesAttr && !COMMON_ATTRS.has(propName)) {
|
||||
validateStateStyleSyntax(temp, log);
|
||||
@@ -537,7 +537,7 @@ function createViewStackProcessor(item: any, endViewStack: boolean) {
|
||||
}
|
||||
return ts.factory.createExpressionStatement(ts.factory.createCallExpression(
|
||||
ts.factory.createPropertyAccessExpression(
|
||||
ts.factory.createIdentifier(VIEW_STACK_PROCESSOR),
|
||||
ts.factory.createIdentifier(GLOBAL_CONTEXT),
|
||||
ts.factory.createIdentifier(VISUAL_STATE)
|
||||
),
|
||||
undefined,
|
||||
|
||||
@@ -159,7 +159,7 @@ function processComponentMethod(node: ts.MethodDeclaration, parentComponentName:
|
||||
} else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) {
|
||||
if (node.parameters && node.parameters.length === 0) {
|
||||
INNER_STYLE_FUNCTION.set(name, node.body);
|
||||
STYLES_ATTRIBUTE.push(name);
|
||||
STYLES_ATTRIBUTE.add(name);
|
||||
BUILDIN_STYLE_NAMES.add(name);
|
||||
decoratorParamSet.add(STYLES);
|
||||
} else {
|
||||
|
||||
@@ -56,8 +56,7 @@ import {
|
||||
EXTEND_ATTRIBUTE,
|
||||
JS_BIND_COMPONENTS,
|
||||
INNER_STYLE_FUNCTION,
|
||||
GLOBAL_STYLE_FUNCTION,
|
||||
STYLES_ATTRIBUTE
|
||||
GLOBAL_STYLE_FUNCTION
|
||||
} from './component_map';
|
||||
import { resources } from '../main';
|
||||
|
||||
@@ -82,7 +81,6 @@ export function processUISyntax(program: ts.Program, ut = false): Function {
|
||||
BUILDIN_STYLE_NAMES.delete(styleName);
|
||||
})
|
||||
GLOBAL_STYLE_FUNCTION.clear();
|
||||
STYLES_ATTRIBUTE.length = 0;
|
||||
return node;
|
||||
} else {
|
||||
return node;
|
||||
|
||||
@@ -183,7 +183,7 @@ function checkComponentDecorator(source: string, filePath: string,
|
||||
}
|
||||
if (ts.isFunctionDeclaration(item) && item.decorators && item.decorators.length === 1 &&
|
||||
item.decorators[0].expression && item.decorators[0].expression.getText() === STYLES) {
|
||||
STYLES_ATTRIBUTE.push(item.name.getText())
|
||||
STYLES_ATTRIBUTE.add(item.name.getText())
|
||||
GLOBAL_STYLE_FUNCTION.set(item.name.getText(), item.body);
|
||||
BUILDIN_STYLE_NAMES.add(item.name.getText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user