Fix Scaladoc interface for 2.8.0.Beta1-RC4 and later.

This commit is contained in:
Mark Harrah 2009-12-20 12:02:49 -05:00
parent 3b28156f84
commit bb0a3b3d2f
4 changed files with 21 additions and 10 deletions

View File

@ -5,15 +5,15 @@ package xsbt
import xsbti.{AnalysisCallback,Logger} import xsbti.{AnalysisCallback,Logger}
import scala.tools.nsc.{Phase, SubComponent} import scala.tools.nsc.{Phase, SubComponent}
import Log.debug
class CompilerInterface class CompilerInterface
{ {
def run(args: Array[String], callback: AnalysisCallback, maximumErrors: Int, log: Logger) def run(args: Array[String], callback: AnalysisCallback, maximumErrors: Int, log: Logger)
{ {
def debug(msg: => String) = log.debug(Message(msg))
import scala.tools.nsc.{CompilerCommand, Global, Settings} import scala.tools.nsc.{CompilerCommand, Global, Settings}
debug("Interfacing (CompilerInterface) with Scala compiler " + scala.tools.nsc.Properties.versionString) debug(log, "Interfacing (CompilerInterface) with Scala compiler " + scala.tools.nsc.Properties.versionString)
val reporter = new LoggerReporter(maximumErrors, log) val reporter = new LoggerReporter(maximumErrors, log)
val settings = new Settings(reporter.error) val settings = new Settings(reporter.error)
@ -76,13 +76,13 @@ class CompilerInterface
if(!reporter.hasErrors) if(!reporter.hasErrors)
{ {
val run = new compiler.Run val run = new compiler.Run
debug(args.mkString("Calling Scala compiler with arguments (CompilerInterface):\n\t", "\n\t", "")) debug(log, args.mkString("Calling Scala compiler with arguments (CompilerInterface):\n\t", "\n\t", ""))
run compile command.files run compile command.files
} }
reporter.printSummary() reporter.printSummary()
if(reporter.hasErrors) if(reporter.hasErrors)
{ {
debug("Compilation failed (CompilerInterface)") debug(log, "Compilation failed (CompilerInterface)")
throw new InterfaceCompileFailed(args, "Compilation failed") throw new InterfaceCompileFailed(args, "Compilation failed")
} }
} }

View File

@ -0,0 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
*/
package xsbt
object Log
{
def debug(log: xsbti.Logger, msg: => String) = log.debug(Message(msg))
}

View File

@ -12,8 +12,8 @@ class RunInterface
{ {
def run(classpathURLs: Array[URL], mainClass: String, options: Array[String], log: Logger) def run(classpathURLs: Array[URL], mainClass: String, options: Array[String], log: Logger)
{ {
log.info(Message("Running " + mainClass + " ...")) log.info(Message("Running " + mainClass + " " + options.mkString(" ")))
log.debug(Message(" Classpath:" + classpathURLs.mkString("\n\t", "\n\t",""))) log.debug(Message(" Classpath:\n\t" + classpathURLs.mkString("\n\t")))
try { ObjectRunner.run(classpathURLs.toList, mainClass, options.toList) } try { ObjectRunner.run(classpathURLs.toList, mainClass, options.toList) }
catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause } catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
} }

View File

@ -5,6 +5,7 @@ package xsbt
import xsbti.Logger import xsbti.Logger
import scala.tools.nsc.SubComponent import scala.tools.nsc.SubComponent
import Log.debug
class ScaladocInterface class ScaladocInterface
{ {
@ -20,10 +21,11 @@ private class Runner(args: Array[String], maximumErrors: Int, log: Logger)
import forScope._ import forScope._
def run() def run()
{ {
debug(log, "Calling Scaladoc with arguments:\n\t" + args.mkString("\n\t"))
if(!reporter.hasErrors) if(!reporter.hasErrors)
{ {
import doc._ // 2.8 has doc.Processor import doc._ // 2.8 trunk and Beta1-RC4 have doc.DocFactory. For other Scala versions, the next line creates forScope.DocFactory
val processor = new Processor(reporter, docSettings) val processor = new DocFactory(reporter, docSettings)
processor.document(command.files) processor.document(command.files)
} }
reporter.printSummary() reporter.printSummary()
@ -32,12 +34,12 @@ private class Runner(args: Array[String], maximumErrors: Int, log: Logger)
object forScope object forScope
{ {
class Processor(reporter: LoggerReporter, docSettings: doc.Settings) // 2.7 compatibility class DocFactory(reporter: LoggerReporter, docSettings: doc.Settings) // 2.7 compatibility
{ {
object compiler extends Global(command.settings, reporter) object compiler extends Global(command.settings, reporter)
{ {
override def onlyPresentation = true override def onlyPresentation = true
class DefaultDocDriver // 2.8 compatibility class DefaultDocDriver // 2.8 source compatibility
{ {
assert(false) assert(false)
def process(units: Iterator[CompilationUnit]) = error("for 2.8 compatibility only") def process(units: Iterator[CompilationUnit]) = error("for 2.8 compatibility only")