diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-07-31 11:33:16 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-02 15:50:52 +0200 |
commit | 027b00171c0d92ec669deaa471966e6468c6b8cf (patch) | |
tree | 63808014ea752c49ae39e0b731f0d15bc6edeb28 /src/reflect/scala/reflect/api/Trees.scala | |
parent | b578059b43a4caaadee2cb20f74cd9a7c876c8ef (diff) | |
download | scala-027b00171c0d92ec669deaa471966e6468c6b8cf.tar.gz scala-027b00171c0d92ec669deaa471966e6468c6b8cf.tar.bz2 scala-027b00171c0d92ec669deaa471966e6468c6b8cf.zip |
more refinements of reflection API
Added a bunch of test methods to symbols to cover public flags:
(e.g. isPrivate, isFinal, isOverride, isImplicit, etc). I'd argue that
the API duplication w.r.t flag sets is trumped by unified interface
to tests and better encapsulation.
Also updated the API to be easier to understand after prior exposure
to Java or .NET reflection APIs:
1) Added typeParams to TypeSymbol and ClassSymbol.
2) Renamed MethodSymbol.resultType to returnType.
3) Removed the distinction between MethodSymbol.params vs MethodSymbol.allParams
now we just have MethodSymbol.params: List[List[Symbol]].
Diffstat (limited to 'src/reflect/scala/reflect/api/Trees.scala')
-rw-r--r-- | src/reflect/scala/reflect/api/Trees.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index 28dd764c70..8165f599b2 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -640,8 +640,16 @@ trait Trees extends base.Trees { self: Universe => abstract class Transformer { val treeCopy: TreeCopier = newLazyTreeCopier protected[scala] var currentOwner: Symbol = rootMirror.RootClass - protected def currentMethod = currentOwner.enclosingMethod - protected def currentClass = currentOwner.enclosingClass + protected def currentMethod = { + def enclosingMethod(sym: Symbol): Symbol = + if (sym.isMethod || sym == NoSymbol) sym else enclosingMethod(sym.owner) + enclosingMethod(currentOwner) + } + protected def currentClass = { + def enclosingClass(sym: Symbol): Symbol = + if (sym.isClass || sym == NoSymbol) sym else enclosingClass(sym.owner) + enclosingClass(currentOwner) + } // protected def currentPackage = currentOwner.enclosingTopLevelClass.owner def transform(tree: Tree): Tree = itransform(this, tree) |