summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/settings/FscSettings.scala
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-01-16 16:47:15 -0800
committerJames Iry <jamesiry@gmail.com>2013-01-25 15:52:46 -0800
commit952e1bfe02cd12b7882aae97ee0901094c7a38c7 (patch)
treec4f3e9648da51820e2fb3f81509a359f6c98196f /src/compiler/scala/tools/nsc/settings/FscSettings.scala
parent2fa859e1b3eb2ac57058feaba87d96adfbac9209 (diff)
downloadscala-952e1bfe02cd12b7882aae97ee0901094c7a38c7.tar.gz
scala-952e1bfe02cd12b7882aae97ee0901094c7a38c7.tar.bz2
scala-952e1bfe02cd12b7882aae97ee0901094c7a38c7.zip
SI-4602 Make fsc absolutize source file names
The fsc server was using a path supplied by the client to turn things like class path values into absolute paths. But it wasn't absolutizing the source file names supplied to the compiler which lead to SI-4602. This commit adds that absolutizing bit and cleans the logic up a bit so that the settings object isn't told a path that it already knows. A test is included that simulates changing directory by forcing two different -current-dir settings on two different compile sessions on the same server process.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/FscSettings.scala')
-rw-r--r--src/compiler/scala/tools/nsc/settings/FscSettings.scala23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/FscSettings.scala b/src/compiler/scala/tools/nsc/settings/FscSettings.scala
index 06ebc20d3e..5c852ae07c 100644
--- a/src/compiler/scala/tools/nsc/settings/FscSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/FscSettings.scala
@@ -38,14 +38,25 @@ class FscSettings(error: String => Unit) extends Settings(error) {
private def holdsPath = Set[Settings#Setting](
d, dependencyfile, pluginsDir, Ygenjavap
)
+
+ override def processArguments(arguments: List[String], processAll: Boolean): (Boolean, List[String]) = {
+ val (r, args) = super.processArguments(arguments, processAll)
+ // we need to ensure the files specified with relative locations are absolutized based on the currentDir
+ (r, args map {a => absolutizePath(a)})
+ }
+
+ /**
+ * Take an individual path and if it's not absolute turns it into an absolute path based on currentDir.
+ * If it's already absolute then it's left alone.
+ */
+ private[this] def absolutizePath(p: String) = (Path(currentDir.value) resolve Path(p)).normalize.path
- /** All user set settings rewritten with absolute paths. */
- def absolutize(root: Path) {
- def rewrite(p: String) = (root resolve Path(p)).normalize.path
+ /** All user set settings rewritten with absolute paths based on currentDir */
+ def absolutize() {
userSetSettings foreach {
- case p: OutputSetting => p.outputDirs setSingleOutput AbstractFile.getDirectory(rewrite(p.value))
- case p: PathSetting => p.value = ClassPath.map(p.value, rewrite)
- case p: StringSetting => if (holdsPath(p)) p.value = rewrite(p.value)
+ case p: OutputSetting => p.outputDirs setSingleOutput AbstractFile.getDirectory(absolutizePath(p.value))
+ case p: PathSetting => p.value = ClassPath.map(p.value, absolutizePath)
+ case p: StringSetting => if (holdsPath(p)) p.value = absolutizePath(p.value)
case _ => ()
}
}