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/scalap | |
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/scalap')
-rw-r--r-- | src/scalap/scala/tools/scalap/Decode.scala | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index d859ac5766..04d72c015b 100644 --- a/src/scalap/scala/tools/scalap/Decode.scala +++ b/src/scalap/scala/tools/scalap/Decode.scala @@ -23,9 +23,36 @@ object Decode { case _ => NoSymbol } + /** private[scala] so nobody gets the idea this is a supported interface. + */ + private[scala] def caseParamNames(path: String): Option[List[String]] = { + val (outer, inner) = (path indexOf '$') match { + case -1 => (path, "") + case x => (path take x, path drop (x + 1)) + } + + for { + clazz <- getSystemLoader.tryToLoadClass[AnyRef](outer) + ssig <- ScalaSigParser.parse(clazz) + } + yield { + val f: PartialFunction[Symbol, List[String]] = + if (inner.isEmpty) { + case x: MethodSymbol if x.isCaseAccessor && (x.name endsWith " ") => List(x.name dropRight 1) + } + else { + case x: ClassSymbol if x.name == inner => + val xs = x.children filter (child => child.isCaseAccessor && (child.name endsWith " ")) + xs.toList map (_.name dropRight 1) + } + + (ssig.symbols partialMap f).flatten toList + } + } + /** Returns a map of Alias -> Type for the given package. */ - def typeAliases(pkg: String) = { + private[scala] def typeAliases(pkg: String) = { for { clazz <- getSystemLoader.tryToLoadClass[AnyRef](pkg + ".package") ssig <- ScalaSigParser.parse(clazz) |