aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/util/SourcePosition.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-01 17:41:48 +0900
committerFelix Mulder <felix.mulder@gmail.com>2017-03-01 19:45:39 +0900
commit07cdb3d9893385eae6d15d83a7f1e32dd7bbf0a1 (patch)
treeb67abfa9d90e70c97c9907c6e66276e461937e8c /compiler/src/dotty/tools/dotc/util/SourcePosition.scala
parentcc263594951cd901c9d4fcc2ed7aa7956c774e64 (diff)
downloaddotty-07cdb3d9893385eae6d15d83a7f1e32dd7bbf0a1.tar.gz
dotty-07cdb3d9893385eae6d15d83a7f1e32dd7bbf0a1.tar.bz2
dotty-07cdb3d9893385eae6d15d83a7f1e32dd7bbf0a1.zip
Message rendering: colorize positional splice, then split
Diffstat (limited to 'compiler/src/dotty/tools/dotc/util/SourcePosition.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/util/SourcePosition.scala8
1 files changed, 5 insertions, 3 deletions
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)