diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-09-29 15:45:46 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:36 +0200 |
commit | 0781b31fa4e3d22cb6a51882b8d632ea9a16ed6f (patch) | |
tree | d0b89359d2af440640e457f04d6d6a945251a592 /src/dotty/tools/dotc/util/SourcePosition.scala | |
parent | a0026a09d76c09266c368c7a07a0cc2c5994367e (diff) | |
download | dotty-0781b31fa4e3d22cb6a51882b8d632ea9a16ed6f.tar.gz dotty-0781b31fa4e3d22cb6a51882b8d632ea9a16ed6f.tar.bz2 dotty-0781b31fa4e3d22cb6a51882b8d632ea9a16ed6f.zip |
Handle multiline messages in ConsoleReporter
Diffstat (limited to 'src/dotty/tools/dotc/util/SourcePosition.scala')
-rw-r--r-- | src/dotty/tools/dotc/util/SourcePosition.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/util/SourcePosition.scala b/src/dotty/tools/dotc/util/SourcePosition.scala index 68a9b6403..d0f9cb887 100644 --- a/src/dotty/tools/dotc/util/SourcePosition.scala +++ b/src/dotty/tools/dotc/util/SourcePosition.scala @@ -14,6 +14,17 @@ extends interfaces.SourcePosition { def point: Int = pos.point /** The line of the position, starting at 0 */ def line: Int = source.offsetToLine(point) + + /** The lines of the position */ + def lines: List[Int] = + List.range(source.offsetToLine(start), source.offsetToLine(end)) match { + case Nil => line :: Nil + case xs => xs + } + + def lineContent(lineNumber: Int): String = + source.lineContent(source.lineToOffset(lineNumber)) + /** The column of the position, starting at 0 */ def column: Int = source.column(point) |