Signed-off-by: puyajun <puyajun@huawei.com>
This commit is contained in:
puyajun
2022-04-06 09:50:15 +08:00
parent 9e5c767d2e
commit 2b6600bdfb
4 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -236,7 +236,7 @@ export class ResultStates {
if (this.mErrorCount > 0) {
resultInfo += `ERROR:${this.mErrorCount}`;
result = 'FAIL ';
if (!/ets_loader_ark$/.test(path.resolve(__dirname, ".."))) {
if (!/ets_loader_ark$/.test(path.resolve(__dirname, '..'))) {
process.exitCode = 1;
}
} else {
+10 -10
View File
@@ -203,7 +203,7 @@ function validateEtsComponentNode(node: ts.CallExpression | ts.EtsComponentExpre
}
}
let sourceNode: ts.SourceFile;
let sourceNode: ts.SourceFile;
export function processComponentChild(node: ts.Block | ts.SourceFile, newStatements: ts.Statement[], log: LogInfo[],
supplement: supplementType = {isAcceleratePreview: false, line: 0, column: 0, fileName: ''}): void {
@@ -212,21 +212,20 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme
const compilerOptions = ts.readConfigFile(
path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions;
Object.assign(compilerOptions, {
"sourceMap": false,
'sourceMap': false
});
sourceNode = ts.createSourceFile('', node.getText(), ts.ScriptTarget.Latest, true, ts.ScriptKind.ETS, compilerOptions);
}
if (node.statements.length) {
node.statements.forEach((item, index, array) => {
node.statements.forEach((item) => {
if (ts.isExpressionStatement(item)) {
const name: string = getName(item);
switch (getComponentType(item, log, name)) {
case ComponentType.innerComponent:
processInnerComponent(item, index, Array.from(node.statements),
newStatements, log, name);
processInnerComponent(item, newStatements, log);
break;
case ComponentType.customComponent:
if (!newsupplement.isAcceleratePreview){
if (!newsupplement.isAcceleratePreview) {
if (item.expression && ts.isEtsComponentExpression(item.expression) && item.expression.body) {
if (processExpressionStatementChange(item, item.expression.body, log)) {
item = processExpressionStatementChange(item, item.expression.body, log);
@@ -328,11 +327,12 @@ function parseEtsComponentExpression(node: ts.ExpressionStatement): EtsComponent
return { etsComponentNode: etsComponentNode, hasAttr: hasAttr };
}
function processInnerComponent(node: ts.ExpressionStatement, index: number, arr: ts.Statement[],
newStatements: ts.Statement[], log: LogInfo[], name: string): void {
function processInnerComponent(node: ts.ExpressionStatement, newStatements: ts.Statement[], log: LogInfo[]): void {
const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION);
newStatements.push(res.newNode);
if (projectConfig.isPreview && !NO_DEBUG_LINE_COMPONENT.has(name)) {
const nameResult: NameResult = { name: null };
validateEtsComponentNode(node.expression as ts.EtsComponentExpression, nameResult);
if (projectConfig.isPreview && nameResult.name && !NO_DEBUG_LINE_COMPONENT.has(nameResult.name)) {
let posOfNode: ts.LineAndCharacter;
let curFileName: string;
let line: number = 1;
@@ -353,7 +353,7 @@ function processInnerComponent(node: ts.ExpressionStatement, index: number, arr:
`${path.relative(projectPath, curFileName).replace(/\\+/g, '/')}` +
`(${posOfNode.line + line}:${posOfNode.character + col})`;
const debugNode: ts.ExpressionStatement = ts.factory.createExpressionStatement(
createFunction(ts.factory.createIdentifier(getName(node)),
createFunction(ts.factory.createIdentifier(nameResult.name),
ts.factory.createIdentifier(COMPONENT_DEBUGLINE_FUNCTION),
ts.factory.createNodeArray([ts.factory.createStringLiteral(debugInfo)])));
newStatements.push(debugNode);
@@ -114,7 +114,7 @@ function addParamsType(ctorNode: ts.ConstructorDeclaration, modifyPara: ts.Param
break;
}
newTSPara.push(parameter);
})
});
return newTSPara;
}
+4 -4
View File
@@ -61,8 +61,8 @@ import {
} from './utils';
import { projectConfig } from '../main';
import { collectExtend } from './process_ui_syntax';
import { importModuleCollection } from "./ets_checker";
import { isExtendFunction } from "./process_ui_syntax";
import { importModuleCollection } from './ets_checker';
import { isExtendFunction } from './process_ui_syntax';
export interface ComponentCollection {
entryComponent: string;
@@ -303,7 +303,7 @@ function visitAllNode(node: ts.Node, sourceFileNode: ts.SourceFile, allComponent
CUSTOM_BUILDER_METHOD.add(node.name.getText());
}
if (ts.isFunctionDeclaration(node) && isExtendFunction(node)) {
let componentName: string = isExtendFunction(node);
const componentName: string = isExtendFunction(node);
collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.getText());
}
node.getChildren().forEach((item: ts.Node) => visitAllNode(item, sourceFileNode, allComponentNames, log));
@@ -759,7 +759,7 @@ export function processSystemApi(content: string, isProcessAllowList: boolean =
let moduleType: string = item2 || item5;
let systemKey: string = item3 || item6;
let systemValue: string = item1 || item4;
if (!VALIDATE_MODULE.includes(systemValue)){
if (!VALIDATE_MODULE.includes(systemValue)) {
importModuleCollection.add(systemValue);
}
if (!isProcessAllowList && !isSystemModule) {