diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-26 22:14:15 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-26 22:14:15 +0000 |
commit | f6183b63f28a199b7888949963a8d6984d54c3b1 (patch) | |
tree | 8eb557773e913669e7ebac6a720392602fe72481 /src/compiler/scala/tools/nsc/interpreter/package.scala | |
parent | 8856f21f59ff735db7951901a799300a5affd9cc (diff) | |
download | scala-f6183b63f28a199b7888949963a8d6984d54c3b1.tar.gz scala-f6183b63f28a199b7888949963a8d6984d54c3b1.tar.bz2 scala-f6183b63f28a199b7888949963a8d6984d54c3b1.zip |
Refinements to the recent repl patches.
few more things, like literals (1.<tab>, "abc".<tab>). A completion
aware case class walker which leverages the names of the case fields for
completion. For instance:
:power
val x = new ProductCompletion(mkTree("def f(x: Int, y: Int) = f(5, 10) + f(10, 20)")
x.<tab>
mods name rhs tparams tpt vparamss
x.rhs.fun.<tab>
name qualifier
scala> x.rhs.fun.qualifier
res3: scala.tools.nsc.ast.Trees$Apply = f(5, 10)
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/package.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/package.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/package.scala b/src/compiler/scala/tools/nsc/interpreter/package.scala new file mode 100644 index 0000000000..767bc9ca2f --- /dev/null +++ b/src/compiler/scala/tools/nsc/interpreter/package.scala @@ -0,0 +1,19 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc + +package object interpreter { + /** Apply a function and return the passed value */ + def returning[T](x: T)(f: T => Unit): T = { f(x) ; x } + + /** Tracing */ + def tracing[T](msg: String)(x: T): T = { println("(" + msg + ") " + x) ; x } + + /** Class objects */ + def classForName(name: String): Option[Class[_]] = + try Some(Class forName name) + catch { case _: ClassNotFoundException | _: SecurityException => None } +} |