summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/util/ClassPath.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-05-30 10:38:16 +0000
committermichelou <michelou@epfl.ch>2007-05-30 10:38:16 +0000
commit31d539218aaddc9e225800fc9c28869f4b6b96ab (patch)
tree8fc713a9c4b5b79f4d745e48b815e350133eb1b9 /src/compiler/scala/tools/nsc/util/ClassPath.scala
parent6712cfd277781008d6c66610ab23397cfcb5c850 (diff)
downloadscala-31d539218aaddc9e225800fc9c28869f4b6b96ab.tar.gz
scala-31d539218aaddc9e225800fc9c28869f4b6b96ab.tar.bz2
scala-31d539218aaddc9e225800fc9c28869f4b6b96ab.zip
added option -Xcodebase
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/ClassPath.scala')
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 2707e1675d..754abfc8b8 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -11,6 +11,7 @@
package scala.tools.nsc.util
import java.io.File
+import java.net.URL
import java.util.StringTokenizer
import scala.collection.mutable.ArrayBuffer
@@ -172,30 +173,24 @@ class ClassPath(onlyPresentation: Boolean) {
def root = new Context(entries.toList)
- def this(classpath: String) = {
+ def this(classpath: String) {
this()
addFilesInPath(classpath)
}
+ def this(source: String, output: String) {
+ this()
+ addDirsInPath(source, output)
+ }
+
def this(classpath: String, source: String, output: String,
- boot: String, extdirs: String) = {
+ boot: String, extdirs: String, codebase: String) {
this()
addFilesInPath(boot)
addArchivesInExtDirPath(extdirs)
- val clazzes = AbstractFile.getDirectory(output)
- if (clazzes eq null)
- throw new FatalError("Output location \"" + output + "\" not found")
- val strtok = new StringTokenizer(source, File.pathSeparator)
- if (!strtok.hasMoreTokens()) {
- val output0 = (new Output(clazzes, null))
- entries += output0
- }
- else while (strtok.hasMoreTokens()) {
- val sources = AbstractFile.getDirectory(strtok.nextToken())
- val output0 = (new Output(clazzes, sources))
- entries += output0
- }
+ addDirsInPath(source, output)
addFilesInPath(classpath)
+ addURLsInPath(codebase)
}
/**
@@ -203,7 +198,7 @@ class ClassPath(onlyPresentation: Boolean) {
* @param isDir ...
* @return ...
*/
- def lookupPath(path: String, isDir: Boolean) = {
+ def lookupPath(path: String, isDir: Boolean): AbstractFile = {
val ctx = root.find(path, isDir)
if (ctx eq null) null
else if (ctx.entries.isEmpty) null
@@ -215,7 +210,7 @@ class ClassPath(onlyPresentation: Boolean) {
* @param classes ...
* @param sources ...
*/
- def library(classes: String, sources: String) = {
+ def library(classes: String, sources: String) {
assert(classes ne null)
val location = AbstractFile.getDirectory(classes)
val sourceFile0 =
@@ -227,7 +222,7 @@ class ClassPath(onlyPresentation: Boolean) {
entries += new Library0()
}
- private def addFilesInPath(path: String) = {
+ private def addFilesInPath(path: String) {
val strtok = new StringTokenizer(path, File.pathSeparator)
while (strtok.hasMoreTokens()) {
val file = AbstractFile.getDirectory(strtok.nextToken())
@@ -235,7 +230,7 @@ class ClassPath(onlyPresentation: Boolean) {
}
}
- private def addArchivesInExtDirPath(path: String) = {
+ private def addArchivesInExtDirPath(path: String) {
val strtok = new StringTokenizer(path, File.pathSeparator)
while (strtok.hasMoreTokens()) {
val file = AbstractFile.getDirectory(strtok.nextToken())
@@ -251,6 +246,39 @@ class ClassPath(onlyPresentation: Boolean) {
}
}
+ private def addDirsInPath(source: String, output: String) {
+ val clazzes = AbstractFile.getDirectory(output)
+ if (clazzes eq null)
+ throw new FatalError("Output location \"" + output + "\" not found")
+ val strtok = new StringTokenizer(source, File.pathSeparator)
+ if (!strtok.hasMoreTokens()) {
+ val output0 = (new Output(clazzes, null))
+ entries += output0
+ }
+ else while (strtok.hasMoreTokens()) {
+ val sources = AbstractFile.getDirectory(strtok.nextToken())
+ val output0 = (new Output(clazzes, sources))
+ entries += output0
+ }
+ }
+
+ private val urlSeparator = " "
+ private def addURLsInPath(codebase: String) {
+ val strtok = new StringTokenizer(codebase, urlSeparator)
+ while (strtok.hasMoreTokens()) {
+ try {
+ val url = new URL(strtok.nextToken())
+ val archive = AbstractFile.getURL(url)
+ if (archive ne null) entries += (new Library(archive))
+ }
+ catch {
+ case e =>
+ Console.println("error in addURLsInPath: " + e.getMessage)//debug
+ throw e
+ }
+ }
+ }
+
override def toString() =
entries.toList.mkString("", File.pathSeparator, "")
} // class Build