Skip to content

Commit

Permalink
workaround Scaladoc range position bug
Browse files Browse the repository at this point in the history
Fixes #734
Ref scala/bug#11865

When `ArrayIndexOutOfBoundsException` is encountered, this will use startLine and startColumn as fallback. This is probably cheaper than trying to figure out the EOL position.
  • Loading branch information
eed3si9n committed Feb 3, 2020
1 parent 2b61287 commit ff5b915
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,24 @@ private object DelegatingReporter {
val endOffset = if (pos.isRange) Some(pos.end) else None
val startLine = if (pos.isRange) Some(lineOf(pos.start)) else None
val startColumn = if (pos.isRange) Some(columnOf(pos.start)) else None
val endLine = if (pos.isRange) Some(lineOf(pos.end)) else None
val endColumn = if (pos.isRange) Some(columnOf(pos.end)) else None
val endLine =
if (pos.isRange)
try {
Some(lineOf(pos.end))
} catch {
// work around for https://github.com/scala/bug/issues/11865 by falling back to start pos
case _: ArrayIndexOutOfBoundsException =>
startLine
} else None
val endColumn =
if (pos.isRange)
try {
Some(columnOf(pos.end))
} catch {
// work around for https://github.com/scala/bug/issues/11865 by falling back to start pos
case _: ArrayIndexOutOfBoundsException =>
startColumn
} else None

new PositionImpl(
Option(sourcePath),
Expand Down

0 comments on commit ff5b915

Please sign in to comment.