src/share/classes/com/sun/tools/javac/tree/TreeInfo.java

changeset 1143
ec59a2ce9114
parent 1138
7375d4979bd3
child 1219
48ee63caaa93
equal deleted inserted replaced
1142:c896d95e7469 1143:ec59a2ce9114
224 case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty(); 224 case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
225 case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz); 225 case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
226 default: return false; 226 default: return false;
227 } 227 }
228 } 228 }
229
230 /**
231 * Return true if the AST corresponds to a static select of the kind A.B
232 */
233 public static boolean isStaticSelector(JCTree base, Names names) {
234 if (base == null)
235 return false;
236 switch (base.getTag()) {
237 case IDENT:
238 JCIdent id = (JCIdent)base;
239 return id.name != names._this &&
240 id.name != names._super &&
241 isStaticSym(base);
242 case SELECT:
243 return isStaticSym(base) &&
244 isStaticSelector(((JCFieldAccess)base).selected, names);
245 case TYPEAPPLY:
246 return true;
247 default:
248 return false;
249 }
250 }
251 //where
252 private static boolean isStaticSym(JCTree tree) {
253 Symbol sym = symbol(tree);
254 return (sym.kind == Kinds.TYP ||
255 sym.kind == Kinds.PCK);
256 }
229 257
230 /** Return true if a tree represents the null literal. */ 258 /** Return true if a tree represents the null literal. */
231 public static boolean isNull(JCTree tree) { 259 public static boolean isNull(JCTree tree) {
232 if (!tree.hasTag(LITERAL)) 260 if (!tree.hasTag(LITERAL))
233 return false; 261 return false;

mercurial