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

Print this page




 102     /** Is tree a constructor declaration?
 103      */
 104     public static boolean isConstructor(JCTree tree) {
 105         if (tree.getTag() == JCTree.METHODDEF) {
 106             Name name = ((JCMethodDecl) tree).name;
 107             return name == name.table.names.init;
 108         } else {
 109             return false;
 110         }
 111     }
 112 
 113     /** Is there a constructor declaration in the given list of trees?
 114      */
 115     public static boolean hasConstructors(List<JCTree> trees) {
 116         for (List<JCTree> l = trees; l.nonEmpty(); l = l.tail)
 117             if (isConstructor(l.head)) return true;
 118         return false;
 119     }
 120 
 121     public static boolean isMultiCatch(JCCatch catchClause) {
 122         return catchClause.param.vartype.getTag() == JCTree.TYPEDISJUNCTION;
 123     }
 124 
 125     /** Is statement an initializer for a synthetic field?
 126      */
 127     public static boolean isSyntheticInit(JCTree stat) {
 128         if (stat.getTag() == JCTree.EXEC) {
 129             JCExpressionStatement exec = (JCExpressionStatement)stat;
 130             if (exec.expr.getTag() == JCTree.ASSIGN) {
 131                 JCAssign assign = (JCAssign)exec.expr;
 132                 if (assign.lhs.getTag() == JCTree.SELECT) {
 133                     JCFieldAccess select = (JCFieldAccess)assign.lhs;
 134                     if (select.sym != null &&
 135                         (select.sym.flags() & SYNTHETIC) != 0) {
 136                         Name selected = name(select.selected);
 137                         if (selected != null && selected == selected.table.names._this)
 138                             return true;
 139                     }
 140                 }
 141             }
 142         }




 102     /** Is tree a constructor declaration?
 103      */
 104     public static boolean isConstructor(JCTree tree) {
 105         if (tree.getTag() == JCTree.METHODDEF) {
 106             Name name = ((JCMethodDecl) tree).name;
 107             return name == name.table.names.init;
 108         } else {
 109             return false;
 110         }
 111     }
 112 
 113     /** Is there a constructor declaration in the given list of trees?
 114      */
 115     public static boolean hasConstructors(List<JCTree> trees) {
 116         for (List<JCTree> l = trees; l.nonEmpty(); l = l.tail)
 117             if (isConstructor(l.head)) return true;
 118         return false;
 119     }
 120 
 121     public static boolean isMultiCatch(JCCatch catchClause) {
 122         return catchClause.param.vartype.getTag() == JCTree.TYPEUNION;
 123     }
 124 
 125     /** Is statement an initializer for a synthetic field?
 126      */
 127     public static boolean isSyntheticInit(JCTree stat) {
 128         if (stat.getTag() == JCTree.EXEC) {
 129             JCExpressionStatement exec = (JCExpressionStatement)stat;
 130             if (exec.expr.getTag() == JCTree.ASSIGN) {
 131                 JCAssign assign = (JCAssign)exec.expr;
 132                 if (assign.lhs.getTag() == JCTree.SELECT) {
 133                     JCFieldAccess select = (JCFieldAccess)assign.lhs;
 134                     if (select.sym != null &&
 135                         (select.sym.flags() & SYNTHETIC) != 0) {
 136                         Name selected = name(select.selected);
 137                         if (selected != null && selected == selected.table.names._this)
 138                             return true;
 139                     }
 140                 }
 141             }
 142         }