Skip to content

Commit

Permalink
improve diagnostics location of JSDoc comment errors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
phil294 committed Jan 27, 2022
1 parent 28c3d52 commit be5e704
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions server/src/services/transpileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down

0 comments on commit be5e704

Please sign in to comment.