langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
changeset 29776 984a79b71cfe
parent 29051 7244db2ab176
child 36526 3b41f1c69604
equal deleted inserted replaced
29775:dc7df633fea1 29776:984a79b71cfe
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   184     public static boolean isDiamond(JCTree tree) {
   184     public static boolean isDiamond(JCTree tree) {
   185         switch(tree.getTag()) {
   185         switch(tree.getTag()) {
   186             case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
   186             case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
   187             case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
   187             case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
   188             case ANNOTATED_TYPE: return isDiamond(((JCAnnotatedType)tree).underlyingType);
   188             case ANNOTATED_TYPE: return isDiamond(((JCAnnotatedType)tree).underlyingType);
       
   189             default: return false;
       
   190         }
       
   191     }
       
   192 
       
   193     /** Return true if the given tree represents a type elided anonymous class instance creation. */
       
   194     public static boolean isAnonymousDiamond(JCTree tree) {
       
   195         switch(tree.getTag()) {
       
   196             case NEWCLASS:  {
       
   197                 JCNewClass nc = (JCNewClass)tree;
       
   198                 return nc.def != null && isDiamond(nc.clazz);
       
   199             }
       
   200             case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType);
   189             default: return false;
   201             default: return false;
   190         }
   202         }
   191     }
   203     }
   192 
   204 
   193     public static boolean isEnumInit(JCTree tree) {
   205     public static boolean isEnumInit(JCTree tree) {