1 /* 2 * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.tools.javac.tree; 27 28 import java.util.*; 29 30 import java.io.IOException; 31 import java.io.StringWriter; 32 import javax.lang.model.element.Modifier; 33 import javax.lang.model.type.TypeKind; 34 import javax.tools.JavaFileObject; 35 36 import com.sun.tools.javac.util.*; 37 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 38 import com.sun.tools.javac.util.List; 39 import com.sun.tools.javac.code.*; 40 import com.sun.tools.javac.code.Scope; 41 import com.sun.tools.javac.code.Symbol.*; 42 import com.sun.source.tree.*; 43 44 import static com.sun.tools.javac.code.BoundKind.*; 45 46 /** 47 * Root class for abstract syntax tree nodes. It provides definitions 48 * for specific tree nodes as subclasses nested inside. 49 * 50 * <p>Each subclass is highly standardized. It generally contains 51 * only tree fields for the syntactic subcomponents of the node. Some 52 * classes that represent identifier uses or definitions also define a 53 * Symbol field that denotes the represented identifier. Classes for 54 * non-local jumps also carry the jump target as a field. The root 55 * class Tree itself defines fields for the tree's type and position. 56 * No other fields are kept in a tree node; instead parameters are 57 * passed to methods accessing the node. 58 * 59 * <p>Except for the methods defined by com.sun.source, the only 60 * method defined in subclasses is `visit' which applies a given 61 * visitor to the tree. The actual tree processing is done by visitor 62 * classes in other packages. The abstract class Visitor, as well as 63 * an Factory interface for trees, are defined as inner classes in 64 * Tree. 65 * 66 * <p>To avoid ambiguities with the Tree API in com.sun.source all sub 67 * classes should, by convention, start with JC (javac). 68 * 69 * <p><b>This is NOT part of any supported API. 70 * If you write code that depends on this, you do so at your own risk. 71 * This code and its internal interfaces are subject to change or 72 * deletion without notice.</b> 73 * 74 * @see TreeMaker 75 * @see TreeInfo 76 * @see TreeTranslator 77 * @see Pretty 78 */ 79 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { 80 81 /* Tree tag values, identifying kinds of trees */ 82 83 /** Toplevel nodes, of type TopLevel, representing entire source files. 84 */ 85 public static final int TOPLEVEL = 1; 86 87 /** Import clauses, of type Import. 88 */ 89 public static final int IMPORT = TOPLEVEL + 1; 90 91 /** Class definitions, of type ClassDef. 92 */ 93 public static final int CLASSDEF = IMPORT + 1; 94 95 /** Method definitions, of type MethodDef. 96 */ 97 public static final int METHODDEF = CLASSDEF + 1; 98 99 /** Variable definitions, of type VarDef. 100 */ 101 public static final int VARDEF = METHODDEF + 1; 102 103 /** The no-op statement ";", of type Skip 104 */ 105 public static final int SKIP = VARDEF + 1; 106 107 /** Blocks, of type Block. 108 */ 109 public static final int BLOCK = SKIP + 1; 110 111 /** Do-while loops, of type DoLoop. 112 */ 113 public static final int DOLOOP = BLOCK + 1; 114 115 /** While-loops, of type WhileLoop. 116 */ 117 public static final int WHILELOOP = DOLOOP + 1; 118 119 /** For-loops, of type ForLoop. 120 */ 121 public static final int FORLOOP = WHILELOOP + 1; 122 123 /** Foreach-loops, of type ForeachLoop. 124 */ 125 public static final int FOREACHLOOP = FORLOOP + 1; 126 127 /** Labelled statements, of type Labelled. 128 */ 129 public static final int LABELLED = FOREACHLOOP + 1; 130 131 /** Switch statements, of type Switch. 132 */ 133 public static final int SWITCH = LABELLED + 1; 134 135 /** Case parts in switch statements, of type Case. 136 */ 137 public static final int CASE = SWITCH + 1; 138 139 /** Synchronized statements, of type Synchonized. 140 */ 141 public static final int SYNCHRONIZED = CASE + 1; 142 143 /** Try statements, of type Try. 144 */ 145 public static final int TRY = SYNCHRONIZED + 1; 146 147 /** Catch clauses in try statements, of type Catch. 148 */ 149 public static final int CATCH = TRY + 1; 150 151 /** Conditional expressions, of type Conditional. 152 */ 153 public static final int CONDEXPR = CATCH + 1; 154 155 /** Conditional statements, of type If. 156 */ 157 public static final int IF = CONDEXPR + 1; 158 159 /** Expression statements, of type Exec. 160 */ 161 public static final int EXEC = IF + 1; 162 163 /** Break statements, of type Break. 164 */ 165 public static final int BREAK = EXEC + 1; 166 167 /** Continue statements, of type Continue. 168 */ 169 public static final int CONTINUE = BREAK + 1; 170 171 /** Return statements, of type Return. 172 */ 173 public static final int RETURN = CONTINUE + 1; 174 175 /** Throw statements, of type Throw. 176 */ 177 public static final int THROW = RETURN + 1; 178 179 /** Assert statements, of type Assert. 180 */ 181 public static final int ASSERT = THROW + 1; 182 183 /** Method invocation expressions, of type Apply. 184 */ 185 public static final int APPLY = ASSERT + 1; 186 187 /** Class instance creation expressions, of type NewClass. 188 */ 189 public static final int NEWCLASS = APPLY + 1; 190 191 /** Array creation expressions, of type NewArray. 192 */ 193 public static final int NEWARRAY = NEWCLASS + 1; 194 195 /** Parenthesized subexpressions, of type Parens. 196 */ 197 public static final int PARENS = NEWARRAY + 1; 198 199 /** Assignment expressions, of type Assign. 200 */ 201 public static final int ASSIGN = PARENS + 1; 202 203 /** Type cast expressions, of type TypeCast. 204 */ 205 public static final int TYPECAST = ASSIGN + 1; 206 207 /** Type test expressions, of type TypeTest. 208 */ 209 public static final int TYPETEST = TYPECAST + 1; 210 211 /** Indexed array expressions, of type Indexed. 212 */ 213 public static final int INDEXED = TYPETEST + 1; 214 215 /** Selections, of type Select. 216 */ 217 public static final int SELECT = INDEXED + 1; 218 219 /** Simple identifiers, of type Ident. 220 */ 221 public static final int IDENT = SELECT + 1; 222 223 /** Literals, of type Literal. 224 */ 225 public static final int LITERAL = IDENT + 1; 226 227 /** Basic type identifiers, of type TypeIdent. 228 */ 229 public static final int TYPEIDENT = LITERAL + 1; 230 231 /** Array types, of type TypeArray. 232 */ 233 public static final int TYPEARRAY = TYPEIDENT + 1; 234 235 /** Parameterized types, of type TypeApply. 236 */ 237 public static final int TYPEAPPLY = TYPEARRAY + 1; 238 239 /** Disjunctive types, of type TypeDisjoint. 240 */ 241 public static final int TYPEDISJOINT = TYPEAPPLY + 1; 242 243 /** Formal type parameters, of type TypeParameter. 244 */ 245 public static final int TYPEPARAMETER = TYPEDISJOINT + 1; 246 247 /** Type argument. 248 */ 249 public static final int WILDCARD = TYPEPARAMETER + 1; 250 251 /** Bound kind: extends, super, exact, or unbound 252 */ 253 public static final int TYPEBOUNDKIND = WILDCARD + 1; 254 255 /** metadata: Annotation. 256 */ 257 public static final int ANNOTATION = TYPEBOUNDKIND + 1; 258 259 /** metadata: Modifiers 260 */ 261 public static final int MODIFIERS = ANNOTATION + 1; 262 263 public static final int ANNOTATED_TYPE = MODIFIERS + 1; 264 265 /** Error trees, of type Erroneous. 266 */ 267 public static final int ERRONEOUS = ANNOTATED_TYPE + 1; 268 269 /** Unary operators, of type Unary. 270 */ 271 public static final int POS = ERRONEOUS + 1; // + 272 public static final int NEG = POS + 1; // - 273 public static final int NOT = NEG + 1; // ! 274 public static final int COMPL = NOT + 1; // ~ 275 public static final int PREINC = COMPL + 1; // ++ _ 276 public static final int PREDEC = PREINC + 1; // -- _ 277 public static final int POSTINC = PREDEC + 1; // _ ++ 278 public static final int POSTDEC = POSTINC + 1; // _ -- 279 280 /** unary operator for null reference checks, only used internally. 281 */ 282 public static final int NULLCHK = POSTDEC + 1; 283 284 /** Binary operators, of type Binary. 285 */ 286 public static final int OR = NULLCHK + 1; // || 287 public static final int AND = OR + 1; // && 288 public static final int BITOR = AND + 1; // | 289 public static final int BITXOR = BITOR + 1; // ^ 290 public static final int BITAND = BITXOR + 1; // & 291 public static final int EQ = BITAND + 1; // == 292 public static final int NE = EQ + 1; // != 293 public static final int LT = NE + 1; // < 294 public static final int GT = LT + 1; // > 295 public static final int LE = GT + 1; // <= 296 public static final int GE = LE + 1; // >= 297 public static final int SL = GE + 1; // << 298 public static final int SR = SL + 1; // >> 299 public static final int USR = SR + 1; // >>> 300 public static final int PLUS = USR + 1; // + 301 public static final int MINUS = PLUS + 1; // - 302 public static final int MUL = MINUS + 1; // * 303 public static final int DIV = MUL + 1; // / 304 public static final int MOD = DIV + 1; // % 305 306 /** Assignment operators, of type Assignop. 307 */ 308 public static final int BITOR_ASG = MOD + 1; // |= 309 public static final int BITXOR_ASG = BITOR_ASG + 1; // ^= 310 public static final int BITAND_ASG = BITXOR_ASG + 1; // &= 311 312 public static final int SL_ASG = SL + BITOR_ASG - BITOR; // <<= 313 public static final int SR_ASG = SL_ASG + 1; // >>= 314 public static final int USR_ASG = SR_ASG + 1; // >>>= 315 public static final int PLUS_ASG = USR_ASG + 1; // += 316 public static final int MINUS_ASG = PLUS_ASG + 1; // -= 317 public static final int MUL_ASG = MINUS_ASG + 1; // *= 318 public static final int DIV_ASG = MUL_ASG + 1; // /= 319 public static final int MOD_ASG = DIV_ASG + 1; // %= 320 321 /** A synthetic let expression, of type LetExpr. 322 */ 323 public static final int LETEXPR = MOD_ASG + 1; // ala scheme 324 325 326 /** The offset between assignment operators and normal operators. 327 */ 328 public static final int ASGOffset = BITOR_ASG - BITOR; 329 330 /* The (encoded) position in the source file. @see util.Position. 331 */ 332 public int pos; 333 334 /* The type of this node. 335 */ 336 public Type type; 337 338 /* The tag of this node -- one of the constants declared above. 339 */ 340 public abstract int getTag(); 341 342 /** Convert a tree to a pretty-printed string. */ 343 public String toString() { 344 StringWriter s = new StringWriter(); 345 try { 346 new Pretty(s, false).printExpr(this); 347 } 348 catch (IOException e) { 349 // should never happen, because StringWriter is defined 350 // never to throw any IOExceptions 351 throw new AssertionError(e); 352 } 353 return s.toString(); 354 } 355 356 /** Set position field and return this tree. 357 */ 358 public JCTree setPos(int pos) { 359 this.pos = pos; 360 return this; 361 } 362 363 /** Set type field and return this tree. 364 */ 365 public JCTree setType(Type type) { 366 this.type = type; 367 return this; 368 } 369 370 /** Visit this tree with a given visitor. 371 */ 372 public abstract void accept(Visitor v); 373 374 public abstract <R,D> R accept(TreeVisitor<R,D> v, D d); 375 376 /** Return a shallow copy of this tree. 377 */ 378 public Object clone() { 379 try { 380 return super.clone(); 381 } catch(CloneNotSupportedException e) { 382 throw new RuntimeException(e); 383 } 384 } 385 386 /** Get a default position for this tree node. 387 */ 388 public DiagnosticPosition pos() { 389 return this; 390 } 391 392 // for default DiagnosticPosition 393 public JCTree getTree() { 394 return this; 395 } 396 397 // for default DiagnosticPosition 398 public int getStartPosition() { 399 return TreeInfo.getStartPos(this); 400 } 401 402 // for default DiagnosticPosition 403 public int getPreferredPosition() { 404 return pos; 405 } 406 407 // for default DiagnosticPosition 408 public int getEndPosition(Map<JCTree, Integer> endPosTable) { 409 return TreeInfo.getEndPos(this, endPosTable); 410 } 411 412 /** 413 * Everything in one source file is kept in a TopLevel structure. 414 * @param pid The tree representing the package clause. 415 * @param sourcefile The source file name. 416 * @param defs All definitions in this file (ClassDef, Import, and Skip) 417 * @param packge The package it belongs to. 418 * @param namedImportScope A scope for all named imports. 419 * @param starImportScope A scope for all import-on-demands. 420 * @param lineMap Line starting positions, defined only 421 * if option -g is set. 422 * @param docComments A hashtable that stores all documentation comments 423 * indexed by the tree nodes they refer to. 424 * defined only if option -s is set. 425 * @param endPositions A hashtable that stores ending positions of source 426 * ranges indexed by the tree nodes they belong to. 427 * Defined only if option -Xjcov is set. 428 */ 429 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree { 430 public List<JCAnnotation> packageAnnotations; 431 public JCExpression pid; 432 public List<JCTree> defs; 433 public JavaFileObject sourcefile; 434 public PackageSymbol packge; 435 public Scope namedImportScope; 436 public Scope starImportScope; 437 public long flags; 438 public Position.LineMap lineMap = null; 439 public Map<JCTree, String> docComments = null; 440 public Map<JCTree, Integer> endPositions = null; 441 protected JCCompilationUnit(List<JCAnnotation> packageAnnotations, 442 JCExpression pid, 443 List<JCTree> defs, 444 JavaFileObject sourcefile, 445 PackageSymbol packge, 446 Scope namedImportScope, 447 Scope starImportScope) { 448 this.packageAnnotations = packageAnnotations; 449 this.pid = pid; 450 this.defs = defs; 451 this.sourcefile = sourcefile; 452 this.packge = packge; 453 this.namedImportScope = namedImportScope; 454 this.starImportScope = starImportScope; 455 } 456 @Override 457 public void accept(Visitor v) { v.visitTopLevel(this); } 458 459 public Kind getKind() { return Kind.COMPILATION_UNIT; } 460 public List<JCAnnotation> getPackageAnnotations() { 461 return packageAnnotations; 462 } 463 public List<JCImport> getImports() { 464 ListBuffer<JCImport> imports = new ListBuffer<JCImport>(); 465 for (JCTree tree : defs) { 466 if (tree.getTag() == IMPORT) 467 imports.append((JCImport)tree); 468 else 469 break; 470 } 471 return imports.toList(); 472 } 473 public JCExpression getPackageName() { return pid; } 474 public JavaFileObject getSourceFile() { 475 return sourcefile; 476 } 477 public Position.LineMap getLineMap() { 478 return lineMap; 479 } 480 public List<JCTree> getTypeDecls() { 481 List<JCTree> typeDefs; 482 for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) 483 if (typeDefs.head.getTag() != IMPORT) 484 break; 485 return typeDefs; 486 } 487 @Override 488 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 489 return v.visitCompilationUnit(this, d); 490 } 491 492 @Override 493 public int getTag() { 494 return TOPLEVEL; 495 } 496 } 497 498 /** 499 * An import clause. 500 * @param qualid The imported class(es). 501 */ 502 public static class JCImport extends JCTree implements ImportTree { 503 public boolean staticImport; 504 public JCTree qualid; 505 protected JCImport(JCTree qualid, boolean importStatic) { 506 this.qualid = qualid; 507 this.staticImport = importStatic; 508 } 509 @Override 510 public void accept(Visitor v) { v.visitImport(this); } 511 512 public boolean isStatic() { return staticImport; } 513 public JCTree getQualifiedIdentifier() { return qualid; } 514 515 public Kind getKind() { return Kind.IMPORT; } 516 @Override 517 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 518 return v.visitImport(this, d); 519 } 520 521 @Override 522 public int getTag() { 523 return IMPORT; 524 } 525 } 526 527 public static abstract class JCStatement extends JCTree implements StatementTree { 528 @Override 529 public JCStatement setType(Type type) { 530 super.setType(type); 531 return this; 532 } 533 @Override 534 public JCStatement setPos(int pos) { 535 super.setPos(pos); 536 return this; 537 } 538 } 539 540 public static abstract class JCExpression extends JCTree implements ExpressionTree { 541 @Override 542 public JCExpression setType(Type type) { 543 super.setType(type); 544 return this; 545 } 546 @Override 547 public JCExpression setPos(int pos) { 548 super.setPos(pos); 549 return this; 550 } 551 } 552 553 /** 554 * A class definition. 555 * @param modifiers the modifiers 556 * @param name the name of the class 557 * @param typarams formal class parameters 558 * @param extending the classes this class extends 559 * @param implementing the interfaces implemented by this class 560 * @param defs all variables and methods defined in this class 561 * @param sym the symbol 562 */ 563 public static class JCClassDecl extends JCStatement implements ClassTree { 564 public JCModifiers mods; 565 public Name name; 566 public List<JCTypeParameter> typarams; 567 public JCTree extending; 568 public List<JCExpression> implementing; 569 public List<JCTree> defs; 570 public ClassSymbol sym; 571 protected JCClassDecl(JCModifiers mods, 572 Name name, 573 List<JCTypeParameter> typarams, 574 JCTree extending, 575 List<JCExpression> implementing, 576 List<JCTree> defs, 577 ClassSymbol sym) 578 { 579 this.mods = mods; 580 this.name = name; 581 this.typarams = typarams; 582 this.extending = extending; 583 this.implementing = implementing; 584 this.defs = defs; 585 this.sym = sym; 586 } 587 @Override 588 public void accept(Visitor v) { v.visitClassDef(this); } 589 590 public Kind getKind() { return Kind.CLASS; } 591 public JCModifiers getModifiers() { return mods; } 592 public Name getSimpleName() { return name; } 593 public List<JCTypeParameter> getTypeParameters() { 594 return typarams; 595 } 596 public JCTree getExtendsClause() { return extending; } 597 public List<JCExpression> getImplementsClause() { 598 return implementing; 599 } 600 public List<JCTree> getMembers() { 601 return defs; 602 } 603 @Override 604 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 605 return v.visitClass(this, d); 606 } 607 608 @Override 609 public int getTag() { 610 return CLASSDEF; 611 } 612 } 613 614 /** 615 * A method definition. 616 * @param modifiers method modifiers 617 * @param name method name 618 * @param restype type of method return value 619 * @param typarams type parameters 620 * @param params value parameters 621 * @param thrown exceptions thrown by this method 622 * @param stats statements in the method 623 * @param sym method symbol 624 */ 625 public static class JCMethodDecl extends JCTree implements MethodTree { 626 public JCModifiers mods; 627 public Name name; 628 public JCExpression restype; 629 public List<JCTypeParameter> typarams; 630 public List<JCVariableDecl> params; 631 public List<JCTypeAnnotation> receiverAnnotations; 632 public List<JCExpression> thrown; 633 public JCBlock body; 634 public JCExpression defaultValue; // for annotation types 635 public MethodSymbol sym; 636 protected JCMethodDecl(JCModifiers mods, 637 Name name, 638 JCExpression restype, 639 List<JCTypeParameter> typarams, 640 List<JCVariableDecl> params, 641 List<JCTypeAnnotation> receiver, 642 List<JCExpression> thrown, 643 JCBlock body, 644 JCExpression defaultValue, 645 MethodSymbol sym) 646 { 647 this.mods = mods; 648 this.name = name; 649 this.restype = restype; 650 this.typarams = typarams; 651 this.params = params; 652 this.receiverAnnotations = (receiver != null ? receiver : List.<JCTypeAnnotation>nil()); 653 this.thrown = thrown; 654 this.body = body; 655 this.defaultValue = defaultValue; 656 this.sym = sym; 657 } 658 @Override 659 public void accept(Visitor v) { v.visitMethodDef(this); } 660 661 public Kind getKind() { return Kind.METHOD; } 662 public JCModifiers getModifiers() { return mods; } 663 public Name getName() { return name; } 664 public JCTree getReturnType() { return restype; } 665 public List<JCTypeParameter> getTypeParameters() { 666 return typarams; 667 } 668 public List<JCVariableDecl> getParameters() { 669 return params; 670 } 671 public List<JCTypeAnnotation> getReceiverAnnotations() { return receiverAnnotations; } 672 public List<JCExpression> getThrows() { 673 return thrown; 674 } 675 public JCBlock getBody() { return body; } 676 public JCTree getDefaultValue() { // for annotation types 677 return defaultValue; 678 } 679 @Override 680 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 681 return v.visitMethod(this, d); 682 } 683 684 @Override 685 public int getTag() { 686 return METHODDEF; 687 } 688 } 689 690 /** 691 * A variable definition. 692 * @param modifiers variable modifiers 693 * @param name variable name 694 * @param vartype type of the variable 695 * @param init variables initial value 696 * @param sym symbol 697 */ 698 public static class JCVariableDecl extends JCStatement implements VariableTree { 699 public JCModifiers mods; 700 public Name name; 701 public JCExpression vartype; 702 public JCExpression init; 703 public VarSymbol sym; 704 protected JCVariableDecl(JCModifiers mods, 705 Name name, 706 JCExpression vartype, 707 JCExpression init, 708 VarSymbol sym) { 709 this.mods = mods; 710 this.name = name; 711 this.vartype = vartype; 712 this.init = init; 713 this.sym = sym; 714 } 715 @Override 716 public void accept(Visitor v) { v.visitVarDef(this); } 717 718 public Kind getKind() { return Kind.VARIABLE; } 719 public JCModifiers getModifiers() { return mods; } 720 public Name getName() { return name; } 721 public JCTree getType() { return vartype; } 722 public JCExpression getInitializer() { 723 return init; 724 } 725 @Override 726 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 727 return v.visitVariable(this, d); 728 } 729 730 @Override 731 public int getTag() { 732 return VARDEF; 733 } 734 } 735 736 /** 737 * A no-op statement ";". 738 */ 739 public static class JCSkip extends JCStatement implements EmptyStatementTree { 740 protected JCSkip() { 741 } 742 @Override 743 public void accept(Visitor v) { v.visitSkip(this); } 744 745 public Kind getKind() { return Kind.EMPTY_STATEMENT; } 746 @Override 747 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 748 return v.visitEmptyStatement(this, d); 749 } 750 751 @Override 752 public int getTag() { 753 return SKIP; 754 } 755 } 756 757 /** 758 * A statement block. 759 * @param stats statements 760 * @param flags flags 761 */ 762 public static class JCBlock extends JCStatement implements BlockTree { 763 public long flags; 764 public List<JCStatement> stats; 765 /** Position of closing brace, optional. */ 766 public int endpos = Position.NOPOS; 767 protected JCBlock(long flags, List<JCStatement> stats) { 768 this.stats = stats; 769 this.flags = flags; 770 } 771 @Override 772 public void accept(Visitor v) { v.visitBlock(this); } 773 774 public Kind getKind() { return Kind.BLOCK; } 775 public List<JCStatement> getStatements() { 776 return stats; 777 } 778 public boolean isStatic() { return (flags & Flags.STATIC) != 0; } 779 @Override 780 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 781 return v.visitBlock(this, d); 782 } 783 784 @Override 785 public int getTag() { 786 return BLOCK; 787 } 788 } 789 790 /** 791 * A do loop 792 */ 793 public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree { 794 public JCStatement body; 795 public JCExpression cond; 796 protected JCDoWhileLoop(JCStatement body, JCExpression cond) { 797 this.body = body; 798 this.cond = cond; 799 } 800 @Override 801 public void accept(Visitor v) { v.visitDoLoop(this); } 802 803 public Kind getKind() { return Kind.DO_WHILE_LOOP; } 804 public JCExpression getCondition() { return cond; } 805 public JCStatement getStatement() { return body; } 806 @Override 807 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 808 return v.visitDoWhileLoop(this, d); 809 } 810 811 @Override 812 public int getTag() { 813 return DOLOOP; 814 } 815 } 816 817 /** 818 * A while loop 819 */ 820 public static class JCWhileLoop extends JCStatement implements WhileLoopTree { 821 public JCExpression cond; 822 public JCStatement body; 823 protected JCWhileLoop(JCExpression cond, JCStatement body) { 824 this.cond = cond; 825 this.body = body; 826 } 827 @Override 828 public void accept(Visitor v) { v.visitWhileLoop(this); } 829 830 public Kind getKind() { return Kind.WHILE_LOOP; } 831 public JCExpression getCondition() { return cond; } 832 public JCStatement getStatement() { return body; } 833 @Override 834 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 835 return v.visitWhileLoop(this, d); 836 } 837 838 @Override 839 public int getTag() { 840 return WHILELOOP; 841 } 842 } 843 844 /** 845 * A for loop. 846 */ 847 public static class JCForLoop extends JCStatement implements ForLoopTree { 848 public List<JCStatement> init; 849 public JCExpression cond; 850 public List<JCExpressionStatement> step; 851 public JCStatement body; 852 protected JCForLoop(List<JCStatement> init, 853 JCExpression cond, 854 List<JCExpressionStatement> update, 855 JCStatement body) 856 { 857 this.init = init; 858 this.cond = cond; 859 this.step = update; 860 this.body = body; 861 } 862 @Override 863 public void accept(Visitor v) { v.visitForLoop(this); } 864 865 public Kind getKind() { return Kind.FOR_LOOP; } 866 public JCExpression getCondition() { return cond; } 867 public JCStatement getStatement() { return body; } 868 public List<JCStatement> getInitializer() { 869 return init; 870 } 871 public List<JCExpressionStatement> getUpdate() { 872 return step; 873 } 874 @Override 875 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 876 return v.visitForLoop(this, d); 877 } 878 879 @Override 880 public int getTag() { 881 return FORLOOP; 882 } 883 } 884 885 /** 886 * The enhanced for loop. 887 */ 888 public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree { 889 public JCVariableDecl var; 890 public JCExpression expr; 891 public JCStatement body; 892 protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { 893 this.var = var; 894 this.expr = expr; 895 this.body = body; 896 } 897 @Override 898 public void accept(Visitor v) { v.visitForeachLoop(this); } 899 900 public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; } 901 public JCVariableDecl getVariable() { return var; } 902 public JCExpression getExpression() { return expr; } 903 public JCStatement getStatement() { return body; } 904 @Override 905 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 906 return v.visitEnhancedForLoop(this, d); 907 } 908 @Override 909 public int getTag() { 910 return FOREACHLOOP; 911 } 912 } 913 914 /** 915 * A labelled expression or statement. 916 */ 917 public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree { 918 public Name label; 919 public JCStatement body; 920 protected JCLabeledStatement(Name label, JCStatement body) { 921 this.label = label; 922 this.body = body; 923 } 924 @Override 925 public void accept(Visitor v) { v.visitLabelled(this); } 926 public Kind getKind() { return Kind.LABELED_STATEMENT; } 927 public Name getLabel() { return label; } 928 public JCStatement getStatement() { return body; } 929 @Override 930 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 931 return v.visitLabeledStatement(this, d); 932 } 933 @Override 934 public int getTag() { 935 return LABELLED; 936 } 937 } 938 939 /** 940 * A "switch ( ) { }" construction. 941 */ 942 public static class JCSwitch extends JCStatement implements SwitchTree { 943 public JCExpression selector; 944 public List<JCCase> cases; 945 protected JCSwitch(JCExpression selector, List<JCCase> cases) { 946 this.selector = selector; 947 this.cases = cases; 948 } 949 @Override 950 public void accept(Visitor v) { v.visitSwitch(this); } 951 952 public Kind getKind() { return Kind.SWITCH; } 953 public JCExpression getExpression() { return selector; } 954 public List<JCCase> getCases() { return cases; } 955 @Override 956 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 957 return v.visitSwitch(this, d); 958 } 959 @Override 960 public int getTag() { 961 return SWITCH; 962 } 963 } 964 965 /** 966 * A "case :" of a switch. 967 */ 968 public static class JCCase extends JCStatement implements CaseTree { 969 public JCExpression pat; 970 public List<JCStatement> stats; 971 protected JCCase(JCExpression pat, List<JCStatement> stats) { 972 this.pat = pat; 973 this.stats = stats; 974 } 975 @Override 976 public void accept(Visitor v) { v.visitCase(this); } 977 978 public Kind getKind() { return Kind.CASE; } 979 public JCExpression getExpression() { return pat; } 980 public List<JCStatement> getStatements() { return stats; } 981 @Override 982 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 983 return v.visitCase(this, d); 984 } 985 @Override 986 public int getTag() { 987 return CASE; 988 } 989 } 990 991 /** 992 * A synchronized block. 993 */ 994 public static class JCSynchronized extends JCStatement implements SynchronizedTree { 995 public JCExpression lock; 996 public JCBlock body; 997 protected JCSynchronized(JCExpression lock, JCBlock body) { 998 this.lock = lock; 999 this.body = body; 1000 } 1001 @Override 1002 public void accept(Visitor v) { v.visitSynchronized(this); } 1003 1004 public Kind getKind() { return Kind.SYNCHRONIZED; } 1005 public JCExpression getExpression() { return lock; } 1006 public JCBlock getBlock() { return body; } 1007 @Override 1008 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1009 return v.visitSynchronized(this, d); 1010 } 1011 @Override 1012 public int getTag() { 1013 return SYNCHRONIZED; 1014 } 1015 } 1016 1017 /** 1018 * A "try { } catch ( ) { } finally { }" block. 1019 */ 1020 public static class JCTry extends JCStatement implements TryTree { 1021 public JCBlock body; 1022 public List<JCCatch> catchers; 1023 public JCBlock finalizer; 1024 public List<JCTree> resources; 1025 protected JCTry(JCBlock body, 1026 List<JCCatch> catchers, 1027 JCBlock finalizer, 1028 List<JCTree> resources) { 1029 this.body = body; 1030 this.catchers = catchers; 1031 this.finalizer = finalizer; 1032 this.resources = resources; 1033 } 1034 @Override 1035 public void accept(Visitor v) { v.visitTry(this); } 1036 1037 public Kind getKind() { return Kind.TRY; } 1038 public JCBlock getBlock() { return body; } 1039 public List<JCCatch> getCatches() { 1040 return catchers; 1041 } 1042 public JCBlock getFinallyBlock() { return finalizer; } 1043 @Override 1044 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1045 return v.visitTry(this, d); 1046 } 1047 @Override 1048 public List<? extends JCTree> getResources() { 1049 return resources; 1050 } 1051 @Override 1052 public int getTag() { 1053 return TRY; 1054 } 1055 } 1056 1057 /** 1058 * A catch block. 1059 */ 1060 public static class JCCatch extends JCTree implements CatchTree { 1061 public JCVariableDecl param; 1062 public JCBlock body; 1063 protected JCCatch(JCVariableDecl param, JCBlock body) { 1064 this.param = param; 1065 this.body = body; 1066 } 1067 @Override 1068 public void accept(Visitor v) { v.visitCatch(this); } 1069 1070 public Kind getKind() { return Kind.CATCH; } 1071 public JCVariableDecl getParameter() { return param; } 1072 public JCBlock getBlock() { return body; } 1073 @Override 1074 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1075 return v.visitCatch(this, d); 1076 } 1077 @Override 1078 public int getTag() { 1079 return CATCH; 1080 } 1081 } 1082 1083 /** 1084 * A ( ) ? ( ) : ( ) conditional expression 1085 */ 1086 public static class JCConditional extends JCExpression implements ConditionalExpressionTree { 1087 public JCExpression cond; 1088 public JCExpression truepart; 1089 public JCExpression falsepart; 1090 protected JCConditional(JCExpression cond, 1091 JCExpression truepart, 1092 JCExpression falsepart) 1093 { 1094 this.cond = cond; 1095 this.truepart = truepart; 1096 this.falsepart = falsepart; 1097 } 1098 @Override 1099 public void accept(Visitor v) { v.visitConditional(this); } 1100 1101 public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; } 1102 public JCExpression getCondition() { return cond; } 1103 public JCExpression getTrueExpression() { return truepart; } 1104 public JCExpression getFalseExpression() { return falsepart; } 1105 @Override 1106 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1107 return v.visitConditionalExpression(this, d); 1108 } 1109 @Override 1110 public int getTag() { 1111 return CONDEXPR; 1112 } 1113 } 1114 1115 /** 1116 * An "if ( ) { } else { }" block 1117 */ 1118 public static class JCIf extends JCStatement implements IfTree { 1119 public JCExpression cond; 1120 public JCStatement thenpart; 1121 public JCStatement elsepart; 1122 protected JCIf(JCExpression cond, 1123 JCStatement thenpart, 1124 JCStatement elsepart) 1125 { 1126 this.cond = cond; 1127 this.thenpart = thenpart; 1128 this.elsepart = elsepart; 1129 } 1130 @Override 1131 public void accept(Visitor v) { v.visitIf(this); } 1132 1133 public Kind getKind() { return Kind.IF; } 1134 public JCExpression getCondition() { return cond; } 1135 public JCStatement getThenStatement() { return thenpart; } 1136 public JCStatement getElseStatement() { return elsepart; } 1137 @Override 1138 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1139 return v.visitIf(this, d); 1140 } 1141 @Override 1142 public int getTag() { 1143 return IF; 1144 } 1145 } 1146 1147 /** 1148 * an expression statement 1149 * @param expr expression structure 1150 */ 1151 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree { 1152 public JCExpression expr; 1153 protected JCExpressionStatement(JCExpression expr) 1154 { 1155 this.expr = expr; 1156 } 1157 @Override 1158 public void accept(Visitor v) { v.visitExec(this); } 1159 1160 public Kind getKind() { return Kind.EXPRESSION_STATEMENT; } 1161 public JCExpression getExpression() { return expr; } 1162 @Override 1163 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1164 return v.visitExpressionStatement(this, d); 1165 } 1166 @Override 1167 public int getTag() { 1168 return EXEC; 1169 } 1170 } 1171 1172 /** 1173 * A break from a loop or switch. 1174 */ 1175 public static class JCBreak extends JCStatement implements BreakTree { 1176 public Name label; 1177 public JCTree target; 1178 protected JCBreak(Name label, JCTree target) { 1179 this.label = label; 1180 this.target = target; 1181 } 1182 @Override 1183 public void accept(Visitor v) { v.visitBreak(this); } 1184 1185 public Kind getKind() { return Kind.BREAK; } 1186 public Name getLabel() { return label; } 1187 @Override 1188 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1189 return v.visitBreak(this, d); 1190 } 1191 @Override 1192 public int getTag() { 1193 return BREAK; 1194 } 1195 } 1196 1197 /** 1198 * A continue of a loop. 1199 */ 1200 public static class JCContinue extends JCStatement implements ContinueTree { 1201 public Name label; 1202 public JCTree target; 1203 protected JCContinue(Name label, JCTree target) { 1204 this.label = label; 1205 this.target = target; 1206 } 1207 @Override 1208 public void accept(Visitor v) { v.visitContinue(this); } 1209 1210 public Kind getKind() { return Kind.CONTINUE; } 1211 public Name getLabel() { return label; } 1212 @Override 1213 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1214 return v.visitContinue(this, d); 1215 } 1216 @Override 1217 public int getTag() { 1218 return CONTINUE; 1219 } 1220 } 1221 1222 /** 1223 * A return statement. 1224 */ 1225 public static class JCReturn extends JCStatement implements ReturnTree { 1226 public JCExpression expr; 1227 protected JCReturn(JCExpression expr) { 1228 this.expr = expr; 1229 } 1230 @Override 1231 public void accept(Visitor v) { v.visitReturn(this); } 1232 1233 public Kind getKind() { return Kind.RETURN; } 1234 public JCExpression getExpression() { return expr; } 1235 @Override 1236 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1237 return v.visitReturn(this, d); 1238 } 1239 @Override 1240 public int getTag() { 1241 return RETURN; 1242 } 1243 } 1244 1245 /** 1246 * A throw statement. 1247 */ 1248 public static class JCThrow extends JCStatement implements ThrowTree { 1249 public JCExpression expr; 1250 protected JCThrow(JCTree expr) { 1251 this.expr = (JCExpression)expr; 1252 } 1253 @Override 1254 public void accept(Visitor v) { v.visitThrow(this); } 1255 1256 public Kind getKind() { return Kind.THROW; } 1257 public JCExpression getExpression() { return expr; } 1258 @Override 1259 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1260 return v.visitThrow(this, d); 1261 } 1262 @Override 1263 public int getTag() { 1264 return THROW; 1265 } 1266 } 1267 1268 /** 1269 * An assert statement. 1270 */ 1271 public static class JCAssert extends JCStatement implements AssertTree { 1272 public JCExpression cond; 1273 public JCExpression detail; 1274 protected JCAssert(JCExpression cond, JCExpression detail) { 1275 this.cond = cond; 1276 this.detail = detail; 1277 } 1278 @Override 1279 public void accept(Visitor v) { v.visitAssert(this); } 1280 1281 public Kind getKind() { return Kind.ASSERT; } 1282 public JCExpression getCondition() { return cond; } 1283 public JCExpression getDetail() { return detail; } 1284 @Override 1285 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1286 return v.visitAssert(this, d); 1287 } 1288 @Override 1289 public int getTag() { 1290 return ASSERT; 1291 } 1292 } 1293 1294 /** 1295 * A method invocation 1296 */ 1297 public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree { 1298 public List<JCExpression> typeargs; 1299 public JCExpression meth; 1300 public List<JCExpression> args; 1301 public Type varargsElement; 1302 protected JCMethodInvocation(List<JCExpression> typeargs, 1303 JCExpression meth, 1304 List<JCExpression> args) 1305 { 1306 this.typeargs = (typeargs == null) ? List.<JCExpression>nil() 1307 : typeargs; 1308 this.meth = meth; 1309 this.args = args; 1310 } 1311 @Override 1312 public void accept(Visitor v) { v.visitApply(this); } 1313 1314 public Kind getKind() { return Kind.METHOD_INVOCATION; } 1315 public List<JCExpression> getTypeArguments() { 1316 return typeargs; 1317 } 1318 public JCExpression getMethodSelect() { return meth; } 1319 public List<JCExpression> getArguments() { 1320 return args; 1321 } 1322 @Override 1323 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1324 return v.visitMethodInvocation(this, d); 1325 } 1326 @Override 1327 public JCMethodInvocation setType(Type type) { 1328 super.setType(type); 1329 return this; 1330 } 1331 @Override 1332 public int getTag() { 1333 return(APPLY); 1334 } 1335 } 1336 1337 /** 1338 * A new(...) operation. 1339 */ 1340 public static class JCNewClass extends JCExpression implements NewClassTree { 1341 public JCExpression encl; 1342 public List<JCExpression> typeargs; 1343 public JCExpression clazz; 1344 public List<JCExpression> args; 1345 public JCClassDecl def; 1346 public Symbol constructor; 1347 public Type varargsElement; 1348 public Type constructorType; 1349 protected JCNewClass(JCExpression encl, 1350 List<JCExpression> typeargs, 1351 JCExpression clazz, 1352 List<JCExpression> args, 1353 JCClassDecl def) 1354 { 1355 this.encl = encl; 1356 this.typeargs = (typeargs == null) ? List.<JCExpression>nil() 1357 : typeargs; 1358 this.clazz = clazz; 1359 this.args = args; 1360 this.def = def; 1361 } 1362 @Override 1363 public void accept(Visitor v) { v.visitNewClass(this); } 1364 1365 public Kind getKind() { return Kind.NEW_CLASS; } 1366 public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... ) 1367 return encl; 1368 } 1369 public List<JCExpression> getTypeArguments() { 1370 return typeargs; 1371 } 1372 public JCExpression getIdentifier() { return clazz; } 1373 public List<JCExpression> getArguments() { 1374 return args; 1375 } 1376 public JCClassDecl getClassBody() { return def; } 1377 @Override 1378 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1379 return v.visitNewClass(this, d); 1380 } 1381 @Override 1382 public int getTag() { 1383 return NEWCLASS; 1384 } 1385 } 1386 1387 /** 1388 * A new[...] operation. 1389 */ 1390 public static class JCNewArray extends JCExpression implements NewArrayTree { 1391 public JCExpression elemtype; 1392 public List<JCExpression> dims; 1393 public List<JCTypeAnnotation> annotations; 1394 public List<List<JCTypeAnnotation>> dimAnnotations; 1395 public List<JCExpression> elems; 1396 protected JCNewArray(JCExpression elemtype, 1397 List<JCExpression> dims, 1398 List<JCExpression> elems) 1399 { 1400 this.elemtype = elemtype; 1401 this.dims = dims; 1402 this.annotations = List.nil(); 1403 this.dimAnnotations = List.nil(); 1404 this.elems = elems; 1405 } 1406 @Override 1407 public void accept(Visitor v) { v.visitNewArray(this); } 1408 1409 public Kind getKind() { return Kind.NEW_ARRAY; } 1410 public JCExpression getType() { return elemtype; } 1411 public List<JCExpression> getDimensions() { 1412 return dims; 1413 } 1414 public List<JCExpression> getInitializers() { 1415 return elems; 1416 } 1417 @Override 1418 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1419 return v.visitNewArray(this, d); 1420 } 1421 @Override 1422 public int getTag() { 1423 return NEWARRAY; 1424 } 1425 } 1426 1427 /** 1428 * A parenthesized subexpression ( ... ) 1429 */ 1430 public static class JCParens extends JCExpression implements ParenthesizedTree { 1431 public JCExpression expr; 1432 protected JCParens(JCExpression expr) { 1433 this.expr = expr; 1434 } 1435 @Override 1436 public void accept(Visitor v) { v.visitParens(this); } 1437 1438 public Kind getKind() { return Kind.PARENTHESIZED; } 1439 public JCExpression getExpression() { return expr; } 1440 @Override 1441 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1442 return v.visitParenthesized(this, d); 1443 } 1444 @Override 1445 public int getTag() { 1446 return PARENS; 1447 } 1448 } 1449 1450 /** 1451 * A assignment with "=". 1452 */ 1453 public static class JCAssign extends JCExpression implements AssignmentTree { 1454 public JCExpression lhs; 1455 public JCExpression rhs; 1456 protected JCAssign(JCExpression lhs, JCExpression rhs) { 1457 this.lhs = lhs; 1458 this.rhs = rhs; 1459 } 1460 @Override 1461 public void accept(Visitor v) { v.visitAssign(this); } 1462 1463 public Kind getKind() { return Kind.ASSIGNMENT; } 1464 public JCExpression getVariable() { return lhs; } 1465 public JCExpression getExpression() { return rhs; } 1466 @Override 1467 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1468 return v.visitAssignment(this, d); 1469 } 1470 @Override 1471 public int getTag() { 1472 return ASSIGN; 1473 } 1474 } 1475 1476 /** 1477 * An assignment with "+=", "|=" ... 1478 */ 1479 public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree { 1480 private int opcode; 1481 public JCExpression lhs; 1482 public JCExpression rhs; 1483 public Symbol operator; 1484 protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs, Symbol operator) { 1485 this.opcode = opcode; 1486 this.lhs = (JCExpression)lhs; 1487 this.rhs = (JCExpression)rhs; 1488 this.operator = operator; 1489 } 1490 @Override 1491 public void accept(Visitor v) { v.visitAssignop(this); } 1492 1493 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 1494 public JCExpression getVariable() { return lhs; } 1495 public JCExpression getExpression() { return rhs; } 1496 public Symbol getOperator() { 1497 return operator; 1498 } 1499 @Override 1500 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1501 return v.visitCompoundAssignment(this, d); 1502 } 1503 @Override 1504 public int getTag() { 1505 return opcode; 1506 } 1507 } 1508 1509 /** 1510 * A unary operation. 1511 */ 1512 public static class JCUnary extends JCExpression implements UnaryTree { 1513 private int opcode; 1514 public JCExpression arg; 1515 public Symbol operator; 1516 protected JCUnary(int opcode, JCExpression arg) { 1517 this.opcode = opcode; 1518 this.arg = arg; 1519 } 1520 @Override 1521 public void accept(Visitor v) { v.visitUnary(this); } 1522 1523 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 1524 public JCExpression getExpression() { return arg; } 1525 public Symbol getOperator() { 1526 return operator; 1527 } 1528 @Override 1529 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1530 return v.visitUnary(this, d); 1531 } 1532 @Override 1533 public int getTag() { 1534 return opcode; 1535 } 1536 1537 public void setTag(int tag) { 1538 opcode = tag; 1539 } 1540 } 1541 1542 /** 1543 * A binary operation. 1544 */ 1545 public static class JCBinary extends JCExpression implements BinaryTree { 1546 private int opcode; 1547 public JCExpression lhs; 1548 public JCExpression rhs; 1549 public Symbol operator; 1550 protected JCBinary(int opcode, 1551 JCExpression lhs, 1552 JCExpression rhs, 1553 Symbol operator) { 1554 this.opcode = opcode; 1555 this.lhs = lhs; 1556 this.rhs = rhs; 1557 this.operator = operator; 1558 } 1559 @Override 1560 public void accept(Visitor v) { v.visitBinary(this); } 1561 1562 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 1563 public JCExpression getLeftOperand() { return lhs; } 1564 public JCExpression getRightOperand() { return rhs; } 1565 public Symbol getOperator() { 1566 return operator; 1567 } 1568 @Override 1569 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1570 return v.visitBinary(this, d); 1571 } 1572 @Override 1573 public int getTag() { 1574 return opcode; 1575 } 1576 } 1577 1578 /** 1579 * A type cast. 1580 */ 1581 public static class JCTypeCast extends JCExpression implements TypeCastTree { 1582 public JCTree clazz; 1583 public JCExpression expr; 1584 protected JCTypeCast(JCTree clazz, JCExpression expr) { 1585 this.clazz = clazz; 1586 this.expr = expr; 1587 } 1588 @Override 1589 public void accept(Visitor v) { v.visitTypeCast(this); } 1590 1591 public Kind getKind() { return Kind.TYPE_CAST; } 1592 public JCTree getType() { return clazz; } 1593 public JCExpression getExpression() { return expr; } 1594 @Override 1595 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1596 return v.visitTypeCast(this, d); 1597 } 1598 @Override 1599 public int getTag() { 1600 return TYPECAST; 1601 } 1602 } 1603 1604 /** 1605 * A type test. 1606 */ 1607 public static class JCInstanceOf extends JCExpression implements InstanceOfTree { 1608 public JCExpression expr; 1609 public JCTree clazz; 1610 protected JCInstanceOf(JCExpression expr, JCTree clazz) { 1611 this.expr = expr; 1612 this.clazz = clazz; 1613 } 1614 @Override 1615 public void accept(Visitor v) { v.visitTypeTest(this); } 1616 1617 public Kind getKind() { return Kind.INSTANCE_OF; } 1618 public JCTree getType() { return clazz; } 1619 public JCExpression getExpression() { return expr; } 1620 @Override 1621 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1622 return v.visitInstanceOf(this, d); 1623 } 1624 @Override 1625 public int getTag() { 1626 return TYPETEST; 1627 } 1628 } 1629 1630 /** 1631 * An array selection 1632 */ 1633 public static class JCArrayAccess extends JCExpression implements ArrayAccessTree { 1634 public JCExpression indexed; 1635 public JCExpression index; 1636 protected JCArrayAccess(JCExpression indexed, JCExpression index) { 1637 this.indexed = indexed; 1638 this.index = index; 1639 } 1640 @Override 1641 public void accept(Visitor v) { v.visitIndexed(this); } 1642 1643 public Kind getKind() { return Kind.ARRAY_ACCESS; } 1644 public JCExpression getExpression() { return indexed; } 1645 public JCExpression getIndex() { return index; } 1646 @Override 1647 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1648 return v.visitArrayAccess(this, d); 1649 } 1650 @Override 1651 public int getTag() { 1652 return INDEXED; 1653 } 1654 } 1655 1656 /** 1657 * Selects through packages and classes 1658 * @param selected selected Tree hierarchie 1659 * @param selector name of field to select thru 1660 * @param sym symbol of the selected class 1661 */ 1662 public static class JCFieldAccess extends JCExpression implements MemberSelectTree { 1663 public JCExpression selected; 1664 public Name name; 1665 public Symbol sym; 1666 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) { 1667 this.selected = selected; 1668 this.name = name; 1669 this.sym = sym; 1670 } 1671 @Override 1672 public void accept(Visitor v) { v.visitSelect(this); } 1673 1674 public Kind getKind() { return Kind.MEMBER_SELECT; } 1675 public JCExpression getExpression() { return selected; } 1676 @Override 1677 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1678 return v.visitMemberSelect(this, d); 1679 } 1680 public Name getIdentifier() { return name; } 1681 @Override 1682 public int getTag() { 1683 return SELECT; 1684 } 1685 } 1686 1687 /** 1688 * An identifier 1689 * @param idname the name 1690 * @param sym the symbol 1691 */ 1692 public static class JCIdent extends JCExpression implements IdentifierTree { 1693 public Name name; 1694 public Symbol sym; 1695 protected JCIdent(Name name, Symbol sym) { 1696 this.name = name; 1697 this.sym = sym; 1698 } 1699 @Override 1700 public void accept(Visitor v) { v.visitIdent(this); } 1701 1702 public Kind getKind() { return Kind.IDENTIFIER; } 1703 public Name getName() { return name; } 1704 @Override 1705 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1706 return v.visitIdentifier(this, d); 1707 } 1708 public int getTag() { 1709 return IDENT; 1710 } 1711 } 1712 1713 /** 1714 * A constant value given literally. 1715 * @param value value representation 1716 */ 1717 public static class JCLiteral extends JCExpression implements LiteralTree { 1718 public int typetag; 1719 public Object value; 1720 protected JCLiteral(int typetag, Object value) { 1721 this.typetag = typetag; 1722 this.value = value; 1723 } 1724 @Override 1725 public void accept(Visitor v) { v.visitLiteral(this); } 1726 1727 public Kind getKind() { 1728 switch (typetag) { 1729 case TypeTags.INT: 1730 return Kind.INT_LITERAL; 1731 case TypeTags.LONG: 1732 return Kind.LONG_LITERAL; 1733 case TypeTags.FLOAT: 1734 return Kind.FLOAT_LITERAL; 1735 case TypeTags.DOUBLE: 1736 return Kind.DOUBLE_LITERAL; 1737 case TypeTags.BOOLEAN: 1738 return Kind.BOOLEAN_LITERAL; 1739 case TypeTags.CHAR: 1740 return Kind.CHAR_LITERAL; 1741 case TypeTags.CLASS: 1742 return Kind.STRING_LITERAL; 1743 case TypeTags.BOT: 1744 return Kind.NULL_LITERAL; 1745 default: 1746 throw new AssertionError("unknown literal kind " + this); 1747 } 1748 } 1749 public Object getValue() { 1750 switch (typetag) { 1751 case TypeTags.BOOLEAN: 1752 int bi = (Integer) value; 1753 return (bi != 0); 1754 case TypeTags.CHAR: 1755 int ci = (Integer) value; 1756 char c = (char) ci; 1757 if (c != ci) 1758 throw new AssertionError("bad value for char literal"); 1759 return c; 1760 default: 1761 return value; 1762 } 1763 } 1764 @Override 1765 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1766 return v.visitLiteral(this, d); 1767 } 1768 @Override 1769 public JCLiteral setType(Type type) { 1770 super.setType(type); 1771 return this; 1772 } 1773 @Override 1774 public int getTag() { 1775 return LITERAL; 1776 } 1777 } 1778 1779 /** 1780 * Identifies a basic type. 1781 * @param tag the basic type id 1782 * @see TypeTags 1783 */ 1784 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree { 1785 public int typetag; 1786 protected JCPrimitiveTypeTree(int typetag) { 1787 this.typetag = typetag; 1788 } 1789 @Override 1790 public void accept(Visitor v) { v.visitTypeIdent(this); } 1791 1792 public Kind getKind() { return Kind.PRIMITIVE_TYPE; } 1793 public TypeKind getPrimitiveTypeKind() { 1794 switch (typetag) { 1795 case TypeTags.BOOLEAN: 1796 return TypeKind.BOOLEAN; 1797 case TypeTags.BYTE: 1798 return TypeKind.BYTE; 1799 case TypeTags.SHORT: 1800 return TypeKind.SHORT; 1801 case TypeTags.INT: 1802 return TypeKind.INT; 1803 case TypeTags.LONG: 1804 return TypeKind.LONG; 1805 case TypeTags.CHAR: 1806 return TypeKind.CHAR; 1807 case TypeTags.FLOAT: 1808 return TypeKind.FLOAT; 1809 case TypeTags.DOUBLE: 1810 return TypeKind.DOUBLE; 1811 case TypeTags.VOID: 1812 return TypeKind.VOID; 1813 default: 1814 throw new AssertionError("unknown primitive type " + this); 1815 } 1816 } 1817 @Override 1818 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1819 return v.visitPrimitiveType(this, d); 1820 } 1821 @Override 1822 public int getTag() { 1823 return TYPEIDENT; 1824 } 1825 } 1826 1827 /** 1828 * An array type, A[] 1829 */ 1830 public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree { 1831 public JCExpression elemtype; 1832 protected JCArrayTypeTree(JCExpression elemtype) { 1833 this.elemtype = elemtype; 1834 } 1835 @Override 1836 public void accept(Visitor v) { v.visitTypeArray(this); } 1837 1838 public Kind getKind() { return Kind.ARRAY_TYPE; } 1839 public JCTree getType() { return elemtype; } 1840 @Override 1841 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1842 return v.visitArrayType(this, d); 1843 } 1844 @Override 1845 public int getTag() { 1846 return TYPEARRAY; 1847 } 1848 } 1849 1850 /** 1851 * A parameterized type, T<...> 1852 */ 1853 public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree { 1854 public JCExpression clazz; 1855 public List<JCExpression> arguments; 1856 protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) { 1857 this.clazz = clazz; 1858 this.arguments = arguments; 1859 } 1860 @Override 1861 public void accept(Visitor v) { v.visitTypeApply(this); } 1862 1863 public Kind getKind() { return Kind.PARAMETERIZED_TYPE; } 1864 public JCTree getType() { return clazz; } 1865 public List<JCExpression> getTypeArguments() { 1866 return arguments; 1867 } 1868 @Override 1869 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1870 return v.visitParameterizedType(this, d); 1871 } 1872 @Override 1873 public int getTag() { 1874 return TYPEAPPLY; 1875 } 1876 } 1877 1878 /** 1879 * A disjoint type, T1 | T2 | ... Tn (used in multicatch statements) 1880 */ 1881 public static class JCTypeDisjoint extends JCExpression implements DisjointTypeTree { 1882 1883 public List<JCExpression> components; 1884 1885 protected JCTypeDisjoint(List<JCExpression> components) { 1886 this.components = components; 1887 } 1888 @Override 1889 public void accept(Visitor v) { v.visitTypeDisjoint(this); } 1890 1891 public Kind getKind() { return Kind.DISJOINT_TYPE; } 1892 1893 public List<JCExpression> getTypeComponents() { 1894 return components; 1895 } 1896 @Override 1897 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1898 return v.visitDisjointType(this, d); 1899 } 1900 @Override 1901 public int getTag() { 1902 return TYPEDISJOINT; 1903 } 1904 } 1905 1906 /** 1907 * A formal class parameter. 1908 * @param name name 1909 * @param bounds bounds 1910 */ 1911 public static class JCTypeParameter extends JCTree implements TypeParameterTree { 1912 public Name name; 1913 public List<JCExpression> bounds; 1914 public List<JCTypeAnnotation> annotations; 1915 protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCTypeAnnotation> annotations) { 1916 this.name = name; 1917 this.bounds = bounds; 1918 this.annotations = annotations; 1919 } 1920 @Override 1921 public void accept(Visitor v) { v.visitTypeParameter(this); } 1922 1923 public Kind getKind() { return Kind.TYPE_PARAMETER; } 1924 public Name getName() { return name; } 1925 public List<JCExpression> getBounds() { 1926 return bounds; 1927 } 1928 public List<JCTypeAnnotation> getAnnotations() { 1929 return annotations; 1930 } 1931 @Override 1932 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1933 return v.visitTypeParameter(this, d); 1934 } 1935 @Override 1936 public int getTag() { 1937 return TYPEPARAMETER; 1938 } 1939 } 1940 1941 public static class JCWildcard extends JCExpression implements WildcardTree { 1942 public TypeBoundKind kind; 1943 public JCTree inner; 1944 protected JCWildcard(TypeBoundKind kind, JCTree inner) { 1945 kind.getClass(); // null-check 1946 this.kind = kind; 1947 this.inner = inner; 1948 } 1949 @Override 1950 public void accept(Visitor v) { v.visitWildcard(this); } 1951 1952 public Kind getKind() { 1953 switch (kind.kind) { 1954 case UNBOUND: 1955 return Kind.UNBOUNDED_WILDCARD; 1956 case EXTENDS: 1957 return Kind.EXTENDS_WILDCARD; 1958 case SUPER: 1959 return Kind.SUPER_WILDCARD; 1960 default: 1961 throw new AssertionError("Unknown wildcard bound " + kind); 1962 } 1963 } 1964 public JCTree getBound() { return inner; } 1965 @Override 1966 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1967 return v.visitWildcard(this, d); 1968 } 1969 @Override 1970 public int getTag() { 1971 return WILDCARD; 1972 } 1973 } 1974 1975 public static class TypeBoundKind extends JCTree { 1976 public BoundKind kind; 1977 protected TypeBoundKind(BoundKind kind) { 1978 this.kind = kind; 1979 } 1980 @Override 1981 public void accept(Visitor v) { v.visitTypeBoundKind(this); } 1982 1983 public Kind getKind() { 1984 throw new AssertionError("TypeBoundKind is not part of a public API"); 1985 } 1986 @Override 1987 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1988 throw new AssertionError("TypeBoundKind is not part of a public API"); 1989 } 1990 @Override 1991 public int getTag() { 1992 return TYPEBOUNDKIND; 1993 } 1994 } 1995 1996 public static class JCAnnotation extends JCExpression implements AnnotationTree { 1997 public JCTree annotationType; 1998 public List<JCExpression> args; 1999 protected JCAnnotation(JCTree annotationType, List<JCExpression> args) { 2000 this.annotationType = annotationType; 2001 this.args = args; 2002 } 2003 @Override 2004 public void accept(Visitor v) { v.visitAnnotation(this); } 2005 2006 public Kind getKind() { return Kind.ANNOTATION; } 2007 public JCTree getAnnotationType() { return annotationType; } 2008 public List<JCExpression> getArguments() { 2009 return args; 2010 } 2011 @Override 2012 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2013 return v.visitAnnotation(this, d); 2014 } 2015 @Override 2016 public int getTag() { 2017 return ANNOTATION; 2018 } 2019 } 2020 2021 public static class JCTypeAnnotation extends JCAnnotation { 2022 public TypeAnnotationPosition annotation_position; 2023 public Attribute.TypeCompound attribute_field; 2024 2025 protected JCTypeAnnotation(JCTree annotationType, List<JCExpression> args) { 2026 super(annotationType, args); 2027 this.annotation_position = new TypeAnnotationPosition(); 2028 } 2029 } 2030 2031 public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { 2032 public long flags; 2033 public List<JCAnnotation> annotations; 2034 protected JCModifiers(long flags, List<JCAnnotation> annotations) { 2035 this.flags = flags; 2036 this.annotations = annotations; 2037 } 2038 @Override 2039 public void accept(Visitor v) { v.visitModifiers(this); } 2040 2041 public Kind getKind() { return Kind.MODIFIERS; } 2042 public Set<Modifier> getFlags() { 2043 return Flags.asModifierSet(flags); 2044 } 2045 public List<JCAnnotation> getAnnotations() { 2046 return annotations; 2047 } 2048 @Override 2049 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2050 return v.visitModifiers(this, d); 2051 } 2052 @Override 2053 public int getTag() { 2054 return MODIFIERS; 2055 } 2056 } 2057 2058 public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree { 2059 public List<JCTypeAnnotation> annotations; 2060 public JCExpression underlyingType; 2061 protected JCAnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) { 2062 this.annotations = annotations; 2063 this.underlyingType = underlyingType; 2064 } 2065 @Override 2066 public void accept(Visitor v) { v.visitAnnotatedType(this); } 2067 2068 public Kind getKind() { return Kind.ANNOTATED_TYPE; } 2069 public List<JCTypeAnnotation> getAnnotations() { 2070 return annotations; 2071 } 2072 public JCExpression getUnderlyingType() { 2073 return underlyingType; 2074 } 2075 @Override 2076 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2077 return v.visitAnnotatedType(this, d); 2078 } 2079 @Override 2080 public int getTag() { 2081 return ANNOTATED_TYPE; 2082 } 2083 } 2084 2085 public static class JCErroneous extends JCExpression 2086 implements com.sun.source.tree.ErroneousTree { 2087 public List<? extends JCTree> errs; 2088 protected JCErroneous(List<? extends JCTree> errs) { 2089 this.errs = errs; 2090 } 2091 @Override 2092 public void accept(Visitor v) { v.visitErroneous(this); } 2093 2094 public Kind getKind() { return Kind.ERRONEOUS; } 2095 2096 public List<? extends JCTree> getErrorTrees() { 2097 return errs; 2098 } 2099 2100 @Override 2101 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2102 return v.visitErroneous(this, d); 2103 } 2104 @Override 2105 public int getTag() { 2106 return ERRONEOUS; 2107 } 2108 } 2109 2110 /** (let int x = 3; in x+2) */ 2111 public static class LetExpr extends JCExpression { 2112 public List<JCVariableDecl> defs; 2113 public JCTree expr; 2114 protected LetExpr(List<JCVariableDecl> defs, JCTree expr) { 2115 this.defs = defs; 2116 this.expr = expr; 2117 } 2118 @Override 2119 public void accept(Visitor v) { v.visitLetExpr(this); } 2120 2121 public Kind getKind() { 2122 throw new AssertionError("LetExpr is not part of a public API"); 2123 } 2124 @Override 2125 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2126 throw new AssertionError("LetExpr is not part of a public API"); 2127 } 2128 @Override 2129 public int getTag() { 2130 return LETEXPR; 2131 } 2132 } 2133 2134 /** An interface for tree factories 2135 */ 2136 public interface Factory { 2137 JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations, 2138 JCExpression pid, 2139 List<JCTree> defs); 2140 JCImport Import(JCTree qualid, boolean staticImport); 2141 JCClassDecl ClassDef(JCModifiers mods, 2142 Name name, 2143 List<JCTypeParameter> typarams, 2144 JCTree extending, 2145 List<JCExpression> implementing, 2146 List<JCTree> defs); 2147 JCMethodDecl MethodDef(JCModifiers mods, 2148 Name name, 2149 JCExpression restype, 2150 List<JCTypeParameter> typarams, 2151 List<JCVariableDecl> params, 2152 List<JCTypeAnnotation> receiver, 2153 List<JCExpression> thrown, 2154 JCBlock body, 2155 JCExpression defaultValue); 2156 JCVariableDecl VarDef(JCModifiers mods, 2157 Name name, 2158 JCExpression vartype, 2159 JCExpression init); 2160 JCSkip Skip(); 2161 JCBlock Block(long flags, List<JCStatement> stats); 2162 JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond); 2163 JCWhileLoop WhileLoop(JCExpression cond, JCStatement body); 2164 JCForLoop ForLoop(List<JCStatement> init, 2165 JCExpression cond, 2166 List<JCExpressionStatement> step, 2167 JCStatement body); 2168 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body); 2169 JCLabeledStatement Labelled(Name label, JCStatement body); 2170 JCSwitch Switch(JCExpression selector, List<JCCase> cases); 2171 JCCase Case(JCExpression pat, List<JCStatement> stats); 2172 JCSynchronized Synchronized(JCExpression lock, JCBlock body); 2173 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer); 2174 JCTry Try(JCBlock body, 2175 List<JCCatch> catchers, 2176 JCBlock finalizer, 2177 List<JCTree> resources); 2178 JCCatch Catch(JCVariableDecl param, JCBlock body); 2179 JCConditional Conditional(JCExpression cond, 2180 JCExpression thenpart, 2181 JCExpression elsepart); 2182 JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart); 2183 JCExpressionStatement Exec(JCExpression expr); 2184 JCBreak Break(Name label); 2185 JCContinue Continue(Name label); 2186 JCReturn Return(JCExpression expr); 2187 JCThrow Throw(JCTree expr); 2188 JCAssert Assert(JCExpression cond, JCExpression detail); 2189 JCMethodInvocation Apply(List<JCExpression> typeargs, 2190 JCExpression fn, 2191 List<JCExpression> args); 2192 JCNewClass NewClass(JCExpression encl, 2193 List<JCExpression> typeargs, 2194 JCExpression clazz, 2195 List<JCExpression> args, 2196 JCClassDecl def); 2197 JCNewArray NewArray(JCExpression elemtype, 2198 List<JCExpression> dims, 2199 List<JCExpression> elems); 2200 JCParens Parens(JCExpression expr); 2201 JCAssign Assign(JCExpression lhs, JCExpression rhs); 2202 JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs); 2203 JCUnary Unary(int opcode, JCExpression arg); 2204 JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs); 2205 JCTypeCast TypeCast(JCTree expr, JCExpression type); 2206 JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); 2207 JCArrayAccess Indexed(JCExpression indexed, JCExpression index); 2208 JCFieldAccess Select(JCExpression selected, Name selector); 2209 JCIdent Ident(Name idname); 2210 JCLiteral Literal(int tag, Object value); 2211 JCPrimitiveTypeTree TypeIdent(int typetag); 2212 JCArrayTypeTree TypeArray(JCExpression elemtype); 2213 JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments); 2214 JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds); 2215 JCWildcard Wildcard(TypeBoundKind kind, JCTree type); 2216 TypeBoundKind TypeBoundKind(BoundKind kind); 2217 JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args); 2218 JCModifiers Modifiers(long flags, List<JCAnnotation> annotations); 2219 JCErroneous Erroneous(List<? extends JCTree> errs); 2220 LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr); 2221 } 2222 2223 /** A generic visitor class for trees. 2224 */ 2225 public static abstract class Visitor { 2226 public void visitTopLevel(JCCompilationUnit that) { visitTree(that); } 2227 public void visitImport(JCImport that) { visitTree(that); } 2228 public void visitClassDef(JCClassDecl that) { visitTree(that); } 2229 public void visitMethodDef(JCMethodDecl that) { visitTree(that); } 2230 public void visitVarDef(JCVariableDecl that) { visitTree(that); } 2231 public void visitSkip(JCSkip that) { visitTree(that); } 2232 public void visitBlock(JCBlock that) { visitTree(that); } 2233 public void visitDoLoop(JCDoWhileLoop that) { visitTree(that); } 2234 public void visitWhileLoop(JCWhileLoop that) { visitTree(that); } 2235 public void visitForLoop(JCForLoop that) { visitTree(that); } 2236 public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); } 2237 public void visitLabelled(JCLabeledStatement that) { visitTree(that); } 2238 public void visitSwitch(JCSwitch that) { visitTree(that); } 2239 public void visitCase(JCCase that) { visitTree(that); } 2240 public void visitSynchronized(JCSynchronized that) { visitTree(that); } 2241 public void visitTry(JCTry that) { visitTree(that); } 2242 public void visitCatch(JCCatch that) { visitTree(that); } 2243 public void visitConditional(JCConditional that) { visitTree(that); } 2244 public void visitIf(JCIf that) { visitTree(that); } 2245 public void visitExec(JCExpressionStatement that) { visitTree(that); } 2246 public void visitBreak(JCBreak that) { visitTree(that); } 2247 public void visitContinue(JCContinue that) { visitTree(that); } 2248 public void visitReturn(JCReturn that) { visitTree(that); } 2249 public void visitThrow(JCThrow that) { visitTree(that); } 2250 public void visitAssert(JCAssert that) { visitTree(that); } 2251 public void visitApply(JCMethodInvocation that) { visitTree(that); } 2252 public void visitNewClass(JCNewClass that) { visitTree(that); } 2253 public void visitNewArray(JCNewArray that) { visitTree(that); } 2254 public void visitParens(JCParens that) { visitTree(that); } 2255 public void visitAssign(JCAssign that) { visitTree(that); } 2256 public void visitAssignop(JCAssignOp that) { visitTree(that); } 2257 public void visitUnary(JCUnary that) { visitTree(that); } 2258 public void visitBinary(JCBinary that) { visitTree(that); } 2259 public void visitTypeCast(JCTypeCast that) { visitTree(that); } 2260 public void visitTypeTest(JCInstanceOf that) { visitTree(that); } 2261 public void visitIndexed(JCArrayAccess that) { visitTree(that); } 2262 public void visitSelect(JCFieldAccess that) { visitTree(that); } 2263 public void visitIdent(JCIdent that) { visitTree(that); } 2264 public void visitLiteral(JCLiteral that) { visitTree(that); } 2265 public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); } 2266 public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); } 2267 public void visitTypeApply(JCTypeApply that) { visitTree(that); } 2268 public void visitTypeDisjoint(JCTypeDisjoint that) { visitTree(that); } 2269 public void visitTypeParameter(JCTypeParameter that) { visitTree(that); } 2270 public void visitWildcard(JCWildcard that) { visitTree(that); } 2271 public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); } 2272 public void visitAnnotation(JCAnnotation that) { visitTree(that); } 2273 public void visitModifiers(JCModifiers that) { visitTree(that); } 2274 public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); } 2275 public void visitErroneous(JCErroneous that) { visitTree(that); } 2276 public void visitLetExpr(LetExpr that) { visitTree(that); } 2277 2278 public void visitTree(JCTree that) { assert false; } 2279 } 2280 2281 }