foreigncompiler.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 49 行
SCALA
49 行
/* __ *\** ________ ___ / / ___ Scala Ant Tasks **** / __/ __// _ | / / / _ | (c) 2005-2008, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */package scala.tools.ant.sabbusimport java.io.Fileimport scala.tools.nsc._import scala.tools.nsc.reporters.ConsoleReporterclass ForeignCompiler { private var argsBuffer: Array[String] = null def args: Array[String] = argsBuffer def args_=(a: Array[String]): Unit = { argsBuffer = a nsc } private val error: (String => Nothing) = { msg => throw new Exception(msg) } private def settings = new scala.tools.nsc.Settings(error) private lazy val reporter = new ConsoleReporter(settings) private lazy val nsc: Global = { try { val command = new CompilerCommand(args.toList, settings, error, false) new Global(command.settings, reporter) } catch { case ex @ FatalError(msg) => throw new Exception(msg, ex) } } def compile(files: Array[File]): Int = { val command = new CompilerCommand(files.toList.map(_.toString), settings, error, true) (new nsc.Run) compile command.files reporter.ERROR.count << 16 | reporter.WARNING.count } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?