Skip to content

Commit 9e77285

Browse files
committed
Document that lines and columns start at 0.
And adjust for it in DottyBackendInterface
1 parent de1042a commit 9e77285

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
480480

481481
implicit def positionHelper(a: Position): PositionHelper = new PositionHelper {
482482
def isDefined: Boolean = a.exists
483-
def line: Int = sourcePos(a).line
483+
def line: Int = sourcePos(a).line + 1
484484
def finalPosition: Position = a
485485
}
486486

src/dotty/tools/dotc/util/SourcePosition.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ case class SourcePosition(source: SourceFile, pos: Position) {
1010
def exists = pos.exists
1111

1212
def lineContents: String = source.lineContents(point)
13+
14+
/** The line of the position, starting at 0 */
1315
def line: Int = source.offsetToLine(point)
16+
17+
/** The column of the position, starting at 0 */
1418
def column: Int = source.column(point)
1519

1620
override def toString =

0 commit comments

Comments
 (0)