@@ -72,15 +72,15 @@ case class SourceFile(file: AbstractFile, content: Array[Char]) {
7272 def positionInUltimateSource (position : SourcePosition ): SourcePosition =
7373 SourcePosition (underlying, position.pos shift start)
7474
75- def isLineBreak (idx : Int ) =
75+ private def isLineBreak (idx : Int ) =
7676 if (idx >= length) false else {
7777 val ch = content(idx)
7878 // don't identify the CR in CR LF as a line break, since LF will do.
7979 if (ch == CR ) (idx + 1 == length) || (content(idx + 1 ) != LF )
8080 else isLineBreakChar(ch)
8181 }
8282
83- def calculateLineIndices (cs : Array [Char ]) = {
83+ private def calculateLineIndices (cs : Array [Char ]) = {
8484 val buf = new ArrayBuffer [Int ]
8585 buf += 0
8686 for (i <- 0 until cs.length) if (isLineBreak(i)) buf += i + 1
@@ -103,25 +103,29 @@ case class SourceFile(file: AbstractFile, content: Array[Char]) {
103103 lastLine
104104 }
105105
106+ /** The index of the first character of the line containing position `offset` */
106107 def startOfLine (offset : Int ): Int = {
107108 require(offset >= 0 )
108109 lineToOffset(offsetToLine(offset))
109110 }
110111
112+ /** The start index of the line following the one containing position `offset` */
111113 def nextLine (offset : Int ): Int =
112114 lineToOffset(offsetToLine(offset) + 1 min lineIndices.length - 1 )
113115
116+ /** The contents of the line containing position `offset` */
114117 def lineContents (offset : Int ): String =
115118 content.slice(startOfLine(offset), nextLine(offset)).mkString
116119
120+ /** The column corresponding to `offset`, starting at 0 */
117121 def column (offset : Int ): Int = {
118122 var idx = startOfLine(offset)
119123 var col = 0
120124 while (idx != offset) {
121- col += (if (content(idx) == '\t ' ) tabInc - col % tabInc else 1 )
125+ col += (if (content(idx) == '\t ' ) ( tabInc - col) % tabInc else 1 )
122126 idx += 1
123127 }
124- col + 1
128+ col
125129 }
126130
127131 override def toString = file.toString
0 commit comments