From 6ee24a3c5d31ef769e47410d8806a5f4bd7a06bf Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Mar 2010 19:55:53 +0000 Subject: While working on partest discovered that Compil... While working on partest discovered that CompilerCommand ignores half its constructor arguments and a couple dozen places blithely pass it those arguments as if they're being used. Then there were setups like this: class OfflineCompilerCommand( arguments: List[String], settings: Settings, error: String => Unit, interactive: Boolean) extends CompilerCommand(arguments, new Settings(error), error, false) Hey offline compiler command, why throw away the perfectly good settings you were given? Ever heard 'reduce, reuse, recycle'? How did you ever work... or do you? No review. --- src/compiler/scala/tools/nsc/CompilerCommand.scala | 39 +++++++++------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'src/compiler/scala/tools/nsc/CompilerCommand.scala') diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 0ef2bcb85d..c8c7482811 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -11,16 +11,8 @@ import scala.collection.mutable.ListBuffer import io.File /** A class representing command line info for scalac */ -class CompilerCommand( - arguments: List[String], - val settings: Settings, - error: String => Unit, - interactive: Boolean, - shouldProcessArguments: Boolean) -{ - def this(arguments: List[String], settings: Settings, error: String => Unit, interactive: Boolean) = - this(arguments, settings, error, interactive, true) - +class CompilerCommand(arguments: List[String], val settings: Settings) { + def this(arguments: List[String], error: String => Unit) = this(arguments, new Settings(error)) type Setting = Settings#Setting /** file extensions of files that the compiler can process */ @@ -83,19 +75,20 @@ class CompilerCommand( settings splitParams (file.lines() map stripComment mkString " ") } - // CompilerCommand needs processArguments called at the end of its constructor, - // as does its subclass GenericRunnerCommand, but it cannot be called twice as it - // accumulates arguments. The fact that it's called from within the constructors - // makes initialization order an obstacle to simplicity. - val (ok: Boolean, files: List[String]) = - if (shouldProcessArguments) { - // expand out @filename to the contents of that filename - val expandedArguments = arguments flatMap { - case x if x startsWith "@" => expandArg(x) - case x => List(x) - } - - settings.processArguments(expandedArguments, true) + // override this if you don't want arguments processed here + def shouldProcessArguments: Boolean = true + + def processArguments: (Boolean, List[String]) = { + // expand out @filename to the contents of that filename + val expandedArguments = arguments flatMap { + case x if x startsWith "@" => expandArg(x) + case x => List(x) } + + settings.processArguments(expandedArguments, true) + } + + val (ok, files) = + if (shouldProcessArguments) processArguments else (true, Nil) } -- cgit v1.2.3