--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Jan 10 11:31:09 2014 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Jan 10 12:47:15 2014 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
@@ -342,6 +343,18 @@
return (lit.typetag == BOT);
}
+ /** Return true iff this tree is a child of some annotation. */
+ public static boolean isInAnnotation(Env<?> env, JCTree tree) {
+ TreePath tp = TreePath.getPath(env.toplevel, tree);
+ if (tp != null) {
+ for (Tree t : tp) {
+ if (t.getKind() == Tree.Kind.ANNOTATION)
+ return true;
+ }
+ }
+ return false;
+ }
+
public static String getCommentText(Env<?> env, JCTree tree) {
DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL))
? ((JCCompilationUnit) tree).docComments