1.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jun 10 09:13:27 2015 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Jan 10 12:47:15 2014 +0100 1.3 @@ -28,6 +28,7 @@ 1.4 1.5 1.6 import com.sun.source.tree.Tree; 1.7 +import com.sun.source.util.TreePath; 1.8 import com.sun.tools.javac.code.*; 1.9 import com.sun.tools.javac.comp.AttrContext; 1.10 import com.sun.tools.javac.comp.Env; 1.11 @@ -351,6 +352,18 @@ 1.12 return (lit.typetag == BOT); 1.13 } 1.14 1.15 + /** Return true iff this tree is a child of some annotation. */ 1.16 + public static boolean isInAnnotation(Env<?> env, JCTree tree) { 1.17 + TreePath tp = TreePath.getPath(env.toplevel, tree); 1.18 + if (tp != null) { 1.19 + for (Tree t : tp) { 1.20 + if (t.getKind() == Tree.Kind.ANNOTATION) 1.21 + return true; 1.22 + } 1.23 + } 1.24 + return false; 1.25 + } 1.26 + 1.27 public static String getCommentText(Env<?> env, JCTree tree) { 1.28 DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL)) 1.29 ? ((JCCompilationUnit) tree).docComments