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

tethys.derivation.impl.MacroLogging.scala Maven / Gradle / Ivy

The newest version!
package tethys.derivation.impl

import scala.language.experimental.macros
import scala.reflect.macros.blackbox

object MacroLogging {
  def logCode[A](tree: A): A = macro MacroLoggingImpl.logCode
  def logTree[A](tree: A): A = macro MacroLoggingImpl.logTree

  private class MacroLoggingImpl(val c: blackbox.Context) {
    import c.universe._

    def logCode(tree: Tree): Tree = {
      c.info(c.enclosingPosition, show(tree), force = false)
      tree
    }

    def logTree(tree: Tree): Tree = {
      c.info(c.enclosingPosition, showRaw(tree), force = false)
      tree
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy