aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.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/printing/SyntaxHighlighting.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/printing/SyntaxHighlighting.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala19
1 files changed, 17 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala
index 86f34e64d..e20f846ac 100644
--- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala
+++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala
@@ -6,6 +6,7 @@ import parsing.Tokens._
import scala.annotation.switch
import scala.collection.mutable.StringBuilder
import core.Contexts.Context
+import util.Chars.{ LF, FF, CR, SU }
import Highlighting.{Highlight, HighlightBuffer}
/** This object provides functions for syntax highlighting in the REPL */
@@ -26,7 +27,7 @@ object SyntaxHighlighting {
private def valDef(str: String) = ValDefColor + str + NoColor
private def operator(str: String) = TypeColor + str + NoColor
private def annotation(str: String) =
- if (str.trim == "@") str else AnnotationColor + str + NoColor
+ if (str.trim == "@") str else { AnnotationColor + str + NoColor }
private val tripleQs = Console.RED_B + "???" + NoColor
private val keywords: Seq[String] = for {
@@ -152,7 +153,11 @@ object SyntaxHighlighting {
var open = 1
while (open > 0 && remaining.nonEmpty) {
curr = takeChar()
- newBuf += curr
+ if (curr == '@') {
+ appendWhile('@', !typeEnders.contains(_), annotation)
+ newBuf append CommentColor
+ }
+ else newBuf += curr
if (curr == '*' && remaining.nonEmpty) {
curr = takeChar()
@@ -163,6 +168,11 @@ object SyntaxHighlighting {
newBuf += curr
if (curr == '*') open += 1
}
+
+ (curr: @switch) match {
+ case LF | FF | CR | SU => newBuf append CommentColor
+ case _ => ()
+ }
}
prev = curr
newBuf append NoColor
@@ -236,6 +246,11 @@ object SyntaxHighlighting {
newBuf += curr
closing = 0
}
+
+ (curr: @switch) match {
+ case LF | FF | CR | SU => newBuf append LiteralColor
+ case _ => ()
+ }
}
newBuf append NoColor
prev = curr