From e25232d5b4fdc1ae7bc5a44ad06e31a00699dbaf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 3 Aug 2014 20:50:37 +0200 Subject: Annotation decorators for symbols Added decorators for symbols that can query specific annotations and annotation arguments (for now, -deprecated and -migration are added) --- src/dotty/tools/dotc/ast/TreeInfo.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/ast/TreeInfo.scala') diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index cc3e53abc..174de4d46 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -103,11 +103,19 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => /** The number of arguments in an application */ def numArgs(tree: Tree): Int = unsplice(tree) match { case Apply(fn, args) => numArgs(fn) + args.length - case TypeApply(fn, args) => numArgs(fn) - case Block(stats, expr) => numArgs(expr) + case TypeApply(fn, _) => numArgs(fn) + case Block(_, expr) => numArgs(expr) case _ => 0 } + /** The (last) list of arguments of an application */ + def arguments(tree: Tree): List[Tree] = unsplice(tree) match { + case Apply(_, args) => args + case TypeApply(fn, _) => arguments(fn) + case Block(_, expr) => arguments(expr) + case _ => Nil + } + /** Is tree a self constructor call this(...)? I.e. a call to a constructor of the * same object? */ -- cgit v1.2.3