From 177505fcb9567827ac334c5c59decd58a43809c8 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 19 Jun 2007 17:58:07 +0000 Subject: added prompt/fileEnding properties --- src/compiler/scala/tools/nsc/CompileClient.scala | 6 +++--- src/compiler/scala/tools/nsc/CompilerCommand.scala | 2 +- src/compiler/scala/tools/nsc/EvalLoop.scala | 4 ++-- src/compiler/scala/tools/nsc/InterpreterLoop.scala | 3 +-- src/compiler/scala/tools/nsc/Main.scala | 3 ++- src/compiler/scala/tools/nsc/Properties.scala | 17 ++++++++++++++++- test/scalatest | 16 ++++++++++++---- 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala index f58ce1c087..0a3e47f8e9 100644 --- a/src/compiler/scala/tools/nsc/CompileClient.scala +++ b/src/compiler/scala/tools/nsc/CompileClient.scala @@ -36,7 +36,7 @@ class StandardCompileClient { pathsList.map(absFileName).mkString("", sep, "") } - val fileEnding = ".scala" + val fileEnding = Properties.fileEndingString protected def normalize(args: Array[String]): (String, String) = { var i = 0 @@ -57,7 +57,7 @@ class StandardCompileClient { } else if (arg == "-shutdown") { shutdown = true } - i = i + 1 + i += 1 if (i < args.length) { if (arg == "-classpath" || arg == "-sourcepath" || @@ -65,7 +65,7 @@ class StandardCompileClient { arg == "-extdirs" || arg == "-d") { args(i) = absFileNames(args(i)) - i = i + 1 + i += 1 } else if (arg == "-server") { serverAdr = args(i) args(i-1) = "" diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 0907b589d3..333d95d6ca 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -20,7 +20,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings, val cmdName = "scalac" /** The file extension of files that the compiler can process */ - def fileEnding = ".scala" //todo: lazy val + def fileEnding = Properties.fileEndingString //todo: lazy val private val helpSyntaxColumnWidth: Int = Iterable.max(settings.allSettings map (_.helpSyntax.length)) diff --git a/src/compiler/scala/tools/nsc/EvalLoop.scala b/src/compiler/scala/tools/nsc/EvalLoop.scala index 25f34e4e8d..ea58f8b9b0 100644 --- a/src/compiler/scala/tools/nsc/EvalLoop.scala +++ b/src/compiler/scala/tools/nsc/EvalLoop.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -10,7 +10,7 @@ trait EvalLoop { def prompt: String - def loop(action: (String) => Unit): Unit = { + def loop(action: (String) => Unit) { Console.print(prompt) val line = Console.readLine if ((line ne null) && line.length() > 0) { diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index 004ea3f74a..99a26e1336 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -104,7 +104,7 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { } /** Prompt to print when awaiting input */ - val prompt = "scala> " + val prompt = Properties.shellPromptString /** The main read-eval-print loop for the interpreter. It calls * command() for each line of input, and stops when @@ -114,7 +114,6 @@ class InterpreterLoop(in0: BufferedReader, out: PrintWriter) { var first = true while (true) { if (interactive) { - out.print("\n") out.print(prompt) out.flush } diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index cc50e71d9b..e473a83a60 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -21,7 +21,8 @@ object Main extends AnyRef with EvalLoop { val versionMsg = "Scala compiler " + Properties.versionString + " -- " + Properties.copyrightString - val prompt = "\nnsc> " + + val prompt = Properties.residentPromptString var reporter: ConsoleReporter = _ diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala index 9f3001c9e0..d6fdca15bb 100644 --- a/src/compiler/scala/tools/nsc/Properties.scala +++ b/src/compiler/scala/tools/nsc/Properties.scala @@ -31,7 +31,7 @@ object Properties { */ val versionString: String = { val defaultString = "(unknown)" - "version " + props.getProperty("version.number") + "version " + props.getProperty("version.number", defaultString) } val copyrightString: String = { @@ -44,6 +44,21 @@ object Properties { props.getProperty("file.encoding", defaultString) } + val fileEndingString: String = { + val defaultString = ".scala" + props.getProperty("file.ending", defaultString) + } + + val residentPromptString: String = { + val defaultString = "\nnsc> " + props.getProperty("resident.prompt", defaultString) + } + + val shellPromptString: String = { + val defaultString = "\nscala> " + props.getProperty("shell.prompt", defaultString) + } + val scalaHome: String = System.getProperty("scala.home") diff --git a/test/scalatest b/test/scalatest index a308ffcf9f..59647ce87c 100755 --- a/test/scalatest +++ b/test/scalatest @@ -264,12 +264,15 @@ test_run_jvm() { fi rm -rf "$dstbase".obj && mkdir -p "$dstbase".obj && - env JAVACMD="$JAVACMD" JAVA_OPTS="$javaopts" $SCALAC -d "$os_dstbase".obj -cp "$JVM_EXT_CLASSPATH" "$@" "$os_srcbase".scala && + env JAVACMD="$JAVACMD" JAVA_OPTS="$javaopts" $SCALAC -d "$os_dstbase".obj \ + -cp "$JVM_EXT_CLASSPATH" "$@" "$os_srcbase".scala && libpath=`get_os_pathlist "$dstdir"` && scala_javaopts=`echo -Djava.library.path=$libpath` && scala_lib=`get_os_filename "$SCALA_LIB"` && - classpath=`get_os_pathlist "$os_dstbase".obj:$CLASSPATH` && - env JAVA_OPTS="$scala_javaopts" $SCALA -Djavacmd="$JAVACMD" -Dscalatest.output=$os_dstbase.obj -Dscalatest.lib=$scala_lib -classpath $classpath:$JVM_EXT_CLASSPATH Test "jvm" && + classpath=`get_os_pathlist "$os_dstbase".obj:$SCALA_COMP:$CLASSPATH` && + env JAVA_OPTS="$scala_javaopts" $SCALA -Djavacmd="$JAVACMD" \ + -Dscalatest.output=$os_dstbase.obj -Dscalatest.lib=$scala_lib \ + -classpath $classpath:$JVM_EXT_CLASSPATH Test "jvm" && rm -rf "$dstbase".obj; } @@ -595,18 +598,22 @@ FILES_SHOOTOUT=""; QUICK="$PREFIX/build/quick/bin" QUICK_LIB="$PREFIX/build/quick/lib/library" +QUICK_COMP="$PREFIX/build/quick/lib/compiler" JVM_EXT_CLASSPATH=`get_ext_classpath $TESTROOT/files/lib` if [ -d "$PREFIX/dists" ]; then LATEST="$PREFIX/dists/latest/bin"; LATEST_LIB="$PREFIX/dists/latest/lib/scala-library.jar"; + LATEST_COMP="$PREFIX/dists/latest/lib/scala-compiler.jar"; elif [ -d "$PREFIX/build" ]; then LATEST="$QUICK"; LATEST_LIB=$QUICK_LIB + LATEST_COMP=$QUICK_COMP elif [ -d "$PREFIX/bin" ]; then LATEST="$PREFIX/bin"; LATEST_LIB="$PREFIX/lib/scala-library.jar" + LATEST_COMP="$PREFIX/lib/scala-compiler.jar" else abort "Scala binaries could not be found"; fi; @@ -614,6 +621,7 @@ BIN_DIR="$LATEST/" # BIN_DIR should have a trailing / when needed, so that # it can also be set to the empty string SCALA_LIB="$LATEST_LIB"; +SCALA_COMP="$LATEST_COMP"; [ -x "$JAVACMD" ] || JAVACMD=java; [ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms16M"; @@ -645,7 +653,7 @@ while [ $# -gt 0 ]; do --script ) TEST_TYPE="script"; shift 1;; --ant ) TEST_TYPE="ant"; shift 1;; --shootout ) TEST_TYPE="shootout"; shift 1;; - --quick ) BIN_DIR="$QUICK/"; SCALA_LIB=$QUICK_LIB; shift 1;; + --quick ) BIN_DIR="$QUICK/"; SCALA_LIB=$QUICK_LIB; SCALA_COMP=$QUICK_COMP; shift 1;; --installed ) BIN_DIR=""; shift 1;; --no-run ) NORUN="true"; shift 1;; --show-log ) SHOWLOG="true"; shift 1;; -- cgit v1.2.3