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

ammonite.kernel.CompilerCompatibility.scala Maven / Gradle / Ivy

There is a newer version: 0.4.2
Show newest version
package ammonite.kernel

import scala.tools.nsc.Global
import scala.tools.nsc.interactive.{Global => InteractiveGlobal}
import scala.tools.nsc.plugins.Plugin
import scala.tools.nsc.typechecker.Analyzer

private[kernel] object CompilerCompatibility {
  // def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } =
  //   new { val global: g.type = g } with Analyzer {
  //     override def findMacroClassLoader() = cl
  //   }

  // type InteractiveAnalyzer = scala.tools.nsc.interactive.InteractiveAnalyzer

  // def interactiveAnalyzer(g: InteractiveGlobal, cl: ClassLoader): InteractiveAnalyzer { val global: g.type } =
  //   new { val global: g.type = g } with InteractiveAnalyzer {
  //     override def findMacroClassLoader() = cl
  //   }

  // def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] =
  //   parser.parseStatsOrPackages()

  // def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = plugin.init(options, error)
  def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = {
    new { val global: g.type = g } with Analyzer {
      override def findMacroClassLoader() = cl
    }
  }

  type InteractiveAnalyzer = scala.tools.nsc.interactive.InteractiveAnalyzer

  def interactiveAnalyzer(g: InteractiveGlobal, cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = {
    new { val global: g.type = g } with InteractiveAnalyzer {
      override def findMacroClassLoader() = cl
    }
  }

  def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] = {
    parser.parseStatsOrPackages()
  }

  def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = {
    plugin.init(options, error)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy