diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 947ac6e2929412fe4e46a12e5416f535027d73dc..d3730a39e4501e0fd8623ff31843bdf88b0f588d 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;