From 07cdb3d9893385eae6d15d83a7f1e32dd7bbf0a1 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 1 Mar 2017 17:41:48 +0900 Subject: Message rendering: colorize positional splice, then split --- compiler/src/dotty/tools/dotc/util/SourcePosition.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/util/SourcePosition.scala') diff --git a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala index aad4995d8..be5c46995 100644 --- a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala +++ b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala @@ -12,9 +12,14 @@ extends interfaces.SourcePosition { def lineContent: String = source.lineContent(point) def point: Int = pos.point + /** The line of the position, starting at 0 */ def line: Int = source.offsetToLine(point) + /** Extracts the lines from the underlying source file as `Array[Char]`*/ + def linesSlice: Array[Char] = + source.content.slice(source.startOfLine(start), source.nextLine(end)) + /** The lines of the position */ def lines: List[Int] = List.range(source.offsetToLine(start), source.offsetToLine(end + 1)) match { @@ -25,9 +30,6 @@ extends interfaces.SourcePosition { def lineOffsets: List[Int] = lines.map(source.lineToOffset(_)) - def lineContent(lineNumber: Int): String = - source.lineContent(source.lineToOffset(lineNumber)) - def beforeAndAfterPoint: (List[Int], List[Int]) = lineOffsets.partition(_ <= point) -- cgit v1.2.3