diff options
author | Miles Sabin <miles@milessabin.com> | 2009-11-15 15:46:52 +0000 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2009-11-15 15:46:52 +0000 |
commit | 31c1983e7264242ea5e35a4cf1ab54105a4d2419 (patch) | |
tree | a6bd81c047a5839845856e8438e01584f02413ed /src/compiler/scala/tools/nsc/Global.scala | |
parent | 046bbed8b7afdb13af1b3f35daf44b72d3a7936d (diff) | |
download | scala-31c1983e7264242ea5e35a4cf1ab54105a4d2419.tar.gz scala-31c1983e7264242ea5e35a4cf1ab54105a4d2419.tar.bz2 scala-31c1983e7264242ea5e35a4cf1ab54105a4d2419.zip |
Fixed #2627.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index bae0d624c6..f137a8eb4c 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -10,7 +10,7 @@ import java.io.{File, FileOutputStream, PrintWriter} import java.io.{IOException, FileNotFoundException} import java.nio.charset._ import compat.Platform.currentTime -import scala.tools.nsc.io.{SourceReader, AbstractFile} +import scala.tools.nsc.io.{SourceReader, AbstractFile, Path} import scala.tools.nsc.reporters._ import scala.tools.nsc.util.{ClassPath, MsilClassPath, JavaClassPath, SourceFile, BatchSourceFile, OffsetPosition, RangePosition} @@ -227,28 +227,12 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable settings.dependenciesFile.value match { case "none" => () case x => - val jfile = new java.io.File(x) - if (!jfile.exists) jfile.createNewFile - else { - // This logic moved here from scala.tools.nsc.dependencies.File. - // Note that it will trip an assertion in lookupPathUnchecked - // if the path being looked at is absolute. - - /** The directory where file lookup should start at. */ - val rootDirectory: AbstractFile = { - AbstractFile.getDirectory(".") -// val roots = java.io.File.listRoots() -// assert(roots.length > 0) -// new PlainFile(roots(0)) - } - - def toFile(path: String) = { - val file = rootDirectory.lookupPathUnchecked(path, false) - assert(file ne null, path) - file - } - - dependencyAnalysis.loadFrom(AbstractFile.getFile(jfile), toFile) + val depFilePath = Path(x) + if (depFilePath.exists) { + /** The directory where file lookup should start */ + val rootPath = Path("") + def toFile(path: String) = AbstractFile.getFile(rootPath resolve Path(path)) + dependencyAnalysis.loadFrom(AbstractFile.getFile(depFilePath), toFile) } } @@ -841,15 +825,20 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable informTime("total", startTime) if (!dependencyAnalysis.off) { - - def fromFile(file: AbstractFile): String = { - val path = file.path - if (path.startsWith("./")) - path.substring(2, path.length) - else path + settings.dependenciesFile.value match { + case "none" => + case x => + val depFilePath = Path(x) + if (!depFilePath.exists) + dependencyAnalysis.dependenciesFile = AbstractFile.getFile(depFilePath.createFile()) + + /** The directory where file lookup should start */ + val rootPath = Path("").normalize + def fromFile(file: AbstractFile): String = + rootPath.relativize(Path(file.file).normalize).path + + dependencyAnalysis.saveDependencies(fromFile) } - - dependencyAnalysis.saveDependencies(fromFile) } } |