diff --git a/compiler/package.json b/compiler/package.json index d0e42b6e6..e6f8bba46 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -20,7 +20,7 @@ "fastbuild": "rollup -c rollup.config.js", "run:arkTest": "mocha \"arkTest_build/ark_compiler_ut/**/*.test.js\"", "run:cleanArkTest": "rm -rf arkTest_build", - "arkTest": "./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest", + "arkTest": "npm run generateKitConfigs && ./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest", "coverage": "node_modules/nyc/bin/nyc.js npm run test:coverage", "duplicate": "jscpd", "generateKitConfigs": "node ./build_kitConfigs_file.js ../../../interface/sdk-js/kits ./kit_configs ../../../interface/sdk-js/api ../../../interface/sdk-js/arkts" diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 2a0acd554..8739aa417 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -40,7 +40,7 @@ import { STYLE_ADD_DOUBLE_DOLLAR, $$, PROPERTIES_ADD_DOUBLE_DOLLAR, - $$_BLOCK_INTERFACE, + DOLLAR_BLOCK_INTERFACE, COMPONENT_EXTEND_DECORATOR, COMPONENT_BUILDER_DECORATOR, ESMODULE, @@ -1056,7 +1056,7 @@ function traverseBuild(node: ts.Node, index: number): void { } node = node.expression; if (ts.isEtsComponentExpression(node) && node.body && ts.isBlock(node.body) && - ts.isIdentifier(node.expression) && !$$_BLOCK_INTERFACE.has(node.expression.escapedText.toString())) { + ts.isIdentifier(node.expression) && !DOLLAR_BLOCK_INTERFACE.has(node.expression.escapedText.toString())) { node.body.statements.forEach((item: ts.Statement, indexBlock: number) => { traverseBuild(item, indexBlock); }); @@ -1091,7 +1091,7 @@ function isPropertiesAddDoubleDollar(node: ts.Node): boolean { if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.arguments && node.arguments.length) { return true; } else if (ts.isEtsComponentExpression(node) && node.body && ts.isBlock(node.body) && - ts.isIdentifier(node.expression) && $$_BLOCK_INTERFACE.has(node.expression.escapedText.toString())) { + ts.isIdentifier(node.expression) && DOLLAR_BLOCK_INTERFACE.has(node.expression.escapedText.toString())) { return true; } else { return false; @@ -1115,8 +1115,8 @@ function loopNodeFindDoubleDollar(node: ts.Node, parentComponentName: string): v doubleDollarCollection(param.initializer); } }); - } - if (STYLE_ADD_DOUBLE_DOLLAR.has(node.expression.getText()) && ts.isPropertyAccessExpression(item)) { + } else if (ts.isPropertyAccessExpression(item) && (handleComponentDollarBlock(node as ts.CallExpression, parentComponentName) || + STYLE_ADD_DOUBLE_DOLLAR.has(node.expression.getText()))) { doubleDollarCollection(item); } }); @@ -1125,6 +1125,12 @@ function loopNodeFindDoubleDollar(node: ts.Node, parentComponentName: string): v } } +function handleComponentDollarBlock(node: ts.CallExpression, parentComponentName: string): boolean { + return ts.isCallExpression(node) && ts.isIdentifier(node.expression) && + DOLLAR_BLOCK_INTERFACE.has(parentComponentName) && PROPERTIES_ADD_DOUBLE_DOLLAR.has(parentComponentName) && + PROPERTIES_ADD_DOUBLE_DOLLAR.get(parentComponentName).has(node.expression.escapedText.toString()); +} + function doubleDollarCollection(item: ts.Node): void { if (item.getText().startsWith($$)) { while (item.expression) { diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 3dd7f4394..9ed4b88e7 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -352,9 +352,9 @@ export const GRID_ITEM: string = 'GridItem'; export const LIST_ITEM: string = 'ListItem'; export const UPDATE_FUNC_BY_ELMT_ID: string = 'updateFuncByElmtId'; -export const $$_BLOCK_INTERFACE: Set = new Set([ - REFRESH, DATE_PICKER, TIME_PICKER, RATING, SEAECH, CALENDAR, STEPPER, TABS, MENU_ITEM, - TIME_PICKER, GRID_ITEM, LIST_ITEM]); +export const DOLLAR_BLOCK_INTERFACE: Set = new Set([ + CHECK_BOX, CHECKBOX_GROUP, DATE_PICKER, TIME_PICKER, MENU_ITEM, PANEL, RATING, SIDE_BAR_CONTAINER, STEPPER, SWIPER, TABS, TEXT_PICKER, TOGGLE, SELECT, + REFRESH, CALENDAR, GRID_ITEM, LIST_ITEM, TEXT_TIMER, SEAECH]); export const STYLE_ADD_DOUBLE_DOLLAR: Set = new Set([ BIND_POPUP, $$_VISIBILITY, BIND_CONTENT_COVER, BIND_SHEET]); export const PROPERTIES_ADD_DOUBLE_DOLLAR: Map> = new Map([