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

internal.InspectTree.scala Maven / Gradle / Ivy

package com.tschuchort.hkd
package internal

import scala.quoted.*
import scala.annotation.MacroAnnotation
import scala.annotation.experimental

@experimental
protected[tschuchort] class InspectTree extends MacroAnnotation {
  override def transform(using q: Quotes)(tree: q.reflect.Definition): List[q.reflect.Definition] =
    import q.reflect.{*, given}
    // printTastyTypeRepr(tree.symbol.owner.info.memberType(tree.symbol))
    println("-----------------------------------------------------")
    println(Printer.TreeShortCode.show(tree))
    printTastyTree(tree)
    List(tree)

}

protected[tschuchort] transparent inline def inspectTree(inline expr: Any): Any = ${ inspectTreeImpl('expr) }

private def inspectTreeImpl(expr: Expr[Any])(using q: Quotes): Expr[Any] =
  import q.reflect.*
  printTastyTree(expr.asTerm)
  expr




© 2015 - 2024 Weber Informatics LLC | Privacy Policy