diff options
author | Paul Phillips <paulp@improving.org> | 2010-04-06 05:19:19 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-04-06 05:19:19 +0000 |
commit | 1cc838b634cb0e11228eb7fd18710703036b8c17 (patch) | |
tree | 0df276591345ae6f3a5215f0458bb7d988adeb7a /src/compiler/scala/tools/nsc/util/ClassPath.scala | |
parent | 4ca7a22d9e7a60df735aaa25beed6c48d011d161 (diff) | |
download | scala-1cc838b634cb0e11228eb7fd18710703036b8c17.tar.gz scala-1cc838b634cb0e11228eb7fd18710703036b8c17.tar.bz2 scala-1cc838b634cb0e11228eb7fd18710703036b8c17.zip |
Some tweaks to classpath handling I had left ov...
Some tweaks to classpath handling I had left over from trying to figure
out the continuations plugin issue. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/ClassPath.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ClassPath.scala | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index f54fb4d0a2..c35b7139c6 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -30,19 +30,19 @@ object ClassPath { private def expandS(pattern: String): List[String] = { val wildSuffix = File.separator + "*" - /** Get all jars in directory */ - def lsJars(dir: Directory, filt: String => Boolean = _ => true) = - dir.files collect { case f if filt(f.name) && (f hasExtension "jar") => f.path } toList + /** Get all subdirectories, jars, zips out of a directory. */ + def lsDir(dir: Directory, filt: String => Boolean = _ => true) = + dir.list filter (x => filt(x.name) && (x.isDirectory || isJarOrZip(x))) map (_.path) toList def basedir(s: String) = if (s contains File.separator) s.substring(0, s.lastIndexOf(File.separator)) else "." - if (pattern == "*") lsJars(Directory(".")) - else if (pattern endsWith wildSuffix) lsJars(Directory(pattern dropRight 2)) + if (pattern == "*") lsDir(Directory(".")) + else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2)) else if (pattern contains '*') { val regexp = ("^%s$" format pattern.replaceAll("""\*""", """.*""")).r - lsJars(Directory(pattern).parent, regexp findFirstIn _ isDefined) + lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined) } else List(pattern) } @@ -197,6 +197,10 @@ abstract class ClassPath[T] { */ def asURLs: List[URL] + /** The whole classpath in the form of one String. + */ + def asClasspathString: String + /** Info which should be propagated to any sub-classpaths. */ def context: ClassPathContext[T] @@ -284,6 +288,7 @@ class SourcePath[T](dir: AbstractFile, val context: ClassPathContext[T]) extends def name = dir.name override def origin = dir.underlyingSource map (_.path) def asURLs = dir.sfile.toList map (_.toURL) + def asClasspathString = dir.path val sourcepaths: List[AbstractFile] = List(dir) lazy val classes: List[ClassRep] = dir collect { @@ -305,6 +310,7 @@ class DirectoryClassPath(val dir: AbstractFile, val context: ClassPathContext[Ab def name = dir.name override def origin = dir.underlyingSource map (_.path) def asURLs = dir.sfile.toList map (_.toURL) + def asClasspathString = dir.path val sourcepaths: List[AbstractFile] = Nil lazy val classes: List[ClassRep] = dir collect { @@ -327,10 +333,12 @@ class MergedClassPath[T]( val context: ClassPathContext[T]) extends ClassPath[T] { def name = entries.head.name - override def origin = Some(entries map (x => x.origin getOrElse x.name) mkString ("Merged(", ", ", ")")) def asURLs = entries flatMap (_.asURLs) lazy val sourcepaths: List[AbstractFile] = entries flatMap (_.sourcepaths) + override def origin = Some(entries map (x => x.origin getOrElse x.name) mkString ("Merged(", ", ", ")")) + override def asClasspathString: String = join(entries map (_.asClasspathString) : _*) + lazy val classes: List[AnyClassRep] = { val cls = new ListBuffer[AnyClassRep] for (e <- entries; c <- e.classes) { @@ -396,11 +404,6 @@ extends ClassPath[T] { }) } - def asClasspathString: String = join(entries collect { - case x: DirectoryClassPath => x.dir.path - case x: MergedClassPath[_] => x.asClasspathString - }: _*) - def show { println("ClassPath %s has %d entries and results in:\n".format(name, entries.size)) asClasspathString split ':' foreach (x => println(" " + x)) |