26 package com.sun.tools.javac.tree; |
26 package com.sun.tools.javac.tree; |
27 |
27 |
28 |
28 |
29 |
29 |
30 import com.sun.source.tree.Tree; |
30 import com.sun.source.tree.Tree; |
|
31 import com.sun.source.util.TreePath; |
31 import com.sun.tools.javac.code.*; |
32 import com.sun.tools.javac.code.*; |
32 import com.sun.tools.javac.comp.AttrContext; |
33 import com.sun.tools.javac.comp.AttrContext; |
33 import com.sun.tools.javac.comp.Env; |
34 import com.sun.tools.javac.comp.Env; |
34 import com.sun.tools.javac.tree.JCTree.*; |
35 import com.sun.tools.javac.tree.JCTree.*; |
35 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*; |
36 import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*; |
347 public static boolean isNull(JCTree tree) { |
348 public static boolean isNull(JCTree tree) { |
348 if (!tree.hasTag(LITERAL)) |
349 if (!tree.hasTag(LITERAL)) |
349 return false; |
350 return false; |
350 JCLiteral lit = (JCLiteral) tree; |
351 JCLiteral lit = (JCLiteral) tree; |
351 return (lit.typetag == BOT); |
352 return (lit.typetag == BOT); |
|
353 } |
|
354 |
|
355 /** Return true iff this tree is a child of some annotation. */ |
|
356 public static boolean isInAnnotation(Env<?> env, JCTree tree) { |
|
357 TreePath tp = TreePath.getPath(env.toplevel, tree); |
|
358 if (tp != null) { |
|
359 for (Tree t : tp) { |
|
360 if (t.getKind() == Tree.Kind.ANNOTATION) |
|
361 return true; |
|
362 } |
|
363 } |
|
364 return false; |
352 } |
365 } |
353 |
366 |
354 public static String getCommentText(Env<?> env, JCTree tree) { |
367 public static String getCommentText(Env<?> env, JCTree tree) { |
355 DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL)) |
368 DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL)) |
356 ? ((JCCompilationUnit) tree).docComments |
369 ? ((JCCompilationUnit) tree).docComments |