From 56339cb7fd6635975f3289b448b3ff2be696f006 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Wed, 16 Mar 2022 12:13:51 +0800 Subject: [PATCH] fixed 58dc961 from https://gitee.com/houhaoyu/developtools_ace-ets2bundle/pulls/378 houhaoyu@huawei.com fix not real file throw error Signed-off-by: houhaoyu Change-Id: Icc017cd1bf7a992d01d1bcf941c00607f868912b --- compiler/src/process_component_build.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 947ac6e29..d3730a39e 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -175,10 +175,13 @@ function validateEtsComponentNode(node: ts.CallExpression | ts.EtsComponentExpre } } +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 { - if (supplement.isAcceleratePreview) { + if (supplement.isAcceleratePreview && ts.isSourceFile(node)) { newsupplement = supplement; + sourceNode = node; } if (node.statements.length) { node.statements.forEach((item, index, array) => { @@ -289,8 +292,12 @@ function processInnerComponent(node: ts.ExpressionStatement, index: number, arr: const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); newStatements.push(res.newNode); if (projectConfig.isPreview && !NO_DEBUG_LINE_COMPONENT.has(name)) { - const posOfNode: ts.LineAndCharacter = - transformLog.sourceFile.getLineAndCharacterOfPosition(getRealNodePos(node)); + let posOfNode: ts.LineAndCharacter; + if (!newsupplement.isAcceleratePreview) { + posOfNode = transformLog.sourceFile.getLineAndCharacterOfPosition(getRealNodePos(node)); + } else { + posOfNode = sourceNode.getLineAndCharacterOfPosition(getRealNodePos(node)); + } const projectPath: string = projectConfig.projectPath; let curFileName: string = transformLog.sourceFile.fileName.replace(/\.ts$/, ''); let line: number = 1; -- Gitee