diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-15 21:44:28 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-15 21:44:28 +0000 |
commit | 9132454143c32c39e8b44f2b63789e211fe70643 (patch) | |
tree | 08d25ff3532f1b972c4b07c4ce947963126b519b | |
parent | 821229741d41ab5a0087ddf289ee01b92e9c0685 (diff) | |
download | scala-9132454143c32c39e8b44f2b63789e211fe70643.tar.gz scala-9132454143c32c39e8b44f2b63789e211fe70643.tar.bz2 scala-9132454143c32c39e8b44f2b63789e211fe70643.zip |
Rewrote my own submitted code of a year ago fro...
Rewrote my own submitted code of a year ago from trac and added
scalawhich to the tools dir. Closes #657.
-rw-r--r-- | src/compiler/scala/tools/util/Which.scala | 39 | ||||
-rwxr-xr-x | tools/scalawhich | 4 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/util/Which.scala b/src/compiler/scala/tools/util/Which.scala new file mode 100644 index 0000000000..b331416f3d --- /dev/null +++ b/src/compiler/scala/tools/util/Which.scala @@ -0,0 +1,39 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools +package util + +import scala.tools.nsc._ + +/** A tool for identifying which classfile is being used. + * under the given conditions. + */ +object Which +{ + def main(args: Array[String]): Unit = { + val settings = new Settings() + val names = settings.processArguments(args.toList, true)._2 + val global = new Global(settings) + val cp = global.classPath + + import cp._ + + for (name <- names) { + def fail = println("Could not find: %s".format(name)) + (cp findClass name) match { + case Some(classRep) => classRep.binary match { + case Some(f) => println("%s is %s".format(name, f)) + case _ => fail + } + case _ => fail + } + } + } +} + + + + diff --git a/tools/scalawhich b/tools/scalawhich new file mode 100755 index 0000000000..6a4b1788a8 --- /dev/null +++ b/tools/scalawhich @@ -0,0 +1,4 @@ +#!/bin/sh +# + +scala scala.tools.util.Which $* |