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

org.scalameta.internal.DebugFinder.scala Maven / Gradle / Ivy

Go to download

Bag of private and public helpers used in scala.meta's APIs and implementations

There is a newer version: 4.12.2
Show newest version
package org.scalameta
package internal

import scala.reflect.macros.blackbox.Context

trait DebugFinder {
  val c: Context
  import c.universe._

  def debuggees(tree: Tree): Map[String, Tree] = {
    object debugFinder extends Traverser {
      private val invariantsPackageObject = c.mirror.staticPackage("org.scalameta").info
        .member(termNames.PACKAGE).asModule
      private val invariantsDebug = invariantsPackageObject.info.member(TermName("debug")).asMethod
      val debuggees = scala.collection.mutable.ListBuffer[Tree]()
      override def traverse(tree: Tree): Unit = tree match {
        case Apply(fun, args) if fun.symbol == invariantsDebug => debuggees ++= args
        case tree => super.traverse(tree)
      }
    }
    debugFinder.traverse(tree)
    debugFinder.debuggees.map(tree => tree.toString -> tree.duplicate).toMap
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy