Skip to content

Commit 6103469

Browse files
author
Tobias Bordenca
committed
created SyntaxHightlightUtils
1 parent 5643de4 commit 6103469

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scala.tasty
22
package util
33

44
import scala.annotation.switch
5+
import scala.tasty.util.SyntaxHighlightUtils._
56

67
class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty0) {
78
import tasty.{rootContext => _, _}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package scala.tasty
2+
package util
3+
4+
object SyntaxHighlightUtils {
5+
6+
// Keep in sync with SyntaxHighlighting
7+
private val NoColor = Console.RESET
8+
private val CommentColor = Console.BLUE
9+
private val KeywordColor = Console.YELLOW
10+
private val ValDefColor = Console.CYAN
11+
private val LiteralColor = Console.RED
12+
private val StringColor = Console.GREEN
13+
private val TypeColor = Console.MAGENTA
14+
private val AnnotationColor = Console.MAGENTA
15+
16+
def none(str: String) = str
17+
def keyword(str: String) = KeywordColor + str + NoColor
18+
def typeDef(str: String) = TypeColor + str + NoColor
19+
def literal(str: String) = LiteralColor + str + NoColor
20+
def valDef(str: String) = ValDefColor + str + NoColor
21+
def operator(str: String) = TypeColor + str + NoColor
22+
def annotation(str: String) =
23+
if (str.trim == "@") str else { AnnotationColor + str + NoColor }
24+
val tripleQs = Console.RED_B + "???" + NoColor
25+
26+
}

0 commit comments

Comments
 (0)