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

io.getquill.quotation.CompileTimeBindings.scala Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
package io.getquill.quotation

import io.getquill.ast.{ Ast, CompileTimeBinding, StatefulTransformer }

import scala.reflect.macros.whitebox.Context

case class CompileTimeBindings[T](state: List[CompileTimeBinding])
  extends StatefulTransformer[List[CompileTimeBinding]] {

  override def apply(ast: Ast): (Ast, StatefulTransformer[List[CompileTimeBinding]]) =
    ast match {
      case binding: CompileTimeBinding => (binding, CompileTimeBindings(binding :: state))
      case other =>
        super.apply(other)
    }
}

object CompileTimeBindings {
  def apply(c: Context)(ast: Ast): List[CompileTimeBinding] =
    new CompileTimeBindings[c.Tree](List.empty[CompileTimeBinding])(ast) match {
      case (_, transformer) =>
        transformer.state.reverse
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy