summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Properties.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-03-10 14:01:44 +0000
committerPaul Phillips <paulp@improving.org>2009-03-10 14:01:44 +0000
commit807daab252714f28d0d7a0e172af682520a8cf16 (patch)
tree30c5d38d62370113007f27509e434460775f8ba2 /src/compiler/scala/tools/nsc/Properties.scala
parenta1c3d51a90aed4daf097ed7e3aa1cf3c344c0d34 (diff)
downloadscala-807daab252714f28d0d7a0e172af682520a8cf16.tar.gz
scala-807daab252714f28d0d7a0e172af682520a8cf16.tar.bz2
scala-807daab252714f28d0d7a0e172af682520a8cf16.zip
Refactored a pile of duplicated Properties code...
Refactored a pile of duplicated Properties code into a trait which is used by the library, compiler, and partest Properties objects.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Properties.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Properties.scala76
1 files changed, 16 insertions, 60 deletions
diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala
index fcc522df93..4ec98a1d0c 100644
--- a/src/compiler/scala/tools/nsc/Properties.scala
+++ b/src/compiler/scala/tools/nsc/Properties.scala
@@ -6,68 +6,24 @@
// $Id$
package scala.tools.nsc
+import scala.util.PropertiesTrait
/** A utility to load the compiler properties from a Java properties file
* included in the jar.
*/
-object Properties {
-
- /** The name of the properties file */
- private val propFilename = "/compiler.properties"
-
- /** The loaded properties */
- private val props = {
- val props = new java.util.Properties
- val stream = classOf[Global].getResourceAsStream(propFilename)
- if (stream != null)
- props.load(stream)
- props
- }
-
- val isWin = System.getProperty("os.name") startsWith "Windows"
-
- /** The version number of the jar this was loaded from, or
- * "(unknown)" if it cannot be determined.
- */
- val versionString: String = {
- val defaultString = "(unknown)"
- "version " + props.getProperty("version.number", defaultString)
- }
-
- val copyrightString: String = {
- val defaultString = "(c) 2002-2009 LAMP/EPFL"
- props.getProperty("copyright.string", defaultString)
- }
-
- val encodingString: String = {
- val defaultString = "UTF8" //"ISO-8859-1"
- props.getProperty("file.encoding", defaultString)
- }
-
- val fileEndingString: String = {
- val defaultString = ".scala|.java"
- 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")
-
- val envClasspath: String =
- System.getProperty("env.classpath")
-
- val cmdName: String =
- if (isWin) "scala.bat" else "scala"
-
- val msilILasm: String =
- System.getProperty("msil.ilasm", "")
+object Properties extends PropertiesTrait {
+ protected def propCategory = "compiler"
+ protected def pickJarBasedOn = classOf[Global]
+
+ // settings based on jar properties
+ val fileEndingString = prop("file.ending", ".scala|.java")
+ val residentPromptString = prop("resident.prompt", "\nnsc> ")
+ val shellPromptString = prop("shell.prompt", "\nscala> ")
+
+ // settings based on System properties
+ val isWin = sysprop("os.name", "") startsWith "Windows"
+ val scalaHome = sysprop("scala.home", null)
+ val envClasspath = sysprop("env.classpath", null)
+ val msilILasm = sysprop("msil.ilasm", "")
+ val cmdName = if (isWin) "scala.bat" else "scala"
}