mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-08-27 03:01:19 -04:00
bugFix: fixed component params validate
Signed-off-by: laibo102 <laibo2@huawei.com> Change-Id: I585eb246554766b567eecc39e9f0afeadf952403
This commit is contained in:
@@ -230,8 +230,7 @@ function addPropertyMember(item: ts.ClassElement, newMembers: ts.ClassElement[],
|
||||
}
|
||||
|
||||
function createPropertyDeclaration(propertyItem: ts.PropertyDeclaration, newType: ts.TypeNode | undefined,
|
||||
normalVar: boolean, isLocalStorage: boolean = false, parentComponentName: string = null
|
||||
): ts.PropertyDeclaration {
|
||||
normalVar: boolean, isLocalStorage: boolean = false, parentComponentName: string = null): ts.PropertyDeclaration {
|
||||
if (typeof newType === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -418,27 +417,22 @@ export function createReference(node: ts.PropertyAssignment): ts.PropertyAssignm
|
||||
const linkParentComponent: string[] = getParentNode(node, linkCollection).slice(1);
|
||||
const propertyName: ts.Identifier = node.name as ts.Identifier;
|
||||
let initText: string;
|
||||
if (linkParentComponent && ts.isPropertyAssignment(node) && ts.isIdentifier(propertyName) &&
|
||||
linkParentComponent.includes(propertyName.escapedText.toString())) {
|
||||
const LINK_REG: RegExp = /^\$/g;
|
||||
const initExpression: ts.Expression = node.initializer;
|
||||
if (ts.isIdentifier(initExpression) &&
|
||||
initExpression.escapedText.toString().match(LINK_REG)) {
|
||||
if (linkParentComponent.includes(propertyName.escapedText.toString())) {
|
||||
initText = initExpression.escapedText.toString().replace(LINK_REG, '');
|
||||
}
|
||||
} else if (ts.isPropertyAccessExpression(initExpression) && initExpression.expression &&
|
||||
initExpression.expression.kind === ts.SyntaxKind.ThisKeyword &&
|
||||
ts.isIdentifier(initExpression.name) &&
|
||||
initExpression.name.escapedText.toString().match(LINK_REG)) {
|
||||
if (linkParentComponent.includes(propertyName.escapedText.toString())) {
|
||||
initText = initExpression.name.escapedText.toString().replace(LINK_REG, '');
|
||||
}
|
||||
}
|
||||
if (initText) {
|
||||
node = addDoubleUnderline(node, propertyName, initText);
|
||||
const LINK_REG: RegExp = /^\$/g;
|
||||
const initExpression: ts.Expression = node.initializer;
|
||||
if (ts.isIdentifier(initExpression) &&
|
||||
initExpression.escapedText.toString().match(LINK_REG)) {
|
||||
initText = initExpression.escapedText.toString().replace(LINK_REG, '');
|
||||
} else if (ts.isPropertyAccessExpression(initExpression) && initExpression.expression &&
|
||||
initExpression.expression.kind === ts.SyntaxKind.ThisKeyword &&
|
||||
ts.isIdentifier(initExpression.name) &&
|
||||
initExpression.name.escapedText.toString().match(LINK_REG)) {
|
||||
if (linkParentComponent.includes(propertyName.escapedText.toString())) {
|
||||
initText = initExpression.name.escapedText.toString().replace(LINK_REG, '');
|
||||
}
|
||||
}
|
||||
if (initText) {
|
||||
node = addDoubleUnderline(node, propertyName, initText);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ function isHasChild(node: ts.CallExpression): boolean {
|
||||
function isToChange(item: ts.PropertyAssignment, node: ts.CallExpression): boolean {
|
||||
const builderParamName: Set<string> = builderParamObjectCollection.get(node.expression.getText());
|
||||
if (item.initializer && ts.isCallExpression(item.initializer) && builderParamName &&
|
||||
builderParamName.has(item.name.getText()) &&
|
||||
builderParamName.has(item.name.getText()) &&
|
||||
!/\.(bind|call|apply)/.test(item.initializer.getText())) {
|
||||
return true;
|
||||
}
|
||||
@@ -191,6 +191,10 @@ function isThisProperty(node: ts.ObjectLiteralElementLike, propertySet: Set<stri
|
||||
}
|
||||
|
||||
function isNonThisProperty(node: ts.ObjectLiteralElementLike, propertySet: Set<string>): boolean {
|
||||
if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
|
||||
node.initializer.escapedText && node.initializer.escapedText.includes('$')) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
|
||||
!propertySet.has(node.name.escapedText.toString())) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user