Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 30 lines (29 sloc) 0.849 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
package sbt.complete

object ProcessError
{
def apply(command: String, msgs: Seq[String], index: Int): String =
{
val (line, modIndex) = extractLine(command, index)
val point = pointerSpace(command, modIndex)
msgs.mkString("\n") + "\n" + line + "\n" + point + "^"
}
def extractLine(s: String, i: Int): (String, Int) =
{
val notNewline = (c: Char) => c != '\n' && c != '\r'
val left = takeRightWhile( s.substring(0, i) )( notNewline )
val right = s substring i takeWhile notNewline
(left + right, left.length)
}
def takeRightWhile(s: String)(pred: Char => Boolean): String =
{
def loop(i: Int): String =
if(i < 0)
s
else if( pred(s(i)) )
loop(i-1)
else
s.substring(i+1)
loop(s.length - 1)
}
def pointerSpace(s: String, i: Int): String = (s take i) map { case '\t' => '\t'; case _ => ' ' } mkString;
}
Something went wrong with that request. Please try again.