我正在通过像这样在进程内运行它来测试我的插件:
type PluginMessage = StoreReporter#Info
def runPlugin(fileName: String): List[PluginMessage] = {
val settings = new Settings
settings.outputDirs setSingleOutput (curDir + "/target")
settings.classpath.tryToSet(List(
"project/boot/scala-" + scalaVersion + "/lib/scala-compiler.jar" +
":project/boot/scala-" + scalaVersion + "/lib/scala-library.jar"))
val reporter = new StoreReporter
val compiler = new Global(settings, reporter) {
override protected def computeInternalPhases() {
super.computeInternalPhases
for (phase <- new AlacsPlugin(this).components)
phasesSet += phase
}
}
(new compiler.Run).compile(List(testPrefix + fileName))
reporter.infos.toList
}
但是,考虑到scalac
我真的希望编译在某个阶段之后结束(特别是在我的插件运行之后)的速度很慢。不幸Global.cancel
的是没有达到预期的效果。我该怎么做?