summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompilerCommand.scala
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2008-10-15 13:58:23 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2008-10-15 13:58:23 +0000
commit86b39a89cda0680d487b3591b492e4dc2ed5263f (patch)
treeee6490ac748ce7c2247f870251db5adb8f9c2d50 /src/compiler/scala/tools/nsc/CompilerCommand.scala
parent1615902e57a0d61cebb62409bdc8da0cf1d8bf18 (diff)
downloadscala-86b39a89cda0680d487b3591b492e4dc2ed5263f.tar.gz
scala-86b39a89cda0680d487b3591b492e4dc2ed5263f.tar.bz2
scala-86b39a89cda0680d487b3591b492e4dc2ed5263f.zip
Fix for #296
The handling of informative messages in CompileServer and in Main was duplicated, and the two copies slowly diverged over time. The code has now been refactored, cleaned up, and made more general. The FakePos(fsc) message was due to a missing override def toString. Both problems are fixed.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompilerCommand.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompilerCommand.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala
index 9ad0bb2539..6f22fb8612 100644
--- a/src/compiler/scala/tools/nsc/CompilerCommand.scala
+++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala
@@ -66,6 +66,36 @@ class CompilerCommand(arguments: List[String], val settings: Settings,
"\n")
}
+ // If any of these settings is set, the compiler shouldn't
+ // start; an informative message of some sort
+ // should be printed instead.
+ // (note: do not add "files.isEmpty" do this list)
+ val stopSettings=List[(()=>Boolean,
+ (Global)=>String)](
+ (()=> settings.help.value, compiler =>
+ usageMsg + compiler.pluginOptionsHelp
+ ),
+ (()=> settings.Xhelp.value, compiler =>
+ xusageMsg
+ ),
+ (()=> settings.Yhelp.value, compiler =>
+ yusageMsg
+ ),
+ (()=> settings.showPlugins.value, compiler =>
+ compiler.pluginDescriptions
+ ),
+ (()=> settings.showPhases.value, compiler =>
+ compiler.phaseDescriptions
+ )
+ )
+
+ def shouldStopWithInfo = stopSettings.exists({pair => (pair._1)()})
+ def getInfoMessage(compiler:Global) =
+ stopSettings.find({pair => (pair._1)()}) match {
+ case Some((test,getMessage)) => getMessage(compiler)
+ case None => ""
+ }
+
/** Whether the command was processed okay */
var ok = true