158. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:09 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

158.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\javac\tree TreeInfo.java Mon Jan 22 14:47:06 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\javac\tree TreeInfo.java Wed Sep 12 16:50:21 2018 UTC

158.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 7 2362
Changed 6 12
Inserted 0 0
Removed 0 0

158.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

158.4 Active regular expressions

No regular expressions were active.

158.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 9, 2017, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26   package co m.sun.tool s.javac.tr ee;
  27  
  28  
  29  
  30   import com .sun.sourc e.tree.Tre e;
  31   import com .sun.sourc e.util.Tre ePath;
  32   import com .sun.tools .javac.cod e.*;
  33   import com .sun.tools .javac.com p.AttrCont ext;
  34   import com .sun.tools .javac.com p.Env;
  35   import com .sun.tools .javac.tre e.JCTree.* ;
  36   import com .sun.tools .javac.tre e.JCTree.J CPolyExpre ssion.*;
  37   import com .sun.tools .javac.uti l.*;
  38  
  39   import com .sun.tools .javac.uti l.JCDiagno stic.Diagn osticPosit ion;
  40   import sta tic com.su n.tools.ja vac.code.F lags.*;
  41   import sta tic com.su n.tools.ja vac.code.T ypeTag.BOT ;
  42   import sta tic com.su n.tools.ja vac.tree.J CTree.Tag. *;
  43   import sta tic com.su n.tools.ja vac.tree.J CTree.Tag. BLOCK;
  44   import sta tic com.su n.tools.ja vac.tree.J CTree.Tag. SYNCHRONIZ ED;
  45  
  46   /** Utilit y class co ntaining i nspector m ethods for  trees.
  47    *
  48    *  <p><b> This is NO T part of  any suppor ted API.
  49    *  If you  write cod e that dep ends on th is, you do  so at you r own risk .
  50    *  This c ode and it s internal  interface s are subj ect to cha nge or
  51    *  deleti on without  notice.</ b>
  52    */
  53   public cla ss TreeInf o {
  54       protec ted static  final Con text.Key<T reeInfo> t reeInfoKey  =
  55           ne w Context. Key<TreeIn fo>();
  56  
  57       public  static Tr eeInfo ins tance(Cont ext contex t) {
  58           Tr eeInfo ins tance = co ntext.get( treeInfoKe y);
  59           if  (instance  == null)
  60                instance  = new Tre eInfo(cont ext);
  61           re turn insta nce;
  62       }
  63  
  64       /** Th e names of  all opera tors.
  65        */
  66       privat e Name[] o pname = ne w Name[Tag .getNumber OfOperator s()];
  67  
  68       privat e void set Opname(Tag  tag, Stri ng name, N ames names ) {
  69            s etOpname(t ag, names. fromString (name));
  70        }
  71        priva te void se tOpname(Ta g tag, Nam e name) {
  72            o pname[tag. operatorIn dex()] = n ame;
  73        }
  74  
  75       privat e TreeInfo (Context c ontext) {
  76           co ntext.put( treeInfoKe y, this);
  77  
  78           Na mes names  = Names.in stance(con text);
  79           /*   Internal ly we use  +++, --- f or unary + , - to red uce +, - o perators
  80            *   overload ing
  81            * /
  82           se tOpname(PO S, "+++",  names);
  83           se tOpname(NE G, "---",  names);
  84           se tOpname(NO T, "!", na mes);
  85           se tOpname(CO MPL, "~",  names);
  86           se tOpname(PR EINC, "++" , names);
  87           se tOpname(PR EDEC, "--" , names);
  88           se tOpname(PO STINC, "++ ", names);
  89           se tOpname(PO STDEC, "-- ", names);
  90           se tOpname(NU LLCHK, "<* nullchk*>" , names);
  91           se tOpname(OR , "||", na mes);
  92           se tOpname(AN D, "&&", n ames);
  93           se tOpname(EQ , "==", na mes);
  94           se tOpname(NE , "!=", na mes);
  95           se tOpname(LT , "<", nam es);
  96           se tOpname(GT , ">", nam es);
  97           se tOpname(LE , "<=", na mes);
  98           se tOpname(GE , ">=", na mes);
  99           se tOpname(BI TOR, "|",  names);
  100           se tOpname(BI TXOR, "^",  names);
  101           se tOpname(BI TAND, "&",  names);
  102           se tOpname(SL , "<<", na mes);
  103           se tOpname(SR , ">>", na mes);
  104           se tOpname(US R, ">>>",  names);
  105           se tOpname(PL US, "+", n ames);
  106           se tOpname(MI NUS, names .hyphen);
  107           se tOpname(MU L, names.a sterisk);
  108           se tOpname(DI V, names.s lash);
  109           se tOpname(MO D, "%", na mes);
  110       }
  111  
  112       public  static Li st<JCExpre ssion> arg s(JCTree t ) {
  113           sw itch (t.ge tTag()) {
  114                case APP LY:
  115                    retu rn ((JCMet hodInvocat ion)t).arg s;
  116                case NEW CLASS:
  117                    retu rn ((JCNew Class)t).a rgs;
  118                default:
  119                    retu rn null;
  120           }
  121       }
  122  
  123       /** Re turn name  of operato r with giv en tree ta g.
  124        */
  125       public  Name oper atorName(J CTree.Tag  tag) {
  126           re turn opnam e[tag.oper atorIndex( )];
  127       }
  128  
  129       /** Is  tree a co nstructor  declaratio n?
  130        */
  131       public  static bo olean isCo nstructor( JCTree tre e) {
  132           if  (tree.has Tag(METHOD DEF)) {
  133                Name nam e = ((JCMe thodDecl)  tree).name ;
  134                return n ame == nam e.table.na mes.init;
  135           }  else {
  136                return f alse;
  137           }
  138       }
  139  
  140       public  static bo olean isRe ceiverPara m(JCTree t ree) {
  141             if (tree.h asTag(
D NS    F)) {
  142                return ( (JCVariabl eDecl)tree ).nameexpr  != null;
  143           }  else {
  144                return f alse;
  145           }
  146       }
  147  
  148       /** Is  there a c onstructor  declarati on in the  given list  of trees?
  149        */
  150       public  static bo olean hasC onstructor s(List<JCT ree> trees ) {
  151           fo r (List<JC Tree> l =  trees; l.n onEmpty();  l = l.tai l)
  152                if (isCo nstructor( l.head)) r eturn true ;
  153           re turn false ;
  154       }
  155  
  156       public  static bo olean isMu ltiCatch(J CCatch cat chClause)  {
  157           re turn catch Clause.par am.vartype .hasTag(TY PEUNION);
  158       }
  159  
  160       /** Is  statement  an initia lizer for  a syntheti c field?
  161        */
  162       public  static bo olean isSy ntheticIni t(JCTree s tat) {
  163           if  (stat.has Tag(EXEC))  {
  164                JCExpres sionStatem ent exec =  (JCExpres sionStatem ent)stat;
  165                if (exec .expr.hasT ag(ASSIGN) ) {
  166                    JCAs sign assig n = (JCAss ign)exec.e xpr;
  167                    if ( assign.lhs .hasTag(SE LECT)) {
  168                         JCFieldAcc ess select  = (JCFiel dAccess)as sign.lhs;
  169                         if (select .sym != nu ll &&
  170                             (selec t.sym.flag s() & SYNT HETIC) !=  0) {
  171                             Name s elected =  name(selec t.selected );
  172                             if (se lected !=  null && se lected ==  selected.t able.names ._this)
  173                                 re turn true;
  174                         }
  175                    }
  176                }
  177           }
  178           re turn false ;
  179       }
  180  
  181       /** If  the expre ssion is a  method ca ll, return  the metho d name, nu ll
  182        *  ot herwise. * /
  183       public  static Na me calledM ethodName( JCTree tre e) {
  184           if  (tree.has Tag(EXEC))  {
  185                JCExpres sionStatem ent exec =  (JCExpres sionStatem ent)tree;
  186                if (exec .expr.hasT ag(APPLY))  {
  187                    Name  mname = T reeInfo.na me(((JCMet hodInvocat ion) exec. expr).meth );
  188                    retu rn mname;
  189                }
  190           }
  191           re turn null;
  192       }
  193  
  194       /** Is  this a ca ll to this  or super?
  195        */
  196       public  static bo olean isSe lfCall(JCT ree tree)  {
  197           Na me name =  calledMeth odName(tre e);
  198           if  (name !=  null) {
  199                Names na mes = name .table.nam es;
  200                return n ame==names ._this ||  name==name s._super;
  201           }  else {
  202                return f alse;
  203           }
  204       }
  205  
  206       /** Is  this a ca ll to supe r?
  207        */
  208       public  static bo olean isSu perCall(JC Tree tree)  {
  209           Na me name =  calledMeth odName(tre e);
  210           if  (name !=  null) {
  211                Names na mes = name .table.nam es;
  212                return n ame==names ._super;
  213           }  else {
  214                return f alse;
  215           }
  216       }
  217  
  218       /** Is  this a co nstructor  whose firs t (non-syn thetic) st atement is  not
  219        *  of  the form  this(...)?
  220        */
  221       public  static bo olean isIn itialConst ructor(JCT ree tree)  {
  222           JC MethodInvo cation app  = firstCo nstructorC all(tree);
  223           if  (app == n ull) retur n false;
  224           Na me meth =  name(app.m eth);
  225           re turn meth  == null ||  meth != m eth.table. names._thi s;
  226       }
  227  
  228       /** Re turn the f irst call  in a const ructor def inition. * /
  229       public  static JC MethodInvo cation fir stConstruc torCall(JC Tree tree)  {
  230           if  (!tree.ha sTag(METHO DDEF)) ret urn null;
  231           JC MethodDecl  md = (JCM ethodDecl)  tree;
  232           Na mes names  = md.name. table.name s;
  233           if  (md.name  != names.i nit) retur n null;
  234           if  (md.body  == null) r eturn null ;
  235           Li st<JCState ment> stat s = md.bod y.stats;
  236           //  Synthetic  initializ ations can  appear be fore the s uper call.
  237           wh ile (stats .nonEmpty( ) && isSyn theticInit (stats.hea d))
  238                stats =  stats.tail ;
  239           if  (stats.is Empty()) r eturn null ;
  240           if  (!stats.h ead.hasTag (EXEC)) re turn null;
  241           JC Expression Statement  exec = (JC Expression Statement)  stats.hea d;
  242           if  (!exec.ex pr.hasTag( APPLY)) re turn null;
  243           re turn (JCMe thodInvoca tion)exec. expr;
  244       }
  245  
  246       /** Re turn true  if a tree  represents  a diamond  new expr.  */
  247       public  static bo olean isDi amond(JCTr ee tree) {
  248           sw itch(tree. getTag())  {
  249                case TYP EAPPLY: re turn ((JCT ypeApply)t ree).getTy peArgument s().isEmpt y();
  250                case NEW CLASS: ret urn isDiam ond(((JCNe wClass)tre e).clazz);
  251                case ANN OTATED_TYP E: return  isDiamond( ((JCAnnota tedType)tr ee).underl yingType);
  252                default:  return fa lse;
  253           }
  254       }
  255  
  256       public  static bo olean isEn umInit(JCT ree tree)  {
  257           sw itch (tree .getTag())  {
  258                  case 
D NS    F:
  259                    retu rn (((JCVa riableDecl )tree).mod s.flags &  ENUM) != 0 ;
  260                default:
  261                    retu rn false;
  262           }
  263       }
  264  
  265       /** se t 'polyKin d' on give n tree */
  266       public  static vo id setPoly Kind(JCTre e tree, Po lyKind pki nd) {
  267           sw itch (tree .getTag())  {
  268                case APP LY:
  269                    ((JC MethodInvo cation)tre e).polyKin d = pkind;
  270                    brea k;
  271                case NEW CLASS:
  272                    ((JC NewClass)t ree).polyK ind = pkin d;
  273                    brea k;
  274                case REF ERENCE:
  275                    ((JC MemberRefe rence)tree ).refPolyK ind = pkin d;
  276                    brea k;
  277                default:
  278                    thro w new Asse rtionError ("Unexpect ed tree: "  + tree);
  279           }
  280       }
  281  
  282       /** se t 'varargs Element' o n given tr ee */
  283       public  static vo id setVara rgsElement (JCTree tr ee, Type v arargsElem ent) {
  284           sw itch (tree .getTag())  {
  285                case APP LY:
  286                    ((JC MethodInvo cation)tre e).varargs Element =  varargsEle ment;
  287                    brea k;
  288                case NEW CLASS:
  289                    ((JC NewClass)t ree).varar gsElement  = varargsE lement;
  290                    brea k;
  291                case REF ERENCE:
  292                    ((JC MemberRefe rence)tree ).varargsE lement = v arargsElem ent;
  293                    brea k;
  294                default:
  295                    thro w new Asse rtionError ("Unexpect ed tree: "  + tree);
  296           }
  297       }
  298  
  299       /** Re turn true  if the tre e correspo nds to an  expression  statement  */
  300       public  static bo olean isEx pressionSt atement(JC Expression  tree) {
  301           sw itch(tree. getTag())  {
  302                case PRE INC: case  PREDEC:
  303                case POS TINC: case  POSTDEC:
  304                case ASS IGN:
  305                case BIT OR_ASG: ca se BITXOR_ ASG: case  BITAND_ASG :
  306                case SL_ ASG: case  SR_ASG: ca se USR_ASG :
  307                case PLU S_ASG: cas e MINUS_AS G:
  308                case MUL _ASG: case  DIV_ASG:  case MOD_A SG:
  309                case APP LY: case N EWCLASS:
  310                case ERR ONEOUS:
  311                    retu rn true;
  312                default:
  313                    retu rn false;
  314           }
  315       }
  316  
  317       /**
  318        * Ret urn true i f the AST  correspond s to a sta tic select  of the ki nd A.B
  319        */
  320       public  static bo olean isSt aticSelect or(JCTree  base, Name s names) {
  321           if  (base ==  null)
  322                return f alse;
  323           sw itch (base .getTag())  {
  324                case IDE NT:
  325                    JCId ent id = ( JCIdent)ba se;
  326                    retu rn id.name  != names. _this &&
  327                             id.nam e != names ._super &&
  328                             isStat icSym(base );
  329                case SEL ECT:
  330                    retu rn isStati cSym(base)  &&
  331                         isStaticSe lector(((J CFieldAcce ss)base).s elected, n ames);
  332                case TYP EAPPLY:
  333                case TYP EARRAY:
  334                    retu rn true;
  335                case ANN OTATED_TYP E:
  336                    retu rn isStati cSelector( ((JCAnnota tedType)ba se).underl yingType,  names);
  337                default:
  338                    retu rn false;
  339           }
  340       }
  341       //wher e
  342           pr ivate stat ic boolean  isStaticS ym(JCTree  tree) {
  343                Symbol s ym = symbo l(tree);
  344                return ( sym.kind = = Kinds.TY P ||
  345                         sym.kind = = Kinds.PC K);
  346           }
  347  
  348       /** Re turn true  if a tree  represents  the null  literal. * /
  349       public  static bo olean isNu ll(JCTree  tree) {
  350           if  (!tree.ha sTag(LITER AL))
  351                return f alse;
  352           JC Literal li t = (JCLit eral) tree ;
  353           re turn (lit. typetag ==  BOT);
  354       }
  355  
  356       /** Re turn true  iff this t ree is a c hild of so me annotat ion. */
  357       public  static bo olean isIn Annotation (Env<?> en v, JCTree  tree) {
  358           Tr eePath tp  = TreePath .getPath(e nv.topleve l, tree);
  359           if  (tp != nu ll) {
  360                for (Tre e t : tp)  {
  361                    if ( t.getKind( ) == Tree. Kind.ANNOT ATION)
  362                         return tru e;
  363                }
  364           }
  365           re turn false ;
  366       }
  367  
  368       public  static St ring getCo mmentText( Env<?> env , JCTree t ree) {
  369           Do cCommentTa ble docCom ments = (t ree.hasTag (JCTree.Ta g.TOPLEVEL ))
  370                    ? (( JCCompilat ionUnit) t ree).docCo mments
  371                    : en v.toplevel .docCommen ts;
  372           re turn (docC omments ==  null) ? n ull : docC omments.ge tCommentTe xt(tree);
  373       }
  374  
  375       public  static DC Tree.DCDoc Comment ge tCommentTr ee(Env<?>  env, JCTre e tree) {
  376           Do cCommentTa ble docCom ments = (t ree.hasTag (JCTree.Ta g.TOPLEVEL ))
  377                    ? (( JCCompilat ionUnit) t ree).docCo mments
  378                    : en v.toplevel .docCommen ts;
  379           re turn (docC omments ==  null) ? n ull : docC omments.ge tCommentTr ee(tree);
  380       }
  381  
  382       /** Th e position  of the fi rst statem ent in a b lock, or t he positio n of
  383        *  th e block it self if it  is empty.
  384        */
  385       public  static in t firstSta tPos(JCTre e tree) {
  386           if  (tree.has Tag(BLOCK)  && ((JCBl ock) tree) .stats.non Empty())
  387                return ( (JCBlock)  tree).stat s.head.pos ;
  388           el se
  389                return t ree.pos;
  390       }
  391  
  392       /** Th e end posi tion of gi ven tree,  if it is a  block wit h
  393        *  de fined endp os.
  394        */
  395       public  static in t endPos(J CTree tree ) {
  396           if  (tree.has Tag(BLOCK)  && ((JCBl ock) tree) .endpos !=  Position. NOPOS)
  397                return ( (JCBlock)  tree).endp os;
  398           el se if (tre e.hasTag(S YNCHRONIZE D))
  399                return e ndPos(((JC Synchroniz ed) tree). body);
  400           el se if (tre e.hasTag(T RY)) {
  401                JCTry t  = (JCTry)  tree;
  402                return e ndPos((t.f inalizer ! = null) ?  t.finalize r
  403                               : (t .catchers. nonEmpty()  ? t.catch ers.last() .body : t. body));
  404           }  else
  405                return t ree.pos;
  406       }
  407  
  408  
  409       /** Ge t the star t position  for a tre e node.  T he start p osition is
  410        * def ined to be  the posit ion of the  first cha racter of  the first
  411        * tok en of the  node's sou rce text.
  412        * @pa ram tree   The tree n ode
  413        */
  414       public  static in t getStart Pos(JCTree  tree) {
  415           if  (tree ==  null)
  416                return P osition.NO POS;
  417  
  418           sw itch(tree. getTag())  {
  419                case APP LY:
  420                    retu rn getStar tPos(((JCM ethodInvoc ation) tre e).meth);
  421                case ASS IGN:
  422                    retu rn getStar tPos(((JCA ssign) tre e).lhs);
  423                case BIT OR_ASG: ca se BITXOR_ ASG: case  BITAND_ASG :
  424                case SL_ ASG: case  SR_ASG: ca se USR_ASG :
  425                case PLU S_ASG: cas e MINUS_AS G: case MU L_ASG:
  426                case DIV _ASG: case  MOD_ASG:
  427                    retu rn getStar tPos(((JCA ssignOp) t ree).lhs);
  428                case OR:  case AND:  case BITO R:
  429                case BIT XOR: case  BITAND: ca se EQ:
  430                case NE:  case LT:  case GT:
  431                case LE:  case GE:  case SL:
  432                case SR:  case USR:  case PLUS :
  433                case MIN US: case M UL: case D IV:
  434                case MOD :
  435                    retu rn getStar tPos(((JCB inary) tre e).lhs);
  436                case CLA SSDEF: {
  437                    JCCl assDecl no de = (JCCl assDecl)tr ee;
  438                    if ( node.mods. pos != Pos ition.NOPO S)
  439                         return nod e.mods.pos ;
  440                    brea k;
  441                }
  442                case CON DEXPR:
  443                    retu rn getStar tPos(((JCC onditional ) tree).co nd);
  444                case EXE C:
  445                    retu rn getStar tPos(((JCE xpressionS tatement)  tree).expr );
  446                case IND EXED:
  447                    retu rn getStar tPos(((JCA rrayAccess ) tree).in dexed);
  448                case MET HODDEF: {
  449                    JCMe thodDecl n ode = (JCM ethodDecl) tree;
  450                    if ( node.mods. pos != Pos ition.NOPO S)
  451                         return nod e.mods.pos ;
  452                    if ( node.typar ams.nonEmp ty()) // L ist.nil()  used for n o typarams
  453                         return get StartPos(n ode.typara ms.head);
  454                    retu rn node.re stype == n ull ? node .pos : get StartPos(n ode.restyp e);
  455                }
  456                case SEL ECT:
  457                    retu rn getStar tPos(((JCF ieldAccess ) tree).se lected);
  458                case TYP EAPPLY:
  459                    retu rn getStar tPos(((JCT ypeApply)  tree).claz z);
  460                case TYP EARRAY:
  461                    retu rn getStar tPos(((JCA rrayTypeTr ee) tree). elemtype);
  462                case TYP ETEST:
  463                    retu rn getStar tPos(((JCI nstanceOf)  tree).exp r);
  464                case POS TINC:
  465                case POS TDEC:
  466                    retu rn getStar tPos(((JCU nary) tree ).arg);
  467                case ANN OTATED_TYP E: {
  468                    JCAn notatedTyp e node = ( JCAnnotate dType) tre e;
  469                    if ( node.annot ations.non Empty()) {
  470                         if (node.u nderlyingT ype.hasTag (TYPEARRAY ) ||
  471                                 no de.underly ingType.ha sTag(SELEC T)) {
  472                             return  getStartP os(node.un derlyingTy pe);
  473                         } else {
  474                             return  getStartP os(node.an notations. head);
  475                         }
  476                    } el se {
  477                         return get StartPos(n ode.underl yingType);
  478                    }
  479                }
  480                case NEW CLASS: {
  481                    JCNe wClass nod e = (JCNew Class)tree ;
  482                    if ( node.encl  != null)
  483                         return get StartPos(n ode.encl);
  484                    brea k;
  485                }
  486                  case 
D NS    F: {
  487                    JCVa riableDecl  node = (J CVariableD ecl)tree;
  488                    if ( node.mods. pos != Pos ition.NOPO S) {
  489                         return nod e.mods.pos ;
  490                    } el se if (nod e.vartype  == null) {
  491                         //if there 's no type  (partiall y typed la mbda param eter)
  492                         //simply r eturn node  position
  493                         return nod e.pos;
  494                    } el se {
  495                         return get StartPos(n ode.vartyp e);
  496                    }
  497                }
  498                case ERR ONEOUS: {
  499                    JCEr roneous no de = (JCEr roneous)tr ee;
  500                    if ( node.errs  != null &&  node.errs .nonEmpty( ))
  501                         return get StartPos(n ode.errs.h ead);
  502                }
  503           }
  504           re turn tree. pos;
  505       }
  506  
  507       /** Th e end posi tion of gi ven tree,  given  a t able of en d position s generate d by the p arser
  508        */
  509       public  static in t getEndPo s(JCTree t ree, EndPo sTable end PosTable)  {
  510           if  (tree ==  null)
  511                return P osition.NO POS;
  512  
  513           if  (endPosTa ble == nul l) {
  514                // fall  back on li mited info  in the tr ee
  515                return e ndPos(tree );
  516           }
  517  
  518           in t mapPos =  endPosTab le.getEndP os(tree);
  519           if  (mapPos ! = Position .NOPOS)
  520                return m apPos;
  521  
  522           sw itch(tree. getTag())  {
  523                case BIT OR_ASG: ca se BITXOR_ ASG: case  BITAND_ASG :
  524                case SL_ ASG: case  SR_ASG: ca se USR_ASG :
  525                case PLU S_ASG: cas e MINUS_AS G: case MU L_ASG:
  526                case DIV _ASG: case  MOD_ASG:
  527                    retu rn getEndP os(((JCAss ignOp) tre e).rhs, en dPosTable) ;
  528                case OR:  case AND:  case BITO R:
  529                case BIT XOR: case  BITAND: ca se EQ:
  530                case NE:  case LT:  case GT:
  531                case LE:  case GE:  case SL:
  532                case SR:  case USR:  case PLUS :
  533                case MIN US: case M UL: case D IV:
  534                case MOD :
  535                    retu rn getEndP os(((JCBin ary) tree) .rhs, endP osTable);
  536                case CAS E:
  537                    retu rn getEndP os(((JCCas e) tree).s tats.last( ), endPosT able);
  538                case CAT CH:
  539                    retu rn getEndP os(((JCCat ch) tree). body, endP osTable);
  540                case CON DEXPR:
  541                    retu rn getEndP os(((JCCon ditional)  tree).fals epart, end PosTable);
  542                case FOR LOOP:
  543                    retu rn getEndP os(((JCFor Loop) tree ).body, en dPosTable) ;
  544                case FOR EACHLOOP:
  545                    retu rn getEndP os(((JCEnh ancedForLo op) tree). body, endP osTable);
  546                case IF:  {
  547                    JCIf  node = (J CIf)tree;
  548                    if ( node.elsep art == nul l) {
  549                         return get EndPos(nod e.thenpart , endPosTa ble);
  550                    } el se {
  551                         return get EndPos(nod e.elsepart , endPosTa ble);
  552                    }
  553                }
  554                case LAB ELLED:
  555                    retu rn getEndP os(((JCLab eledStatem ent) tree) .body, end PosTable);
  556                case MOD IFIERS:
  557                    retu rn getEndP os(((JCMod ifiers) tr ee).annota tions.last (), endPos Table);
  558                case SYN CHRONIZED:
  559                    retu rn getEndP os(((JCSyn chronized)  tree).bod y, endPosT able);
  560                case TOP LEVEL:
  561                    retu rn getEndP os(((JCCom pilationUn it) tree). defs.last( ), endPosT able);
  562                case TRY : {
  563                    JCTr y node = ( JCTry)tree ;
  564                    if ( node.final izer != nu ll) {
  565                         return get EndPos(nod e.finalize r, endPosT able);
  566                    } el se if (!no de.catcher s.isEmpty( )) {
  567                         return get EndPos(nod e.catchers .last(), e ndPosTable );
  568                    } el se {
  569                         return get EndPos(nod e.body, en dPosTable) ;
  570                    }
  571                }
  572                case WIL DCARD:
  573                    retu rn getEndP os(((JCWil dcard) tre e).inner,  endPosTabl e);
  574                case TYP ECAST:
  575                    retu rn getEndP os(((JCTyp eCast) tre e).expr, e ndPosTable );
  576                case TYP ETEST:
  577                    retu rn getEndP os(((JCIns tanceOf) t ree).clazz , endPosTa ble);
  578                case POS :
  579                case NEG :
  580                case NOT :
  581                case COM PL:
  582                case PRE INC:
  583                case PRE DEC:
  584                    retu rn getEndP os(((JCUna ry) tree). arg, endPo sTable);
  585                case WHI LELOOP:
  586                    retu rn getEndP os(((JCWhi leLoop) tr ee).body,  endPosTabl e);
  587                case ANN OTATED_TYP E:
  588                    retu rn getEndP os(((JCAnn otatedType ) tree).un derlyingTy pe, endPos Table);
  589                case ERR ONEOUS: {
  590                    JCEr roneous no de = (JCEr roneous)tr ee;
  591                    if ( node.errs  != null &&  node.errs .nonEmpty( ))
  592                         return get EndPos(nod e.errs.las t(), endPo sTable);
  593                }
  594           }
  595           re turn Posit ion.NOPOS;
  596       }
  597  
  598  
  599       /** A  Diagnostic Position w ith the pr eferred po sition set  to the
  600        *  en d position  of given  tree, if i t is a blo ck with
  601        *  de fined endp os.
  602        */
  603       public  static Di agnosticPo sition dia gEndPos(fi nal JCTree  tree) {
  604           fi nal int en dPos = Tre eInfo.endP os(tree);
  605           re turn new D iagnosticP osition()  {
  606                public J CTree getT ree() { re turn tree;  }
  607                public i nt getStar tPosition( ) { return  TreeInfo. getStartPo s(tree); }
  608                public i nt getPref erredPosit ion() { re turn endPo s; }
  609                public i nt getEndP osition(En dPosTable  endPosTabl e) {
  610                    retu rn TreeInf o.getEndPo s(tree, en dPosTable) ;
  611                }
  612           };
  613       }
  614  
  615       public  enum PosK ind {
  616           ST ART_POS()  { int  toP os(JCTree  tree) { re turn TreeI nfo.getSta rtPos(tree ); } },
  617           FI RST_STAT_P OS() { int   toPos(JC Tree tree)  { return  firstStatP os(tree);  } },
  618           EN D_POS() {  int  toPos (JCTree tr ee) { retu rn endPos( tree); } } ;
  619  
  620           ab stract int  toPos(JCT ree tree);
  621       }
  622  
  623       /** Th e position  of the fi nalizer of  given try /synchroni zed statem ent.
  624        */
  625       public  static in t finalize rPos(JCTre e tree, Po sKind posK ind) {
  626           if  (tree.has Tag(TRY))  {
  627                JCTry t  = (JCTry)  tree;
  628                Assert.c heckNonNul l(t.finali zer);
  629                return p osKind.toP os(t.final izer);
  630           }  else if (t ree.hasTag (SYNCHRONI ZED)) {
  631                return e ndPos(((JC Synchroniz ed) tree). body);
  632           }  else {
  633                throw ne w Assertio nError();
  634           }
  635       }
  636  
  637       /** Fi nd the pos ition for  reporting  an error a bout a sym bol, where
  638        *  th at symbol  is defined  somewhere  in the gi ven tree.  */
  639       public  static in t position For(final  Symbol sym , final JC Tree tree)  {
  640           JC Tree decl  = declarat ionFor(sym , tree);
  641           re turn ((dec l != null)  ? decl :  tree).pos;
  642       }
  643  
  644       /** Fi nd the pos ition for  reporting  an error a bout a sym bol, where
  645        *  th at symbol  is defined  somewhere  in the gi ven tree.  */
  646       public  static Di agnosticPo sition dia gnosticPos itionFor(f inal Symbo l sym, fin al JCTree  tree) {
  647           JC Tree decl  = declarat ionFor(sym , tree);
  648           re turn ((dec l != null)  ? decl :  tree).pos( );
  649       }
  650  
  651       /** Fi nd the dec laration f or a symbo l, where
  652        *  th at symbol  is defined  somewhere  in the gi ven tree.  */
  653       public  static JC Tree decla rationFor( final Symb ol sym, fi nal JCTree  tree) {
  654           cl ass DeclSc anner exte nds TreeSc anner {
  655                JCTree r esult = nu ll;
  656                public v oid scan(J CTree tree ) {
  657                    if ( tree!=null  && result ==null)
  658                         tree.accep t(this);
  659                }
  660                public v oid visitT opLevel(JC Compilatio nUnit that ) {
  661                    if ( that.packg e == sym)  result = t hat;
  662                    else  super.vis itTopLevel (that);
  663                }
  664                public v oid visitC lassDef(JC ClassDecl  that) {
  665                    if ( that.sym = = sym) res ult = that ;
  666                    else  super.vis itClassDef (that);
  667                }
  668                public v oid visitM ethodDef(J CMethodDec l that) {
  669                    if ( that.sym = = sym) res ult = that ;
  670                    else  super.vis itMethodDe f(that);
  671                }
  672                public v oid visitV arDef(JCVa riableDecl  that) {
  673                    if ( that.sym = = sym) res ult = that ;
  674                    else  super.vis itVarDef(t hat);
  675                }
  676                public v oid visitT ypeParamet er(JCTypeP arameter t hat) {
  677                    if ( that.type  != null &&  that.type .tsym == s ym) result  = that;
  678                    else  super.vis itTypePara meter(that );
  679                }
  680           }
  681           De clScanner  s = new De clScanner( );
  682           tr ee.accept( s);
  683           re turn s.res ult;
  684       }
  685  
  686       public  static En v<AttrCont ext> scope For(JCTree  node, JCC ompilation Unit unit)  {
  687           re turn scope For(pathFo r(node, un it));
  688       }
  689  
  690       public  static En v<AttrCont ext> scope For(List<J CTree> pat h) {
  691           //  TODO: not  implement ed yet
  692           th row new Un supportedO perationEx ception("n ot impleme nted yet") ;
  693       }
  694  
  695       public  static Li st<JCTree>  pathFor(f inal JCTre e node, fi nal JCComp ilationUni t unit) {
  696           cl ass Result  extends E rror {
  697                static f inal long  serialVers ionUID = - 5942088234 594905625L ;
  698                List<JCT ree> path;
  699                Result(L ist<JCTree > path) {
  700                    this .path = pa th;
  701                }
  702           }
  703           cl ass PathFi nder exten ds TreeSca nner {
  704                List<JCT ree> path  = List.nil ();
  705                public v oid scan(J CTree tree ) {
  706                    if ( tree != nu ll) {
  707                         path = pat h.prepend( tree);
  708                         if (tree = = node)
  709                             throw  new Result (path);
  710                         super.scan (tree);
  711                         path = pat h.tail;
  712                    }
  713                }
  714           }
  715           tr y {
  716                new Path Finder().s can(unit);
  717           }  catch (Res ult result ) {
  718                return r esult.path ;
  719           }
  720           re turn List. nil();
  721       }
  722  
  723       /** Re turn the s tatement r eferenced  by a label .
  724        *  If  the label  refers to  a loop or  switch, r eturn that  switch
  725        *  ot herwise re turn the l abelled st atement it self
  726        */
  727       public  static JC Tree refer encedState ment(JCLab eledStatem ent tree)  {
  728           JC Tree t = t ree;
  729           do  t = ((JCL abeledStat ement) t). body;
  730           wh ile (t.has Tag(LABELL ED));
  731           sw itch (t.ge tTag()) {
  732           ca se DOLOOP:  case WHIL ELOOP: cas e FORLOOP:  case FORE ACHLOOP: c ase SWITCH :
  733                return t ;
  734           de fault:
  735                return t ree;
  736           }
  737       }
  738  
  739       /** Sk ip parens  and return  the enclo sed expres sion
  740        */
  741       public  static JC Expression  skipParen s(JCExpres sion tree)  {
  742           wh ile (tree. hasTag(PAR ENS)) {
  743                tree = ( (JCParens)  tree).exp r;
  744           }
  745           re turn tree;
  746       }
  747  
  748       /** Sk ip parens  and return  the enclo sed expres sion
  749        */
  750       public  static JC Tree skipP arens(JCTr ee tree) {
  751           if  (tree.has Tag(PARENS ))
  752                return s kipParens( (JCParens) tree);
  753           el se
  754                return t ree;
  755       }
  756  
  757       /** Re turn the t ypes of a  list of tr ees.
  758        */
  759       public  static Li st<Type> t ypes(List< ? extends  JCTree> tr ees) {
  760           Li stBuffer<T ype> ts =  new ListBu ffer<Type> ();
  761           fo r (List<?  extends JC Tree> l =  trees; l.n onEmpty();  l = l.tai l)
  762                ts.appen d(l.head.t ype);
  763           re turn ts.to List();
  764       }
  765  
  766       /** If  this tree  is an ide ntifier or  a field o r a parame terized ty pe,
  767        *  re turn its n ame, other wise retur n null.
  768        */
  769       public  static Na me name(JC Tree tree)  {
  770           sw itch (tree .getTag())  {
  771           ca se IDENT:
  772                return ( (JCIdent)  tree).name ;
  773           ca se SELECT:
  774                return ( (JCFieldAc cess) tree ).name;
  775           ca se TYPEAPP LY:
  776                return n ame(((JCTy peApply) t ree).clazz );
  777           de fault:
  778                return n ull;
  779           }
  780       }
  781  
  782       /** If  this tree  is a qual ified iden tifier, it s return f ully quali fied name,
  783        *  ot herwise re turn null.
  784        */
  785       public  static Na me fullNam e(JCTree t ree) {
  786           tr ee = skipP arens(tree );
  787           sw itch (tree .getTag())  {
  788           ca se IDENT:
  789                return ( (JCIdent)  tree).name ;
  790           ca se SELECT:
  791                Name sna me = fullN ame(((JCFi eldAccess)  tree).sel ected);
  792                return s name == nu ll ? null  : sname.ap pend('.',  name(tree) );
  793           de fault:
  794                return n ull;
  795           }
  796       }
  797  
  798       public  static Sy mbol symbo lFor(JCTre e node) {
  799           Sy mbol sym =  symbolFor Impl(node) ;
  800  
  801           re turn sym ! = null ? s ym.baseSym bol() : nu ll;
  802       }
  803  
  804       privat e static S ymbol symb olForImpl( JCTree nod e) {
  805           no de = skipP arens(node );
  806           sw itch (node .getTag())  {
  807           ca se TOPLEVE L:
  808                return ( (JCCompila tionUnit)  node).pack ge;
  809           ca se CLASSDE F:
  810                return ( (JCClassDe cl) node). sym;
  811           ca se METHODD EF:
  812                return ( (JCMethodD ecl) node) .sym;
  813             case 
D NS    F:
  814                return ( (JCVariabl eDecl) nod e).sym;
  815           ca se IDENT:
  816                return ( (JCIdent)  node).sym;
  817           ca se SELECT:
  818                return ( (JCFieldAc cess) node ).sym;
  819           ca se REFEREN CE:
  820                return ( (JCMemberR eference)  node).sym;
  821           ca se NEWCLAS S:
  822                return ( (JCNewClas s) node).c onstructor ;
  823           ca se APPLY:
  824                return s ymbolFor(( (JCMethodI nvocation)  node).met h);
  825           ca se TYPEAPP LY:
  826                return s ymbolFor(( (JCTypeApp ly) node). clazz);
  827           ca se ANNOTAT ION:
  828           ca se TYPE_AN NOTATION:
  829           ca se TYPEPAR AMETER:
  830                if (node .type != n ull)
  831                    retu rn node.ty pe.tsym;
  832                return n ull;
  833           de fault:
  834                return n ull;
  835           }
  836       }
  837  
  838       public  static bo olean isDe claration( JCTree nod e) {
  839           no de = skipP arens(node );
  840           sw itch (node .getTag())  {
  841           ca se CLASSDE F:
  842           ca se METHODD EF:
  843             case 
D NS    F:
  844                return t rue;
  845           de fault:
  846                return f alse;
  847           }
  848       }
  849  
  850       /** If  this tree  is an ide ntifier or  a field,  return its  symbol,
  851        *  ot herwise re turn null.
  852        */
  853       public  static Sy mbol symbo l(JCTree t ree) {
  854           tr ee = skipP arens(tree );
  855           sw itch (tree .getTag())  {
  856           ca se IDENT:
  857                return ( (JCIdent)  tree).sym;
  858           ca se SELECT:
  859                return ( (JCFieldAc cess) tree ).sym;
  860           ca se TYPEAPP LY:
  861                return s ymbol(((JC TypeApply)  tree).cla zz);
  862           ca se ANNOTAT ED_TYPE:
  863                return s ymbol(((JC AnnotatedT ype) tree) .underlyin gType);
  864           ca se REFEREN CE:
  865                return ( (JCMemberR eference)  tree).sym;
  866           de fault:
  867                return n ull;
  868           }
  869       }
  870  
  871       /** Re turn true  if this is  a nonstat ic selecti on. */
  872       public  static bo olean nons taticSelec t(JCTree t ree) {
  873           tr ee = skipP arens(tree );
  874           if  (!tree.ha sTag(SELEC T)) return  false;
  875           JC FieldAcces s s = (JCF ieldAccess ) tree;
  876           Sy mbol e = s ymbol(s.se lected);
  877           re turn e ==  null || (e .kind != K inds.PCK & & e.kind ! = Kinds.TY P);
  878       }
  879  
  880       /** If  this tree  is an ide ntifier or  a field,  set its sy mbol, othe rwise skip .
  881        */
  882       public  static vo id setSymb ol(JCTree  tree, Symb ol sym) {
  883           tr ee = skipP arens(tree );
  884           sw itch (tree .getTag())  {
  885           ca se IDENT:
  886                ((JCIden t) tree).s ym = sym;  break;
  887           ca se SELECT:
  888                ((JCFiel dAccess) t ree).sym =  sym; brea k;
  889           de fault:
  890           }
  891       }
  892  
  893       /** If  this tree  is a decl aration or  a block,  return its  flags fie ld,
  894        *  ot herwise re turn 0.
  895        */
  896       public  static lo ng flags(J CTree tree ) {
  897           sw itch (tree .getTag())  {
  898             case 
D NS    F:
  899                return ( (JCVariabl eDecl) tre e).mods.fl ags;
  900           ca se METHODD EF:
  901                return ( (JCMethodD ecl) tree) .mods.flag s;
  902           ca se CLASSDE F:
  903                return ( (JCClassDe cl) tree). mods.flags ;
  904           ca se BLOCK:
  905                return ( (JCBlock)  tree).flag s;
  906           de fault:
  907                return 0 ;
  908           }
  909       }
  910  
  911       /** Re turn first  (smallest ) flag in  `flags':
  912        *  pr e: flags ! = 0
  913        */
  914       public  static lo ng firstFl ag(long fl ags) {
  915           lo ng flag =  1;
  916           wh ile ((flag  & flags &  ExtendedS tandardFla gs) == 0)
  917                flag = f lag << 1;
  918           re turn flag;
  919       }
  920  
  921       /** Re turn flags  as a stri ng, separa ted by " " .
  922        */
  923       public  static St ring flagN ames(long  flags) {
  924           re turn Flags .toString( flags & Ex tendedStan dardFlags) .trim();
  925       }
  926  
  927       /** Op erator pre cedences v alues.
  928        */
  929       public  static fi nal int
  930           no tExpressio n = -1,    // not an  expression
  931           no Prec = 0,             // no encl osing expr ession
  932           as signPrec =  1,
  933           as signopPrec  = 2,
  934           co ndPrec = 3 ,
  935           or Prec = 4,
  936           an dPrec = 5,
  937           bi torPrec =  6,
  938           bi txorPrec =  7,
  939           bi tandPrec =  8,
  940           eq Prec = 9,
  941           or dPrec = 10 ,
  942           sh iftPrec =  11,
  943           ad dPrec = 12 ,
  944           mu lPrec = 13 ,
  945           pr efixPrec =  14,
  946           po stfixPrec  = 15,
  947           pr ecCount =  16;
  948  
  949  
  950       /** Ma p operator s to their  precedenc e levels.
  951        */
  952       public  static in t opPrec(J CTree.Tag  op) {
  953           sw itch(op) {
  954           ca se POS:
  955           ca se NEG:
  956           ca se NOT:
  957           ca se COMPL:
  958           ca se PREINC:
  959           ca se PREDEC:  return pr efixPrec;
  960           ca se POSTINC :
  961           ca se POSTDEC :
  962           ca se NULLCHK : return p ostfixPrec ;
  963           ca se ASSIGN:  return as signPrec;
  964           ca se BITOR_A SG:
  965           ca se BITXOR_ ASG:
  966           ca se BITAND_ ASG:
  967           ca se SL_ASG:
  968           ca se SR_ASG:
  969           ca se USR_ASG :
  970           ca se PLUS_AS G:
  971           ca se MINUS_A SG:
  972           ca se MUL_ASG :
  973           ca se DIV_ASG :
  974           ca se MOD_ASG : return a ssignopPre c;
  975           ca se OR: ret urn orPrec ;
  976           ca se AND: re turn andPr ec;
  977           ca se EQ:
  978           ca se NE: ret urn eqPrec ;
  979           ca se LT:
  980           ca se GT:
  981           ca se LE:
  982           ca se GE: ret urn ordPre c;
  983           ca se BITOR:  return bit orPrec;
  984           ca se BITXOR:  return bi txorPrec;
  985           ca se BITAND:  return bi tandPrec;
  986           ca se SL:
  987           ca se SR:
  988           ca se USR: re turn shift Prec;
  989           ca se PLUS:
  990           ca se MINUS:  return add Prec;
  991           ca se MUL:
  992           ca se DIV:
  993           ca se MOD: re turn mulPr ec;
  994           ca se TYPETES T: return  ordPrec;
  995           de fault: thr ow new Ass ertionErro r();
  996           }
  997       }
  998  
  999       static  Tree.Kind  tagToKind (JCTree.Ta g tag) {
  1000           sw itch (tag)  {
  1001           //  Postfix e xpressions
  1002           ca se POSTINC :            // _ ++
  1003                return T ree.Kind.P OSTFIX_INC REMENT;
  1004           ca se POSTDEC :            // _ --
  1005                return T ree.Kind.P OSTFIX_DEC REMENT;
  1006  
  1007           //  Unary ope rators
  1008           ca se PREINC:              // ++ _
  1009                return T ree.Kind.P REFIX_INCR EMENT;
  1010           ca se PREDEC:              // -- _
  1011                return T ree.Kind.P REFIX_DECR EMENT;
  1012           ca se POS:                 // +
  1013                return T ree.Kind.U NARY_PLUS;
  1014           ca se NEG:                 // -
  1015                return T ree.Kind.U NARY_MINUS ;
  1016           ca se COMPL:               // ~
  1017                return T ree.Kind.B ITWISE_COM PLEMENT;
  1018           ca se NOT:                 // !
  1019                return T ree.Kind.L OGICAL_COM PLEMENT;
  1020  
  1021           //  Binary op erators
  1022  
  1023           //  Multiplic ative oper ators
  1024           ca se MUL:                 // *
  1025                return T ree.Kind.M ULTIPLY;
  1026           ca se DIV:                 // /
  1027                return T ree.Kind.D IVIDE;
  1028           ca se MOD:                 // %
  1029                return T ree.Kind.R EMAINDER;
  1030  
  1031           //  Additive  operators
  1032           ca se PLUS:                // +
  1033                return T ree.Kind.P LUS;
  1034           ca se MINUS:               // -
  1035                return T ree.Kind.M INUS;
  1036  
  1037           //  Shift ope rators
  1038           ca se SL:                  // <<
  1039                return T ree.Kind.L EFT_SHIFT;
  1040           ca se SR:                  // >>
  1041                return T ree.Kind.R IGHT_SHIFT ;
  1042           ca se USR:                 // >>>
  1043                return T ree.Kind.U NSIGNED_RI GHT_SHIFT;
  1044  
  1045           //  Relationa l operator s
  1046           ca se LT:                  // <
  1047                return T ree.Kind.L ESS_THAN;
  1048           ca se GT:                  // >
  1049                return T ree.Kind.G REATER_THA N;
  1050           ca se LE:                  // <=
  1051                return T ree.Kind.L ESS_THAN_E QUAL;
  1052           ca se GE:                  // >=
  1053                return T ree.Kind.G REATER_THA N_EQUAL;
  1054  
  1055           //  Equality  operators
  1056           ca se EQ:                  // ==
  1057                return T ree.Kind.E QUAL_TO;
  1058           ca se NE:                  // !=
  1059                return T ree.Kind.N OT_EQUAL_T O;
  1060  
  1061           //  Bitwise a nd logical  operators
  1062           ca se BITAND:              // &
  1063                return T ree.Kind.A ND;
  1064           ca se BITXOR:              // ^
  1065                return T ree.Kind.X OR;
  1066           ca se BITOR:               // |
  1067                return T ree.Kind.O R;
  1068  
  1069           //  Condition al operato rs
  1070           ca se AND:                 // &&
  1071                return T ree.Kind.C ONDITIONAL _AND;
  1072           ca se OR:                  // ||
  1073                return T ree.Kind.C ONDITIONAL _OR;
  1074  
  1075           //  Assignmen t operator s
  1076           ca se MUL_ASG :            // *=
  1077                return T ree.Kind.M ULTIPLY_AS SIGNMENT;
  1078           ca se DIV_ASG :            // /=
  1079                return T ree.Kind.D IVIDE_ASSI GNMENT;
  1080           ca se MOD_ASG :            // %=
  1081                return T ree.Kind.R EMAINDER_A SSIGNMENT;
  1082           ca se PLUS_AS G:           // +=
  1083                return T ree.Kind.P LUS_ASSIGN MENT;
  1084           ca se MINUS_A SG:          // -=
  1085                return T ree.Kind.M INUS_ASSIG NMENT;
  1086           ca se SL_ASG:              // <<=
  1087                return T ree.Kind.L EFT_SHIFT_ ASSIGNMENT ;
  1088           ca se SR_ASG:              // >>=
  1089                return T ree.Kind.R IGHT_SHIFT _ASSIGNMEN T;
  1090           ca se USR_ASG :            // >>>=
  1091                return T ree.Kind.U NSIGNED_RI GHT_SHIFT_ ASSIGNMENT ;
  1092           ca se BITAND_ ASG:         // &=
  1093                return T ree.Kind.A ND_ASSIGNM ENT;
  1094           ca se BITXOR_ ASG:         // ^=
  1095                return T ree.Kind.X OR_ASSIGNM ENT;
  1096           ca se BITOR_A SG:          // |=
  1097                return T ree.Kind.O R_ASSIGNME NT;
  1098  
  1099           //  Null chec k (impleme ntation de tail), for  example,  __.getClas s()
  1100           ca se NULLCHK :
  1101                return T ree.Kind.O THER;
  1102  
  1103           ca se ANNOTAT ION:
  1104                return T ree.Kind.A NNOTATION;
  1105           ca se TYPE_AN NOTATION:
  1106                return T ree.Kind.T YPE_ANNOTA TION;
  1107  
  1108           de fault:
  1109                return n ull;
  1110           }
  1111       }
  1112  
  1113       /**
  1114        * Ret urns the u nderlying  type of th e tree if  it is an a nnotated t ype,
  1115        * or  the tree i tself othe rwise.
  1116        */
  1117       public  static JC Expression  typeIn(JC Expression  tree) {
  1118           sw itch (tree .getTag())  {
  1119           ca se ANNOTAT ED_TYPE:
  1120                return ( (JCAnnotat edType)tre e).underly ingType;
  1121           ca se IDENT:  /* simple  names */
  1122           ca se TYPEIDE NT: /* pri mitive nam e */
  1123           ca se SELECT:  /* qualif ied name * /
  1124           ca se TYPEARR AY: /* arr ay types * /
  1125           ca se WILDCAR D: /* wild  cards */
  1126           ca se TYPEPAR AMETER: /*  type para meters */
  1127           ca se TYPEAPP LY: /* par ameterized  types */
  1128           ca se ERRONEO US: /* err or tree TO DO: needed  for BadCa st JSR308  test case.  Better wa y? */
  1129                return t ree;
  1130           de fault:
  1131                throw ne w Assertio nError("Un expected t ype tree:  " + tree);
  1132           }
  1133       }
  1134  
  1135       /* Ret urn the in ner-most t ype of a t ype tree.
  1136        * For  an array  that conta ins an ann otated typ e, return  that annot ated type.
  1137        * TOD O: current ly only us ed by Pret ty. Descri be behavio r better.
  1138        */
  1139       public  static JC Tree inner mostType(J CTree type ) {
  1140           JC Tree lastA nnotatedTy pe = null;
  1141           JC Tree cur =  type;
  1142           lo op: while  (true) {
  1143                switch ( cur.getTag ()) {
  1144                case TYP EARRAY:
  1145                    last AnnotatedT ype = null ;
  1146                    cur  = ((JCArra yTypeTree) cur).elemt ype;
  1147                    brea k;
  1148                case WIL DCARD:
  1149                    last AnnotatedT ype = null ;
  1150                    cur  = ((JCWild card)cur). inner;
  1151                    brea k;
  1152                case ANN OTATED_TYP E:
  1153                    last AnnotatedT ype = cur;
  1154                    cur  = ((JCAnno tatedType) cur).under lyingType;
  1155                    brea k;
  1156                default:
  1157                    brea k loop;
  1158                }
  1159           }
  1160           if  (lastAnno tatedType! =null) {
  1161                return l astAnnotat edType;
  1162           }  else {
  1163                return c ur;
  1164           }
  1165       }
  1166  
  1167       privat e static c lass TypeA nnotationF inder exte nds TreeSc anner {
  1168           pu blic boole an foundTy peAnno = f alse;
  1169  
  1170           @O verride
  1171           pu blic void  scan(JCTre e tree) {
  1172                if (foun dTypeAnno  || tree ==  null)
  1173                    retu rn;
  1174                super.sc an(tree);
  1175           }
  1176  
  1177           pu blic void  visitAnnot ation(JCAn notation t ree) {
  1178                foundTyp eAnno = fo undTypeAnn o || tree. hasTag(TYP E_ANNOTATI ON);
  1179           }
  1180       }
  1181  
  1182       public  static bo olean cont ainsTypeAn notation(J CTree e) {
  1183           Ty peAnnotati onFinder f inder = ne w TypeAnno tationFind er();
  1184           fi nder.scan( e);
  1185           re turn finde r.foundTyp eAnno;
  1186       }
  1187   }