From be5e704b7f5b542b8de51e5e97452ca0f7d171ab Mon Sep 17 00:00:00 2001 From: phil294 Date: Thu, 27 Jan 2022 13:13:11 +0100 Subject: [PATCH] improve diagnostics location of JSDoc comment errors until now, these were shown at the *start* of the file with the note `The position of this error could not be mapped back to CoffeeScript, sorry. Here's the failing JavaScript context: ...` I now moved the location to the next available follow up code line where there is any source map info available which is much more helpful ref #5 --- server/src/services/transpileService.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/src/services/transpileService.ts b/server/src/services/transpileService.ts index 3896093f..df8fd8a0 100644 --- a/server/src/services/transpileService.ts +++ b/server/src/services/transpileService.ts @@ -274,10 +274,22 @@ const transpile_service: ITranspileService = { [0] if(!mapped) mapped = columns?.find(Boolean) - if(!mapped) - result = undefined - else + if(!mapped) { + let line_i = js_position.line + 1 + while(line_i < source_map.length) { + const any_next_column = source_map[line_i]?.columns?.find(Boolean) + if(any_next_column) { + mapped = any_next_column + break + } + line_i++ + } + } + + if(mapped) result = Position.create(mapped.sourceLine, mapped.sourceColumn) + else + result = undefined // logger.logDebug(`mapped JS => CS: ${js_position.line}:${js_position.character} => ${result?.line}:${result?.character}`) return result },