All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ammonite.repl.tools.Desugar.scala Maven / Gradle / Ivy

There is a newer version: 2.4.1-8-a6696a8f
Show newest version
package ammonite.repl.tools

import sourcecode.Compat._
import scala.language.experimental.macros


class Desugared(s: String){
  override def toString() = s
}
object desugar{
  def transformer(c: Context)(expr: c.Expr[Any]): c.Expr[Desugared] = {
    import c.universe._
    c.Expr[Desugared](q"ammonite.repl.tools.desugar.impl(${showCode(expr.tree)})")
  }

  def impl(s: String)(implicit colors: ammonite.util.CodeColors): Desugared = {

    new Desugared(
      ammonite.repl.Highlighter.defaultHighlight(
        s.toVector,
        colors.comment,
        colors.`type`,
        colors.literal,
        colors.keyword,
        fansi.Attr.Reset
      ).mkString
    )
  }

  def apply(expr: Any): Desugared = macro transformer
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy