From 716bd79fac10070f4ade511c097778288db25930 Mon Sep 17 00:00:00 2001 From: ctw Date: Tue, 22 Feb 2022 15:57:03 +0800 Subject: [PATCH] fix extract text from nodes without real position Signed-off-by: ctw Change-Id: Ibb6736dd2e0e78d6208f0a56fccc55c2509b75fe --- ts2panda/src/debuginfo.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ts2panda/src/debuginfo.ts b/ts2panda/src/debuginfo.ts index 8e3b5c8fed..bc7ffb529d 100644 --- a/ts2panda/src/debuginfo.ts +++ b/ts2panda/src/debuginfo.ts @@ -189,8 +189,11 @@ export class DebugInfo { pos = node.getStart(); } - let loc = file.getLineAndCharacterOfPosition(pos); - let wholeLineText = tempWholeLineText || node.getText(); + let loc = file.getLineAndCharacterOfPosition(pos); + let wholeLineText = tempWholeLineText; + if (node.pos >= 0 && node.end >= 0) { + wholeLineText = wholeLineText || node.getText() + } return { loc: loc, wholeLineText: wholeLineText -- Gitee