aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-05-10 13:00:12 +0200
committerMartin Odersky <odersky@gmail.com>2013-05-10 13:00:12 +0200
commit5ec2199c4966404d462eb866533dc0589fe7f239 (patch)
treee62ca907f8645c4820697d8bddb596a8d644d55f
parent60cf06a76b55cc0e1098557b8464fbcfdd324887 (diff)
downloaddotty-5ec2199c4966404d462eb866533dc0589fe7f239.tar.gz
dotty-5ec2199c4966404d462eb866533dc0589fe7f239.tar.bz2
dotty-5ec2199c4966404d462eb866533dc0589fe7f239.zip
Added locator for untyped trees.
-rw-r--r--src/dotty/tools/dotc/core/UntypedTrees.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/UntypedTrees.scala b/src/dotty/tools/dotc/core/UntypedTrees.scala
index 82a160ab0..8cd857f95 100644
--- a/src/dotty/tools/dotc/core/UntypedTrees.scala
+++ b/src/dotty/tools/dotc/core/UntypedTrees.scala
@@ -74,5 +74,18 @@ object UntypedTrees {
def ugen(implicit ctx: Context) =
new UGen
+
+ implicit class UntypedTreeDecorator(val self: Tree) extends AnyVal {
+ def locateEnclosing(base: List[Tree], pos: Position): List[Tree] = {
+ def encloses(elem: Any) = elem match {
+ case t: Tree => t.envelope contains pos
+ case _ => false
+ }
+ base.productIterator find encloses match {
+ case Some(tree: Tree) => locateEnclosing(tree :: base, pos)
+ case none => base
+ }
+ }
+ }
}