1 /* 2 * Copyright (c) 1999, 2024, 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.io.IOException; 29 import java.io.StringWriter; 30 import java.util.*; 31 32 import javax.lang.model.element.Modifier; 33 import javax.lang.model.type.TypeKind; 34 import javax.tools.JavaFileObject; 35 36 import com.sun.source.tree.*; 37 import com.sun.tools.javac.code.*; 38 import com.sun.tools.javac.code.Directive.RequiresDirective; 39 import com.sun.tools.javac.code.Scope.*; 40 import com.sun.tools.javac.code.Symbol.*; 41 import com.sun.tools.javac.util.*; 42 import com.sun.tools.javac.util.DefinedBy.Api; 43 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 44 import com.sun.tools.javac.util.List; 45 46 import static com.sun.tools.javac.tree.JCTree.Tag.*; 47 48 import javax.tools.JavaFileManager.Location; 49 50 import com.sun.source.tree.ModuleTree.ModuleKind; 51 import com.sun.tools.javac.code.Directive.ExportsDirective; 52 import com.sun.tools.javac.code.Directive.OpensDirective; 53 import com.sun.tools.javac.code.Type.ModuleType; 54 55 /** 56 * Root class for abstract syntax tree nodes. It provides definitions 57 * for specific tree nodes as subclasses nested inside. 58 * 59 * <p>Each subclass is highly standardized. It generally contains 60 * only tree fields for the syntactic subcomponents of the node. Some 61 * classes that represent identifier uses or definitions also define a 62 * Symbol field that denotes the represented identifier. Classes for 63 * non-local jumps also carry the jump target as a field. The root 64 * class Tree itself defines fields for the tree's type and position. 65 * No other fields are kept in a tree node; instead parameters are 66 * passed to methods accessing the node. 67 * 68 * <p>Except for the methods defined by com.sun.source, the only 69 * method defined in subclasses is `visit' which applies a given 70 * visitor to the tree. The actual tree processing is done by visitor 71 * classes in other packages. The abstract class Visitor, as well as 72 * an Factory interface for trees, are defined as inner classes in 73 * Tree. 74 * 75 * <p>To avoid ambiguities with the Tree API in com.sun.source all sub 76 * classes should, by convention, start with JC (javac). 77 * 78 * <p><b>This is NOT part of any supported API. 79 * If you write code that depends on this, you do so at your own risk. 80 * This code and its internal interfaces are subject to change or 81 * deletion without notice.</b> 82 * 83 * @see TreeMaker 84 * @see TreeInfo 85 * @see TreeTranslator 86 * @see Pretty 87 */ 88 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { 89 90 /* Tree tag values, identifying kinds of trees */ 91 public enum Tag { 92 /** For methods that return an invalid tag if a given condition is not met 93 */ 94 NO_TAG, 95 96 /** Toplevel nodes, of type TopLevel, representing entire source files. 97 */ 98 TOPLEVEL, 99 100 /** Package level definitions. 101 */ 102 PACKAGEDEF, 103 104 /** Import clauses, of type Import. 105 */ 106 IMPORT, 107 108 /** Module import clauses. 109 */ 110 MODULEIMPORT, 111 112 /** Class definitions, of type ClassDef. 113 */ 114 CLASSDEF, 115 116 /** Method definitions, of type MethodDef. 117 */ 118 METHODDEF, 119 120 /** Variable definitions, of type VarDef. 121 */ 122 VARDEF, 123 124 /** The no-op statement ";", of type Skip 125 */ 126 SKIP, 127 128 /** Blocks, of type Block. 129 */ 130 BLOCK, 131 132 /** Do-while loops, of type DoLoop. 133 */ 134 DOLOOP, 135 136 /** While-loops, of type WhileLoop. 137 */ 138 WHILELOOP, 139 140 /** For-loops, of type ForLoop. 141 */ 142 FORLOOP, 143 144 /** Foreach-loops, of type ForeachLoop. 145 */ 146 FOREACHLOOP, 147 148 /** Labelled statements, of type Labelled. 149 */ 150 LABELLED, 151 152 /** Switch statements, of type Switch. 153 */ 154 SWITCH, 155 156 /** Case parts in switch statements/expressions, of type Case. 157 */ 158 CASE, 159 160 /** Switch expression statements, of type Switch. 161 */ 162 SWITCH_EXPRESSION, 163 164 /** Synchronized statements, of type Synchronized. 165 */ 166 SYNCHRONIZED, 167 168 /** Try statements, of type Try. 169 */ 170 TRY, 171 172 /** Catch clauses in try statements, of type Catch. 173 */ 174 CATCH, 175 176 /** Conditional expressions, of type Conditional. 177 */ 178 CONDEXPR, 179 180 /** Conditional statements, of type If. 181 */ 182 IF, 183 184 /** Expression statements, of type Exec. 185 */ 186 EXEC, 187 188 /** Break statements, of type Break. 189 */ 190 BREAK, 191 192 /** Yield statements, of type Yield. 193 */ 194 YIELD, 195 196 /** Continue statements, of type Continue. 197 */ 198 CONTINUE, 199 200 /** Return statements, of type Return. 201 */ 202 RETURN, 203 204 /** Throw statements, of type Throw. 205 */ 206 THROW, 207 208 /** Assert statements, of type Assert. 209 */ 210 ASSERT, 211 212 /** Method invocation expressions, of type Apply. 213 */ 214 APPLY, 215 216 /** Class instance creation expressions, of type NewClass. 217 */ 218 NEWCLASS, 219 220 /** Array creation expressions, of type NewArray. 221 */ 222 NEWARRAY, 223 224 /** Lambda expression, of type Lambda. 225 */ 226 LAMBDA, 227 228 /** Parenthesized subexpressions, of type Parens. 229 */ 230 PARENS, 231 232 /** Assignment expressions, of type Assign. 233 */ 234 ASSIGN, 235 236 /** Type cast expressions, of type TypeCast. 237 */ 238 TYPECAST, 239 240 /** Type test expressions, of type TypeTest. 241 */ 242 TYPETEST, 243 244 /** Patterns. 245 */ 246 ANYPATTERN, 247 BINDINGPATTERN, 248 RECORDPATTERN, 249 250 /* Case labels. 251 */ 252 DEFAULTCASELABEL, 253 CONSTANTCASELABEL, 254 PATTERNCASELABEL, 255 256 /** Indexed array expressions, of type Indexed. 257 */ 258 INDEXED, 259 260 /** Selections, of type Select. 261 */ 262 SELECT, 263 264 /** Member references, of type Reference. 265 */ 266 REFERENCE, 267 268 /** Simple identifiers, of type Ident. 269 */ 270 IDENT, 271 272 /** Literals, of type Literal. 273 */ 274 LITERAL, 275 276 /** Basic type identifiers, of type TypeIdent. 277 */ 278 TYPEIDENT, 279 280 /** Array types, of type TypeArray. 281 */ 282 TYPEARRAY, 283 284 /** Parameterized types, of type TypeApply. 285 */ 286 TYPEAPPLY, 287 288 /** Union types, of type TypeUnion. 289 */ 290 TYPEUNION, 291 292 /** Intersection types, of type TypeIntersection. 293 */ 294 TYPEINTERSECTION, 295 296 /** Formal type parameters, of type TypeParameter. 297 */ 298 TYPEPARAMETER, 299 300 /** Type argument. 301 */ 302 WILDCARD, 303 304 /** Bound kind: extends, super, exact, or unbound 305 */ 306 TYPEBOUNDKIND, 307 308 /** metadata: Annotation. 309 */ 310 ANNOTATION, 311 312 /** metadata: Type annotation. 313 */ 314 TYPE_ANNOTATION, 315 316 /** metadata: Modifiers 317 */ 318 MODIFIERS, 319 320 /** An annotated type tree. 321 */ 322 ANNOTATED_TYPE, 323 324 /** Error trees, of type Erroneous. 325 */ 326 ERRONEOUS, 327 328 /** Unary operators, of type Unary. 329 */ 330 POS, // + 331 NEG, // - 332 NOT, // ! 333 COMPL, // ~ 334 PREINC, // ++ _ 335 PREDEC, // -- _ 336 POSTINC, // _ ++ 337 POSTDEC, // _ -- 338 339 /** unary operator for null reference checks, only used internally. 340 */ 341 NULLCHK, 342 343 /** Binary operators, of type Binary. 344 */ 345 OR, // || 346 AND, // && 347 BITOR, // | 348 BITXOR, // ^ 349 BITAND, // & 350 EQ, // == 351 NE, // != 352 LT, // < 353 GT, // > 354 LE, // <= 355 GE, // >= 356 SL, // << 357 SR, // >> 358 USR, // >>> 359 PLUS, // + 360 MINUS, // - 361 MUL, // * 362 DIV, // / 363 MOD, // % 364 365 /** Assignment operators, of type Assignop. 366 */ 367 BITOR_ASG(BITOR), // |= 368 BITXOR_ASG(BITXOR), // ^= 369 BITAND_ASG(BITAND), // &= 370 371 SL_ASG(SL), // <<= 372 SR_ASG(SR), // >>= 373 USR_ASG(USR), // >>>= 374 PLUS_ASG(PLUS), // += 375 MINUS_ASG(MINUS), // -= 376 MUL_ASG(MUL), // *= 377 DIV_ASG(DIV), // /= 378 MOD_ASG(MOD), // %= 379 380 MODULEDEF, 381 EXPORTS, 382 OPENS, 383 PROVIDES, 384 REQUIRES, 385 USES, 386 387 /** A synthetic let expression, of type LetExpr. 388 */ 389 LETEXPR; // ala scheme 390 391 private final Tag noAssignTag; 392 393 private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1; 394 395 private Tag(Tag noAssignTag) { 396 this.noAssignTag = noAssignTag; 397 } 398 399 private Tag() { 400 this(null); 401 } 402 403 public static int getNumberOfOperators() { 404 return numberOfOperators; 405 } 406 407 public Tag noAssignOp() { 408 if (noAssignTag != null) 409 return noAssignTag; 410 throw new AssertionError("noAssignOp() method is not available for non assignment tags"); 411 } 412 413 public boolean isPostUnaryOp() { 414 return (this == POSTINC || this == POSTDEC); 415 } 416 417 public boolean isIncOrDecUnaryOp() { 418 return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC); 419 } 420 421 public boolean isAssignop() { 422 return noAssignTag != null; 423 } 424 425 public int operatorIndex() { 426 return (this.ordinal() - POS.ordinal()); 427 } 428 } 429 430 /* The (encoded) position in the source file. @see util.Position. 431 */ 432 public int pos; 433 434 /* The type of this node. 435 */ 436 public Type type; 437 438 /* The tag of this node -- one of the constants declared above. 439 */ 440 public abstract Tag getTag(); 441 442 /* Returns true if the tag of this node is equals to tag. 443 */ 444 public boolean hasTag(Tag tag) { 445 return tag == getTag(); 446 } 447 448 /** Convert a tree to a pretty-printed string. */ 449 @Override 450 public String toString() { 451 StringWriter s = new StringWriter(); 452 try { 453 new Pretty(s, false).printExpr(this); 454 } 455 catch (IOException e) { 456 // should never happen, because StringWriter is defined 457 // never to throw any IOExceptions 458 throw new AssertionError(e); 459 } 460 return s.toString(); 461 } 462 463 /** Set position field and return this tree. 464 */ 465 public JCTree setPos(int pos) { 466 this.pos = pos; 467 return this; 468 } 469 470 /** Set type field and return this tree. 471 */ 472 public JCTree setType(Type type) { 473 this.type = type; 474 return this; 475 } 476 477 /** Visit this tree with a given visitor. 478 */ 479 public abstract void accept(Visitor v); 480 481 @DefinedBy(Api.COMPILER_TREE) 482 public abstract <R,D> R accept(TreeVisitor<R,D> v, D d); 483 484 /** Return a shallow copy of this tree. 485 */ 486 @Override 487 public Object clone() { 488 try { 489 return super.clone(); 490 } catch(CloneNotSupportedException e) { 491 throw new RuntimeException(e); 492 } 493 } 494 495 /** Get a default position for this tree node. 496 */ 497 public DiagnosticPosition pos() { 498 return this; 499 } 500 501 // for default DiagnosticPosition 502 public JCTree getTree() { 503 return this; 504 } 505 506 // for default DiagnosticPosition 507 public int getStartPosition() { 508 return TreeInfo.getStartPos(this); 509 } 510 511 // for default DiagnosticPosition 512 public int getPreferredPosition() { 513 return pos; 514 } 515 516 // for default DiagnosticPosition 517 public int getEndPosition(EndPosTable endPosTable) { 518 return TreeInfo.getEndPos(this, endPosTable); 519 } 520 521 /** 522 * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure. 523 */ 524 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree { 525 /** All definitions in this file (ClassDef, Import, and Skip) */ 526 public List<JCTree> defs; 527 /** The source file name. */ 528 public JavaFileObject sourcefile; 529 /** The module to which this compilation unit belongs. */ 530 public ModuleSymbol modle; 531 /** The location in which this compilation unit was found. */ 532 public Location locn; 533 /** The package to which this compilation unit belongs. */ 534 public PackageSymbol packge; 535 /** A scope containing top level classes. */ 536 public WriteableScope toplevelScope; 537 /** A scope for all named imports. */ 538 public NamedImportScope namedImportScope; 539 /** A scope for all import-on-demands. */ 540 public StarImportScope starImportScope; 541 /** A scope for all single module imports. */ 542 public StarImportScope moduleImportScope; 543 /** Line starting positions, defined only if option -g is set. */ 544 public Position.LineMap lineMap = null; 545 /** A table that stores all documentation comments indexed by the tree 546 * nodes they refer to. defined only if option -s is set. */ 547 public DocCommentTable docComments = null; 548 /* An object encapsulating ending positions of source ranges indexed by 549 * the tree nodes they belong to. Defined only if option -Xjcov is set. */ 550 public EndPosTable endPositions = null; 551 protected JCCompilationUnit(List<JCTree> defs) { 552 this.defs = defs; 553 } 554 @Override 555 public void accept(Visitor v) { v.visitTopLevel(this); } 556 557 @DefinedBy(Api.COMPILER_TREE) 558 public Kind getKind() { return Kind.COMPILATION_UNIT; } 559 560 public JCModuleDecl getModuleDecl() { 561 for (JCTree tree : defs) { 562 if (tree.hasTag(MODULEDEF)) { 563 return (JCModuleDecl) tree; 564 } 565 } 566 567 return null; 568 } 569 570 @DefinedBy(Api.COMPILER_TREE) 571 public JCModuleDecl getModule() { 572 return getModuleDecl(); 573 } 574 575 @DefinedBy(Api.COMPILER_TREE) 576 public JCPackageDecl getPackage() { 577 // PackageDecl must be the first entry if it exists 578 if (!defs.isEmpty() && defs.head.hasTag(PACKAGEDEF)) 579 return (JCPackageDecl)defs.head; 580 return null; 581 } 582 @DefinedBy(Api.COMPILER_TREE) 583 public List<JCAnnotation> getPackageAnnotations() { 584 JCPackageDecl pd = getPackage(); 585 return pd != null ? pd.getAnnotations() : List.nil(); 586 } 587 @DefinedBy(Api.COMPILER_TREE) 588 public ExpressionTree getPackageName() { 589 JCPackageDecl pd = getPackage(); 590 return pd != null ? pd.getPackageName() : null; 591 } 592 593 @DefinedBy(Api.COMPILER_TREE) 594 public List<JCImportBase> getImports() { 595 ListBuffer<JCImportBase> imports = new ListBuffer<>(); 596 for (JCTree tree : defs) { 597 if (tree instanceof JCImportBase imp) 598 imports.append(imp); 599 else if (!tree.hasTag(PACKAGEDEF) && !tree.hasTag(SKIP)) 600 break; 601 } 602 return imports.toList(); 603 } 604 @DefinedBy(Api.COMPILER_TREE) 605 public JavaFileObject getSourceFile() { 606 return sourcefile; 607 } 608 @DefinedBy(Api.COMPILER_TREE) 609 public Position.LineMap getLineMap() { 610 return lineMap; 611 } 612 @DefinedBy(Api.COMPILER_TREE) 613 public List<JCTree> getTypeDecls() { 614 List<JCTree> typeDefs; 615 for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) { 616 if (!typeDefs.head.hasTag(MODULEDEF) 617 && !typeDefs.head.hasTag(PACKAGEDEF) 618 && !typeDefs.head.hasTag(IMPORT) 619 && !typeDefs.head.hasTag(MODULEIMPORT)) { 620 break; 621 } 622 } 623 return typeDefs; 624 } 625 @Override @DefinedBy(Api.COMPILER_TREE) 626 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 627 return v.visitCompilationUnit(this, d); 628 } 629 630 @Override 631 public Tag getTag() { 632 return TOPLEVEL; 633 } 634 } 635 636 /** 637 * Package definition. 638 */ 639 public static class JCPackageDecl extends JCTree implements PackageTree { 640 public List<JCAnnotation> annotations; 641 /** The tree representing the package clause. */ 642 public JCExpression pid; 643 public PackageSymbol packge; 644 public JCPackageDecl(List<JCAnnotation> annotations, JCExpression pid) { 645 this.annotations = annotations; 646 this.pid = pid; 647 } 648 @Override 649 public void accept(Visitor v) { v.visitPackageDef(this); } 650 @DefinedBy(Api.COMPILER_TREE) 651 public Kind getKind() { 652 return Kind.PACKAGE; 653 } 654 @DefinedBy(Api.COMPILER_TREE) 655 public List<JCAnnotation> getAnnotations() { 656 return annotations; 657 } 658 @DefinedBy(Api.COMPILER_TREE) 659 public JCExpression getPackageName() { 660 return pid; 661 } 662 @Override @DefinedBy(Api.COMPILER_TREE) 663 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 664 return v.visitPackage(this, d); 665 } 666 @Override 667 public Tag getTag() { 668 return PACKAGEDEF; 669 } 670 } 671 672 public static abstract class JCImportBase extends JCTree implements ImportTree { 673 674 @DefinedBy(Api.COMPILER_TREE) 675 public Kind getKind() { return Kind.IMPORT; } 676 @Override @DefinedBy(Api.COMPILER_TREE) 677 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 678 return v.visitImport(this, d); 679 } 680 681 public abstract JCTree getQualifiedIdentifier(); 682 } 683 684 /** 685 * An import clause. 686 */ 687 public static class JCImport extends JCImportBase { 688 public boolean staticImport; 689 /** The imported class(es). */ 690 public JCFieldAccess qualid; 691 public com.sun.tools.javac.code.Scope importScope; 692 protected JCImport(JCFieldAccess qualid, boolean importStatic) { 693 this.qualid = qualid; 694 this.staticImport = importStatic; 695 } 696 @Override 697 public void accept(Visitor v) { v.visitImport(this); } 698 699 @DefinedBy(Api.COMPILER_TREE) 700 public boolean isStatic() { return staticImport; } 701 @DefinedBy(Api.COMPILER_TREE) 702 public boolean isModule() { return false; } 703 @DefinedBy(Api.COMPILER_TREE) 704 public JCFieldAccess getQualifiedIdentifier() { return qualid; } 705 706 @Override 707 public Tag getTag() { 708 return IMPORT; 709 } 710 } 711 712 /** 713 * A module import clause. 714 */ 715 public static class JCModuleImport extends JCImportBase { 716 /** The module name. */ 717 public JCExpression module; 718 protected JCModuleImport(JCExpression module) { 719 this.module = module; 720 } 721 @Override 722 public void accept(Visitor v) { v.visitModuleImport(this); } 723 724 @DefinedBy(Api.COMPILER_TREE) 725 public boolean isStatic() { return false; } 726 @DefinedBy(Api.COMPILER_TREE) 727 public boolean isModule() { return true; } 728 @DefinedBy(Api.COMPILER_TREE) 729 public JCExpression getQualifiedIdentifier() { return module; } 730 731 @DefinedBy(Api.COMPILER_TREE) 732 public Kind getKind() { return Kind.IMPORT; } 733 @Override @DefinedBy(Api.COMPILER_TREE) 734 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 735 return v.visitImport(this, d); 736 } 737 738 @Override 739 public Tag getTag() { 740 return MODULEIMPORT; 741 } 742 } 743 744 public abstract static class JCStatement extends JCTree implements StatementTree { 745 @Override 746 public JCStatement setType(Type type) { 747 super.setType(type); 748 return this; 749 } 750 @Override 751 public JCStatement setPos(int pos) { 752 super.setPos(pos); 753 return this; 754 } 755 } 756 757 public abstract static class JCCaseLabel extends JCTree implements CaseLabelTree { 758 } 759 760 public abstract static class JCExpression extends JCTree implements ExpressionTree { 761 @Override 762 public JCExpression setType(Type type) { 763 super.setType(type); 764 return this; 765 } 766 @Override 767 public JCExpression setPos(int pos) { 768 super.setPos(pos); 769 return this; 770 } 771 772 public boolean isPoly() { return false; } 773 public boolean isStandalone() { return true; } 774 775 } 776 777 /** 778 * Common supertype for all poly expression trees (lambda, method references, 779 * conditionals, method and constructor calls) 780 */ 781 public abstract static class JCPolyExpression extends JCExpression { 782 783 /** 784 * A poly expression can only be truly 'poly' in certain contexts 785 */ 786 public enum PolyKind { 787 /** poly expression to be treated as a standalone expression */ 788 STANDALONE, 789 /** true poly expression */ 790 POLY 791 } 792 793 /** is this poly expression a 'true' poly expression? */ 794 public PolyKind polyKind; 795 796 @Override public boolean isPoly() { return polyKind == PolyKind.POLY; } 797 @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; } 798 } 799 800 /** 801 * Common supertype for all functional expression trees (lambda and method references) 802 */ 803 public abstract static sealed class JCFunctionalExpression extends JCPolyExpression 804 permits JCLambda, JCMemberReference { 805 806 public JCFunctionalExpression() { 807 //a functional expression is always a 'true' poly 808 polyKind = PolyKind.POLY; 809 } 810 811 /** list of target types inferred for this functional expression. */ 812 public Type target; 813 /** The owner of this functional expression. */ 814 public Symbol owner; 815 /** code reflection specific metadata. */ 816 public MethodSymbol codeModel; 817 818 public Type getDescriptorType(Types types) { 819 if (target == null) { 820 return types.createErrorType(null); 821 } else if (target.hasTag(TypeTag.METHOD)) { 822 // this is a quoted expression 823 return target; 824 } else { 825 return types.findDescriptorType(target); 826 } 827 } 828 } 829 830 /** 831 * A class definition. 832 */ 833 public static class JCClassDecl extends JCStatement implements ClassTree { 834 /** the modifiers */ 835 public JCModifiers mods; 836 /** the name of the class */ 837 public Name name; 838 /** formal class parameters */ 839 public List<JCTypeParameter> typarams; 840 /** the classes this class extends */ 841 public JCExpression extending; 842 /** the interfaces implemented by this class */ 843 public List<JCExpression> implementing; 844 /** the subclasses allowed to extend this class, if sealed */ 845 public List<JCExpression> permitting; 846 /** all variables and methods defined in this class */ 847 public List<JCTree> defs; 848 /** the symbol */ 849 public ClassSymbol sym; 850 protected JCClassDecl(JCModifiers mods, 851 Name name, 852 List<JCTypeParameter> typarams, 853 JCExpression extending, 854 List<JCExpression> implementing, 855 List<JCExpression> permitting, 856 List<JCTree> defs, 857 ClassSymbol sym) 858 { 859 this.mods = mods; 860 this.name = name; 861 this.typarams = typarams; 862 this.extending = extending; 863 this.implementing = implementing; 864 this.permitting = permitting; 865 this.defs = defs; 866 this.sym = sym; 867 } 868 @Override 869 public void accept(Visitor v) { v.visitClassDef(this); } 870 871 @DefinedBy(Api.COMPILER_TREE) 872 public Kind getKind() { 873 if ((mods.flags & Flags.ANNOTATION) != 0) 874 return Kind.ANNOTATION_TYPE; 875 else if ((mods.flags & Flags.INTERFACE) != 0) 876 return Kind.INTERFACE; 877 else if ((mods.flags & Flags.ENUM) != 0) 878 return Kind.ENUM; 879 else if ((mods.flags & Flags.RECORD) != 0) 880 return Kind.RECORD; 881 else 882 return Kind.CLASS; 883 } 884 885 @DefinedBy(Api.COMPILER_TREE) 886 public JCModifiers getModifiers() { return mods; } 887 @DefinedBy(Api.COMPILER_TREE) 888 public Name getSimpleName() { return name; } 889 @DefinedBy(Api.COMPILER_TREE) 890 public List<JCTypeParameter> getTypeParameters() { 891 return typarams; 892 } 893 @DefinedBy(Api.COMPILER_TREE) 894 public JCExpression getExtendsClause() { return extending; } 895 @DefinedBy(Api.COMPILER_TREE) 896 public List<JCExpression> getImplementsClause() { 897 return implementing; 898 } 899 @DefinedBy(Api.COMPILER_TREE) 900 public List<JCExpression> getPermitsClause() { 901 return permitting; 902 } 903 @DefinedBy(Api.COMPILER_TREE) 904 public List<JCTree> getMembers() { 905 return defs; 906 } 907 @Override @DefinedBy(Api.COMPILER_TREE) 908 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 909 return v.visitClass(this, d); 910 } 911 912 @Override 913 public Tag getTag() { 914 return CLASSDEF; 915 } 916 } 917 918 /** 919 * A method definition. 920 */ 921 public static class JCMethodDecl extends JCTree implements MethodTree { 922 /** method modifiers */ 923 public JCModifiers mods; 924 /** method name */ 925 public Name name; 926 /** type of method return value */ 927 public JCExpression restype; 928 /** type parameters */ 929 public List<JCTypeParameter> typarams; 930 /** receiver parameter */ 931 public JCVariableDecl recvparam; 932 /** value parameters */ 933 public List<JCVariableDecl> params; 934 /** exceptions thrown by this method */ 935 public List<JCExpression> thrown; 936 /** statements in the method */ 937 public JCBlock body; 938 /** default value, for annotation types */ 939 public JCExpression defaultValue; 940 /** method symbol */ 941 public MethodSymbol sym; 942 /** does this method completes normally */ 943 public boolean completesNormally; 944 945 protected JCMethodDecl(JCModifiers mods, 946 Name name, 947 JCExpression restype, 948 List<JCTypeParameter> typarams, 949 JCVariableDecl recvparam, 950 List<JCVariableDecl> params, 951 List<JCExpression> thrown, 952 JCBlock body, 953 JCExpression defaultValue, 954 MethodSymbol sym) 955 { 956 this.mods = mods; 957 this.name = name; 958 this.restype = restype; 959 this.typarams = typarams; 960 this.params = params; 961 this.recvparam = recvparam; 962 // TODO: do something special if the given type is null? 963 // receiver != null ? receiver : List.<JCTypeAnnotation>nil()); 964 this.thrown = thrown; 965 this.body = body; 966 this.defaultValue = defaultValue; 967 this.sym = sym; 968 } 969 @Override 970 public void accept(Visitor v) { v.visitMethodDef(this); } 971 972 @DefinedBy(Api.COMPILER_TREE) 973 public Kind getKind() { return Kind.METHOD; } 974 @DefinedBy(Api.COMPILER_TREE) 975 public JCModifiers getModifiers() { return mods; } 976 @DefinedBy(Api.COMPILER_TREE) 977 public Name getName() { return name; } 978 @DefinedBy(Api.COMPILER_TREE) 979 public JCTree getReturnType() { return restype; } 980 @DefinedBy(Api.COMPILER_TREE) 981 public List<JCTypeParameter> getTypeParameters() { 982 return typarams; 983 } 984 @DefinedBy(Api.COMPILER_TREE) 985 public List<JCVariableDecl> getParameters() { 986 return params; 987 } 988 @DefinedBy(Api.COMPILER_TREE) 989 public JCVariableDecl getReceiverParameter() { return recvparam; } 990 @DefinedBy(Api.COMPILER_TREE) 991 public List<JCExpression> getThrows() { 992 return thrown; 993 } 994 @DefinedBy(Api.COMPILER_TREE) 995 public JCBlock getBody() { return body; } 996 @DefinedBy(Api.COMPILER_TREE) 997 public JCTree getDefaultValue() { // for annotation types 998 return defaultValue; 999 } 1000 @Override @DefinedBy(Api.COMPILER_TREE) 1001 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1002 return v.visitMethod(this, d); 1003 } 1004 1005 @Override 1006 public Tag getTag() { 1007 return METHODDEF; 1008 } 1009 } 1010 1011 /** 1012 * A variable definition. 1013 */ 1014 public static class JCVariableDecl extends JCStatement implements VariableTree { 1015 /** variable modifiers */ 1016 public JCModifiers mods; 1017 /** variable name */ 1018 public Name name; 1019 /** variable name expression */ 1020 public JCExpression nameexpr; 1021 /** type of the variable */ 1022 public JCExpression vartype; 1023 /** variable's initial value */ 1024 public JCExpression init; 1025 /** symbol */ 1026 public VarSymbol sym; 1027 /** explicit start pos */ 1028 public int startPos = Position.NOPOS; 1029 /** declared using `var` */ 1030 private boolean declaredUsingVar; 1031 1032 protected JCVariableDecl(JCModifiers mods, 1033 Name name, 1034 JCExpression vartype, 1035 JCExpression init, 1036 VarSymbol sym) { 1037 this(mods, name, vartype, init, sym, false); 1038 } 1039 1040 protected JCVariableDecl(JCModifiers mods, 1041 Name name, 1042 JCExpression vartype, 1043 JCExpression init, 1044 VarSymbol sym, 1045 boolean declaredUsingVar) { 1046 this.mods = mods; 1047 this.name = name; 1048 this.vartype = vartype; 1049 this.init = init; 1050 this.sym = sym; 1051 this.declaredUsingVar = declaredUsingVar; 1052 } 1053 1054 protected JCVariableDecl(JCModifiers mods, 1055 JCExpression nameexpr, 1056 JCExpression vartype) { 1057 this(mods, null, vartype, null, null, false); 1058 this.nameexpr = nameexpr; 1059 if (nameexpr.hasTag(Tag.IDENT)) { 1060 this.name = ((JCIdent)nameexpr).name; 1061 } else { 1062 // Only other option is qualified name x.y.this; 1063 this.name = ((JCFieldAccess)nameexpr).name; 1064 } 1065 } 1066 1067 public boolean isImplicitlyTyped() { 1068 return vartype == null; 1069 } 1070 1071 public boolean declaredUsingVar() { 1072 return declaredUsingVar; 1073 } 1074 1075 @Override 1076 public void accept(Visitor v) { v.visitVarDef(this); } 1077 1078 @DefinedBy(Api.COMPILER_TREE) 1079 public Kind getKind() { return Kind.VARIABLE; } 1080 @DefinedBy(Api.COMPILER_TREE) 1081 public JCModifiers getModifiers() { return mods; } 1082 @DefinedBy(Api.COMPILER_TREE) 1083 public Name getName() { return name; } 1084 @DefinedBy(Api.COMPILER_TREE) 1085 public JCExpression getNameExpression() { return nameexpr; } 1086 @DefinedBy(Api.COMPILER_TREE) 1087 public JCTree getType() { return vartype; } 1088 @DefinedBy(Api.COMPILER_TREE) 1089 public JCExpression getInitializer() { 1090 return init; 1091 } 1092 @Override @DefinedBy(Api.COMPILER_TREE) 1093 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1094 return v.visitVariable(this, d); 1095 } 1096 1097 @Override 1098 public Tag getTag() { 1099 return VARDEF; 1100 } 1101 } 1102 1103 /** 1104 * A no-op statement ";". 1105 */ 1106 public static class JCSkip extends JCStatement implements EmptyStatementTree { 1107 protected JCSkip() { 1108 } 1109 @Override 1110 public void accept(Visitor v) { v.visitSkip(this); } 1111 1112 @DefinedBy(Api.COMPILER_TREE) 1113 public Kind getKind() { return Kind.EMPTY_STATEMENT; } 1114 @Override @DefinedBy(Api.COMPILER_TREE) 1115 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1116 return v.visitEmptyStatement(this, d); 1117 } 1118 1119 @Override 1120 public Tag getTag() { 1121 return SKIP; 1122 } 1123 } 1124 1125 /** 1126 * A statement block. 1127 */ 1128 public static class JCBlock extends JCStatement implements BlockTree { 1129 /** flags */ 1130 public long flags; 1131 /** statements */ 1132 public List<JCStatement> stats; 1133 /** Position of closing brace, optional. */ 1134 public int endpos = Position.NOPOS; 1135 /** If this block contains record pattern, it is necessary to catch 1136 * exceptions from the deconstructors and wrap them. 1137 * The {@code patternMatchingCatch} keeps the list of the deconstructor 1138 * invocations, and the additional catch block that wraps the exceptions. 1139 */ 1140 public PatternMatchingCatch patternMatchingCatch; 1141 protected JCBlock(long flags, List<JCStatement> stats) { 1142 this.stats = stats; 1143 this.flags = flags; 1144 } 1145 @Override 1146 public void accept(Visitor v) { v.visitBlock(this); } 1147 1148 @DefinedBy(Api.COMPILER_TREE) 1149 public Kind getKind() { return Kind.BLOCK; } 1150 @DefinedBy(Api.COMPILER_TREE) 1151 public List<JCStatement> getStatements() { 1152 return stats; 1153 } 1154 @DefinedBy(Api.COMPILER_TREE) 1155 public boolean isStatic() { return (flags & Flags.STATIC) != 0; } 1156 @Override @DefinedBy(Api.COMPILER_TREE) 1157 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1158 return v.visitBlock(this, d); 1159 } 1160 1161 @Override 1162 public Tag getTag() { 1163 return BLOCK; 1164 } 1165 1166 public record PatternMatchingCatch(JCCatch handler, Set<JCMethodInvocation> calls2Handle) {} 1167 } 1168 1169 /** 1170 * A do loop 1171 */ 1172 public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree { 1173 public JCStatement body; 1174 public JCExpression cond; 1175 protected JCDoWhileLoop(JCStatement body, JCExpression cond) { 1176 this.body = body; 1177 this.cond = cond; 1178 } 1179 @Override 1180 public void accept(Visitor v) { v.visitDoLoop(this); } 1181 1182 @DefinedBy(Api.COMPILER_TREE) 1183 public Kind getKind() { return Kind.DO_WHILE_LOOP; } 1184 @DefinedBy(Api.COMPILER_TREE) 1185 public JCExpression getCondition() { return cond; } 1186 @DefinedBy(Api.COMPILER_TREE) 1187 public JCStatement getStatement() { return body; } 1188 @Override @DefinedBy(Api.COMPILER_TREE) 1189 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1190 return v.visitDoWhileLoop(this, d); 1191 } 1192 1193 @Override 1194 public Tag getTag() { 1195 return DOLOOP; 1196 } 1197 } 1198 1199 /** 1200 * A while loop 1201 */ 1202 public static class JCWhileLoop extends JCStatement implements WhileLoopTree { 1203 public JCExpression cond; 1204 public JCStatement body; 1205 protected JCWhileLoop(JCExpression cond, JCStatement body) { 1206 this.cond = cond; 1207 this.body = body; 1208 } 1209 @Override 1210 public void accept(Visitor v) { v.visitWhileLoop(this); } 1211 1212 @DefinedBy(Api.COMPILER_TREE) 1213 public Kind getKind() { return Kind.WHILE_LOOP; } 1214 @DefinedBy(Api.COMPILER_TREE) 1215 public JCExpression getCondition() { return cond; } 1216 @DefinedBy(Api.COMPILER_TREE) 1217 public JCStatement getStatement() { return body; } 1218 @Override @DefinedBy(Api.COMPILER_TREE) 1219 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1220 return v.visitWhileLoop(this, d); 1221 } 1222 1223 @Override 1224 public Tag getTag() { 1225 return WHILELOOP; 1226 } 1227 } 1228 1229 /** 1230 * A for loop. 1231 */ 1232 public static class JCForLoop extends JCStatement implements ForLoopTree { 1233 public List<JCStatement> init; 1234 public JCExpression cond; 1235 public List<JCExpressionStatement> step; 1236 public JCStatement body; 1237 protected JCForLoop(List<JCStatement> init, 1238 JCExpression cond, 1239 List<JCExpressionStatement> update, 1240 JCStatement body) 1241 { 1242 this.init = init; 1243 this.cond = cond; 1244 this.step = update; 1245 this.body = body; 1246 } 1247 @Override 1248 public void accept(Visitor v) { v.visitForLoop(this); } 1249 1250 @DefinedBy(Api.COMPILER_TREE) 1251 public Kind getKind() { return Kind.FOR_LOOP; } 1252 @DefinedBy(Api.COMPILER_TREE) 1253 public JCExpression getCondition() { return cond; } 1254 @DefinedBy(Api.COMPILER_TREE) 1255 public JCStatement getStatement() { return body; } 1256 @DefinedBy(Api.COMPILER_TREE) 1257 public List<JCStatement> getInitializer() { 1258 return init; 1259 } 1260 @DefinedBy(Api.COMPILER_TREE) 1261 public List<JCExpressionStatement> getUpdate() { 1262 return step; 1263 } 1264 @Override @DefinedBy(Api.COMPILER_TREE) 1265 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1266 return v.visitForLoop(this, d); 1267 } 1268 1269 @Override 1270 public Tag getTag() { 1271 return FORLOOP; 1272 } 1273 } 1274 1275 /** 1276 * The enhanced for loop. 1277 */ 1278 public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree { 1279 public JCVariableDecl var; 1280 public JCExpression expr; 1281 public JCStatement body; 1282 protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { 1283 this.var = var; 1284 this.expr = expr; 1285 this.body = body; 1286 } 1287 @Override 1288 public void accept(Visitor v) { v.visitForeachLoop(this); } 1289 1290 @DefinedBy(Api.COMPILER_TREE) 1291 public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; } 1292 @DefinedBy(Api.COMPILER_TREE) 1293 public JCVariableDecl getVariable() { return var; } 1294 @DefinedBy(Api.COMPILER_TREE) 1295 public JCExpression getExpression() { return expr; } 1296 @DefinedBy(Api.COMPILER_TREE) 1297 public JCStatement getStatement() { return body; } 1298 @Override @DefinedBy(Api.COMPILER_TREE) 1299 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1300 return v.visitEnhancedForLoop(this, d); 1301 } 1302 @Override 1303 public Tag getTag() { 1304 return FOREACHLOOP; 1305 } 1306 } 1307 1308 /** 1309 * A labelled expression or statement. 1310 */ 1311 public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree { 1312 public Name label; 1313 public JCStatement body; 1314 protected JCLabeledStatement(Name label, JCStatement body) { 1315 this.label = label; 1316 this.body = body; 1317 } 1318 @Override 1319 public void accept(Visitor v) { v.visitLabelled(this); } 1320 @DefinedBy(Api.COMPILER_TREE) 1321 public Kind getKind() { return Kind.LABELED_STATEMENT; } 1322 @DefinedBy(Api.COMPILER_TREE) 1323 public Name getLabel() { return label; } 1324 @DefinedBy(Api.COMPILER_TREE) 1325 public JCStatement getStatement() { return body; } 1326 @Override @DefinedBy(Api.COMPILER_TREE) 1327 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1328 return v.visitLabeledStatement(this, d); 1329 } 1330 @Override 1331 public Tag getTag() { 1332 return LABELLED; 1333 } 1334 } 1335 1336 /** 1337 * A "switch ( ) { }" construction. 1338 */ 1339 public static class JCSwitch extends JCStatement implements SwitchTree { 1340 public JCExpression selector; 1341 public List<JCCase> cases; 1342 /** Position of closing brace, optional. */ 1343 public int endpos = Position.NOPOS; 1344 public boolean hasUnconditionalPattern; 1345 public boolean isExhaustive; 1346 public boolean patternSwitch; 1347 public boolean wasEnumSelector; 1348 protected JCSwitch(JCExpression selector, List<JCCase> cases) { 1349 this.selector = selector; 1350 this.cases = cases; 1351 } 1352 @Override 1353 public void accept(Visitor v) { v.visitSwitch(this); } 1354 1355 @DefinedBy(Api.COMPILER_TREE) 1356 public Kind getKind() { return Kind.SWITCH; } 1357 @DefinedBy(Api.COMPILER_TREE) 1358 public JCExpression getExpression() { return selector; } 1359 @DefinedBy(Api.COMPILER_TREE) 1360 public List<JCCase> getCases() { return cases; } 1361 @Override @DefinedBy(Api.COMPILER_TREE) 1362 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1363 return v.visitSwitch(this, d); 1364 } 1365 @Override 1366 public Tag getTag() { 1367 return SWITCH; 1368 } 1369 } 1370 1371 /** 1372 * A "case :" of a switch. 1373 */ 1374 public static class JCCase extends JCStatement implements CaseTree { 1375 //as CaseKind is deprecated for removal (as it is part of a preview feature), 1376 //using indirection through these fields to avoid unnecessary @SuppressWarnings: 1377 public static final CaseKind STATEMENT = CaseKind.STATEMENT; 1378 public static final CaseKind RULE = CaseKind.RULE; 1379 public final CaseKind caseKind; 1380 public List<JCCaseLabel> labels; 1381 public JCExpression guard; 1382 public List<JCStatement> stats; 1383 public JCTree body; 1384 public boolean completesNormally; 1385 protected JCCase(CaseKind caseKind, List<JCCaseLabel> labels, 1386 JCExpression guard, 1387 List<JCStatement> stats, JCTree body) { 1388 Assert.checkNonNull(labels); 1389 Assert.check(labels.isEmpty() || labels.head != null); 1390 this.caseKind = caseKind; 1391 this.labels = labels; 1392 this.guard = guard; 1393 this.stats = stats; 1394 this.body = body; 1395 } 1396 @Override 1397 public void accept(Visitor v) { v.visitCase(this); } 1398 1399 @Override @DefinedBy(Api.COMPILER_TREE) 1400 public Kind getKind() { return Kind.CASE; } 1401 @Override @Deprecated @DefinedBy(Api.COMPILER_TREE) 1402 public JCExpression getExpression() { return getExpressions().head; } 1403 1404 @Override @DefinedBy(Api.COMPILER_TREE) 1405 public List<JCExpression> getExpressions() { 1406 return labels.stream() 1407 .filter(p -> p.hasTag(CONSTANTCASELABEL)) 1408 .map(p -> ((JCConstantCaseLabel) p).expr) 1409 .collect(List.collector()); 1410 } 1411 1412 @Override @DefinedBy(Api.COMPILER_TREE) 1413 public List<JCCaseLabel> getLabels() { return labels; } 1414 @Override @DefinedBy(Api.COMPILER_TREE) 1415 public JCExpression getGuard() { return guard; } 1416 @Override @DefinedBy(Api.COMPILER_TREE) 1417 public List<JCStatement> getStatements() { 1418 return caseKind == CaseKind.STATEMENT ? stats : null; 1419 } 1420 @Override @DefinedBy(Api.COMPILER_TREE) 1421 public JCTree getBody() { return body; } 1422 @Override @DefinedBy(Api.COMPILER_TREE) 1423 public CaseKind getCaseKind() { 1424 return caseKind; 1425 } 1426 @Override @DefinedBy(Api.COMPILER_TREE) 1427 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1428 return v.visitCase(this, d); 1429 } 1430 @Override 1431 public Tag getTag() { 1432 return CASE; 1433 } 1434 } 1435 1436 /** 1437 * A "switch ( ) { }" construction. 1438 */ 1439 public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree { 1440 public JCExpression selector; 1441 public List<JCCase> cases; 1442 /** Position of closing brace, optional. */ 1443 public int endpos = Position.NOPOS; 1444 public boolean hasUnconditionalPattern; 1445 public boolean isExhaustive; 1446 public boolean patternSwitch; 1447 public boolean wasEnumSelector; 1448 protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) { 1449 this.selector = selector; 1450 this.cases = cases; 1451 } 1452 @Override 1453 public void accept(Visitor v) { v.visitSwitchExpression(this); } 1454 1455 @DefinedBy(Api.COMPILER_TREE) 1456 public Kind getKind() { return Kind.SWITCH_EXPRESSION; } 1457 @DefinedBy(Api.COMPILER_TREE) 1458 public JCExpression getExpression() { return selector; } 1459 @DefinedBy(Api.COMPILER_TREE) 1460 public List<JCCase> getCases() { return cases; } 1461 @Override @DefinedBy(Api.COMPILER_TREE) 1462 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1463 return v.visitSwitchExpression(this, d); 1464 } 1465 @Override 1466 public Tag getTag() { 1467 return SWITCH_EXPRESSION; 1468 } 1469 } 1470 1471 /** 1472 * A synchronized block. 1473 */ 1474 public static class JCSynchronized extends JCStatement implements SynchronizedTree { 1475 public JCExpression lock; 1476 public JCBlock body; 1477 protected JCSynchronized(JCExpression lock, JCBlock body) { 1478 this.lock = lock; 1479 this.body = body; 1480 } 1481 @Override 1482 public void accept(Visitor v) { v.visitSynchronized(this); } 1483 1484 @DefinedBy(Api.COMPILER_TREE) 1485 public Kind getKind() { return Kind.SYNCHRONIZED; } 1486 @DefinedBy(Api.COMPILER_TREE) 1487 public JCExpression getExpression() { return lock; } 1488 @DefinedBy(Api.COMPILER_TREE) 1489 public JCBlock getBlock() { return body; } 1490 @Override @DefinedBy(Api.COMPILER_TREE) 1491 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1492 return v.visitSynchronized(this, d); 1493 } 1494 @Override 1495 public Tag getTag() { 1496 return SYNCHRONIZED; 1497 } 1498 } 1499 1500 /** 1501 * A "try { } catch ( ) { } finally { }" block. 1502 */ 1503 public static class JCTry extends JCStatement implements TryTree { 1504 public JCBlock body; 1505 public List<JCCatch> catchers; 1506 public JCBlock finalizer; 1507 public List<JCTree> resources; 1508 public boolean finallyCanCompleteNormally; 1509 protected JCTry(List<JCTree> resources, 1510 JCBlock body, 1511 List<JCCatch> catchers, 1512 JCBlock finalizer) { 1513 this.body = body; 1514 this.catchers = catchers; 1515 this.finalizer = finalizer; 1516 this.resources = resources; 1517 } 1518 @Override 1519 public void accept(Visitor v) { v.visitTry(this); } 1520 1521 @DefinedBy(Api.COMPILER_TREE) 1522 public Kind getKind() { return Kind.TRY; } 1523 @DefinedBy(Api.COMPILER_TREE) 1524 public JCBlock getBlock() { return body; } 1525 @DefinedBy(Api.COMPILER_TREE) 1526 public List<JCCatch> getCatches() { 1527 return catchers; 1528 } 1529 @DefinedBy(Api.COMPILER_TREE) 1530 public JCBlock getFinallyBlock() { return finalizer; } 1531 @Override @DefinedBy(Api.COMPILER_TREE) 1532 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1533 return v.visitTry(this, d); 1534 } 1535 @Override @DefinedBy(Api.COMPILER_TREE) 1536 public List<JCTree> getResources() { 1537 return resources; 1538 } 1539 @Override 1540 public Tag getTag() { 1541 return TRY; 1542 } 1543 } 1544 1545 /** 1546 * A catch block. 1547 */ 1548 public static class JCCatch extends JCTree implements CatchTree { 1549 public JCVariableDecl param; 1550 public JCBlock body; 1551 protected JCCatch(JCVariableDecl param, JCBlock body) { 1552 this.param = param; 1553 this.body = body; 1554 } 1555 @Override 1556 public void accept(Visitor v) { v.visitCatch(this); } 1557 1558 @DefinedBy(Api.COMPILER_TREE) 1559 public Kind getKind() { return Kind.CATCH; } 1560 @DefinedBy(Api.COMPILER_TREE) 1561 public JCVariableDecl getParameter() { return param; } 1562 @DefinedBy(Api.COMPILER_TREE) 1563 public JCBlock getBlock() { return body; } 1564 @Override @DefinedBy(Api.COMPILER_TREE) 1565 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1566 return v.visitCatch(this, d); 1567 } 1568 @Override 1569 public Tag getTag() { 1570 return CATCH; 1571 } 1572 } 1573 1574 /** 1575 * A ( ) ? ( ) : ( ) conditional expression 1576 */ 1577 public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree { 1578 public JCExpression cond; 1579 public JCExpression truepart; 1580 public JCExpression falsepart; 1581 protected JCConditional(JCExpression cond, 1582 JCExpression truepart, 1583 JCExpression falsepart) 1584 { 1585 this.cond = cond; 1586 this.truepart = truepart; 1587 this.falsepart = falsepart; 1588 } 1589 @Override 1590 public void accept(Visitor v) { v.visitConditional(this); } 1591 1592 @DefinedBy(Api.COMPILER_TREE) 1593 public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; } 1594 @DefinedBy(Api.COMPILER_TREE) 1595 public JCExpression getCondition() { return cond; } 1596 @DefinedBy(Api.COMPILER_TREE) 1597 public JCExpression getTrueExpression() { return truepart; } 1598 @DefinedBy(Api.COMPILER_TREE) 1599 public JCExpression getFalseExpression() { return falsepart; } 1600 @Override @DefinedBy(Api.COMPILER_TREE) 1601 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1602 return v.visitConditionalExpression(this, d); 1603 } 1604 @Override 1605 public Tag getTag() { 1606 return CONDEXPR; 1607 } 1608 } 1609 1610 /** 1611 * An "if ( ) { } else { }" block 1612 */ 1613 public static class JCIf extends JCStatement implements IfTree { 1614 public JCExpression cond; 1615 public JCStatement thenpart; 1616 public JCStatement elsepart; 1617 protected JCIf(JCExpression cond, 1618 JCStatement thenpart, 1619 JCStatement elsepart) 1620 { 1621 this.cond = cond; 1622 this.thenpart = thenpart; 1623 this.elsepart = elsepart; 1624 } 1625 @Override 1626 public void accept(Visitor v) { v.visitIf(this); } 1627 1628 @DefinedBy(Api.COMPILER_TREE) 1629 public Kind getKind() { return Kind.IF; } 1630 @DefinedBy(Api.COMPILER_TREE) 1631 public JCExpression getCondition() { return cond; } 1632 @DefinedBy(Api.COMPILER_TREE) 1633 public JCStatement getThenStatement() { return thenpart; } 1634 @DefinedBy(Api.COMPILER_TREE) 1635 public JCStatement getElseStatement() { return elsepart; } 1636 @Override @DefinedBy(Api.COMPILER_TREE) 1637 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1638 return v.visitIf(this, d); 1639 } 1640 @Override 1641 public Tag getTag() { 1642 return IF; 1643 } 1644 } 1645 1646 /** 1647 * an expression statement 1648 */ 1649 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree { 1650 /** expression structure */ 1651 public JCExpression expr; 1652 protected JCExpressionStatement(JCExpression expr) 1653 { 1654 this.expr = expr; 1655 } 1656 @Override 1657 public void accept(Visitor v) { v.visitExec(this); } 1658 1659 @DefinedBy(Api.COMPILER_TREE) 1660 public Kind getKind() { return Kind.EXPRESSION_STATEMENT; } 1661 @DefinedBy(Api.COMPILER_TREE) 1662 public JCExpression getExpression() { return expr; } 1663 @Override @DefinedBy(Api.COMPILER_TREE) 1664 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1665 return v.visitExpressionStatement(this, d); 1666 } 1667 @Override 1668 public Tag getTag() { 1669 return EXEC; 1670 } 1671 1672 /** Convert a expression-statement tree to a pretty-printed string. */ 1673 @Override 1674 public String toString() { 1675 StringWriter s = new StringWriter(); 1676 try { 1677 new Pretty(s, false).printStat(this); 1678 } 1679 catch (IOException e) { 1680 // should never happen, because StringWriter is defined 1681 // never to throw any IOExceptions 1682 throw new AssertionError(e); 1683 } 1684 return s.toString(); 1685 } 1686 } 1687 1688 /** 1689 * A break from a loop or switch. 1690 */ 1691 public static class JCBreak extends JCStatement implements BreakTree { 1692 public Name label; 1693 public JCTree target; 1694 protected JCBreak(Name label, JCTree target) { 1695 this.label = label; 1696 this.target = target; 1697 } 1698 @Override 1699 public void accept(Visitor v) { v.visitBreak(this); } 1700 public boolean isValueBreak() { 1701 return target != null && target.hasTag(SWITCH_EXPRESSION); 1702 } 1703 1704 @DefinedBy(Api.COMPILER_TREE) 1705 public Kind getKind() { return Kind.BREAK; } 1706 @DefinedBy(Api.COMPILER_TREE) 1707 public Name getLabel() { 1708 return label; 1709 } 1710 @Override @DefinedBy(Api.COMPILER_TREE) 1711 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1712 return v.visitBreak(this, d); 1713 } 1714 @Override 1715 public Tag getTag() { 1716 return BREAK; 1717 } 1718 } 1719 1720 /** 1721 * A break-with from a switch expression. 1722 */ 1723 public static class JCYield extends JCStatement implements YieldTree { 1724 public JCExpression value; 1725 public JCTree target; 1726 protected JCYield(JCExpression value, JCTree target) { 1727 this.value = value; 1728 this.target = target; 1729 } 1730 @Override 1731 public void accept(Visitor v) { v.visitYield(this); } 1732 @DefinedBy(Api.COMPILER_TREE) 1733 public Kind getKind() { return Kind.YIELD; } 1734 @DefinedBy(Api.COMPILER_TREE) 1735 public JCExpression getValue() { return value; } 1736 @Override @DefinedBy(Api.COMPILER_TREE) 1737 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1738 return v.visitYield(this, d); 1739 } 1740 @Override 1741 public Tag getTag() { 1742 return YIELD; 1743 } 1744 } 1745 1746 /** 1747 * A continue of a loop. 1748 */ 1749 public static class JCContinue extends JCStatement implements ContinueTree { 1750 public Name label; 1751 public JCTree target; 1752 protected JCContinue(Name label, JCTree target) { 1753 this.label = label; 1754 this.target = target; 1755 } 1756 @Override 1757 public void accept(Visitor v) { v.visitContinue(this); } 1758 1759 @DefinedBy(Api.COMPILER_TREE) 1760 public Kind getKind() { return Kind.CONTINUE; } 1761 @DefinedBy(Api.COMPILER_TREE) 1762 public Name getLabel() { return label; } 1763 @Override @DefinedBy(Api.COMPILER_TREE) 1764 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1765 return v.visitContinue(this, d); 1766 } 1767 @Override 1768 public Tag getTag() { 1769 return CONTINUE; 1770 } 1771 } 1772 1773 /** 1774 * A return statement. 1775 */ 1776 public static class JCReturn extends JCStatement implements ReturnTree { 1777 public JCExpression expr; 1778 protected JCReturn(JCExpression expr) { 1779 this.expr = expr; 1780 } 1781 @Override 1782 public void accept(Visitor v) { v.visitReturn(this); } 1783 1784 @DefinedBy(Api.COMPILER_TREE) 1785 public Kind getKind() { return Kind.RETURN; } 1786 @DefinedBy(Api.COMPILER_TREE) 1787 public JCExpression getExpression() { return expr; } 1788 @Override @DefinedBy(Api.COMPILER_TREE) 1789 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1790 return v.visitReturn(this, d); 1791 } 1792 @Override 1793 public Tag getTag() { 1794 return RETURN; 1795 } 1796 } 1797 1798 /** 1799 * A throw statement. 1800 */ 1801 public static class JCThrow extends JCStatement implements ThrowTree { 1802 public JCExpression expr; 1803 protected JCThrow(JCExpression expr) { 1804 this.expr = expr; 1805 } 1806 @Override 1807 public void accept(Visitor v) { v.visitThrow(this); } 1808 1809 @DefinedBy(Api.COMPILER_TREE) 1810 public Kind getKind() { return Kind.THROW; } 1811 @DefinedBy(Api.COMPILER_TREE) 1812 public JCExpression getExpression() { return expr; } 1813 @Override @DefinedBy(Api.COMPILER_TREE) 1814 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1815 return v.visitThrow(this, d); 1816 } 1817 @Override 1818 public Tag getTag() { 1819 return THROW; 1820 } 1821 } 1822 1823 /** 1824 * An assert statement. 1825 */ 1826 public static class JCAssert extends JCStatement implements AssertTree { 1827 public JCExpression cond; 1828 public JCExpression detail; 1829 protected JCAssert(JCExpression cond, JCExpression detail) { 1830 this.cond = cond; 1831 this.detail = detail; 1832 } 1833 @Override 1834 public void accept(Visitor v) { v.visitAssert(this); } 1835 1836 @DefinedBy(Api.COMPILER_TREE) 1837 public Kind getKind() { return Kind.ASSERT; } 1838 @DefinedBy(Api.COMPILER_TREE) 1839 public JCExpression getCondition() { return cond; } 1840 @DefinedBy(Api.COMPILER_TREE) 1841 public JCExpression getDetail() { return detail; } 1842 @Override @DefinedBy(Api.COMPILER_TREE) 1843 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1844 return v.visitAssert(this, d); 1845 } 1846 @Override 1847 public Tag getTag() { 1848 return ASSERT; 1849 } 1850 } 1851 1852 /** 1853 * A method invocation 1854 */ 1855 public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree { 1856 public List<JCExpression> typeargs; 1857 public JCExpression meth; 1858 public List<JCExpression> args; 1859 public Type varargsElement; 1860 protected JCMethodInvocation(List<JCExpression> typeargs, 1861 JCExpression meth, 1862 List<JCExpression> args) 1863 { 1864 this.typeargs = (typeargs == null) ? List.nil() 1865 : typeargs; 1866 this.meth = meth; 1867 this.args = args; 1868 } 1869 @Override 1870 public void accept(Visitor v) { v.visitApply(this); } 1871 1872 @DefinedBy(Api.COMPILER_TREE) 1873 public Kind getKind() { return Kind.METHOD_INVOCATION; } 1874 @DefinedBy(Api.COMPILER_TREE) 1875 public List<JCExpression> getTypeArguments() { 1876 return typeargs; 1877 } 1878 @DefinedBy(Api.COMPILER_TREE) 1879 public JCExpression getMethodSelect() { return meth; } 1880 @DefinedBy(Api.COMPILER_TREE) 1881 public List<JCExpression> getArguments() { 1882 return args; 1883 } 1884 @Override @DefinedBy(Api.COMPILER_TREE) 1885 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1886 return v.visitMethodInvocation(this, d); 1887 } 1888 @Override 1889 public JCMethodInvocation setType(Type type) { 1890 super.setType(type); 1891 return this; 1892 } 1893 @Override 1894 public Tag getTag() { 1895 return(APPLY); 1896 } 1897 } 1898 1899 /** 1900 * A new(...) operation. 1901 */ 1902 public static class JCNewClass extends JCPolyExpression implements NewClassTree { 1903 public JCExpression encl; 1904 public List<JCExpression> typeargs; 1905 public JCExpression clazz; 1906 public List<JCExpression> args; 1907 public JCClassDecl def; 1908 public Symbol constructor; 1909 public Type varargsElement; 1910 public Type constructorType; 1911 protected JCNewClass(JCExpression encl, 1912 List<JCExpression> typeargs, 1913 JCExpression clazz, 1914 List<JCExpression> args, 1915 JCClassDecl def) 1916 { 1917 this.encl = encl; 1918 this.typeargs = (typeargs == null) ? List.nil() 1919 : typeargs; 1920 this.clazz = clazz; 1921 this.args = args; 1922 this.def = def; 1923 } 1924 @Override 1925 public void accept(Visitor v) { v.visitNewClass(this); } 1926 1927 @DefinedBy(Api.COMPILER_TREE) 1928 public Kind getKind() { return Kind.NEW_CLASS; } 1929 @DefinedBy(Api.COMPILER_TREE) 1930 public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... ) 1931 return encl; 1932 } 1933 @DefinedBy(Api.COMPILER_TREE) 1934 public List<JCExpression> getTypeArguments() { 1935 return typeargs; 1936 } 1937 @DefinedBy(Api.COMPILER_TREE) 1938 public JCExpression getIdentifier() { return clazz; } 1939 @DefinedBy(Api.COMPILER_TREE) 1940 public List<JCExpression> getArguments() { 1941 return args; 1942 } 1943 @DefinedBy(Api.COMPILER_TREE) 1944 public JCClassDecl getClassBody() { return def; } 1945 @Override @DefinedBy(Api.COMPILER_TREE) 1946 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1947 return v.visitNewClass(this, d); 1948 } 1949 @Override 1950 public Tag getTag() { 1951 return NEWCLASS; 1952 } 1953 1954 public boolean classDeclRemoved() { 1955 return false; 1956 } 1957 } 1958 1959 /** 1960 * A new[...] operation. 1961 */ 1962 public static class JCNewArray extends JCExpression implements NewArrayTree { 1963 public JCExpression elemtype; 1964 public List<JCExpression> dims; 1965 // type annotations on inner-most component 1966 public List<JCAnnotation> annotations; 1967 // type annotations on dimensions 1968 public List<List<JCAnnotation>> dimAnnotations; 1969 public List<JCExpression> elems; 1970 protected JCNewArray(JCExpression elemtype, 1971 List<JCExpression> dims, 1972 List<JCExpression> elems) 1973 { 1974 this.elemtype = elemtype; 1975 this.dims = dims; 1976 this.annotations = List.nil(); 1977 this.dimAnnotations = List.nil(); 1978 this.elems = elems; 1979 } 1980 @Override 1981 public void accept(Visitor v) { v.visitNewArray(this); } 1982 1983 @DefinedBy(Api.COMPILER_TREE) 1984 public Kind getKind() { return Kind.NEW_ARRAY; } 1985 @DefinedBy(Api.COMPILER_TREE) 1986 public JCExpression getType() { return elemtype; } 1987 @DefinedBy(Api.COMPILER_TREE) 1988 public List<JCExpression> getDimensions() { 1989 return dims; 1990 } 1991 @DefinedBy(Api.COMPILER_TREE) 1992 public List<JCExpression> getInitializers() { 1993 return elems; 1994 } 1995 @Override @DefinedBy(Api.COMPILER_TREE) 1996 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 1997 return v.visitNewArray(this, d); 1998 } 1999 @Override 2000 public Tag getTag() { 2001 return NEWARRAY; 2002 } 2003 2004 @Override @DefinedBy(Api.COMPILER_TREE) 2005 public List<JCAnnotation> getAnnotations() { 2006 return annotations; 2007 } 2008 2009 @Override @DefinedBy(Api.COMPILER_TREE) 2010 public List<List<JCAnnotation>> getDimAnnotations() { 2011 return dimAnnotations; 2012 } 2013 } 2014 2015 /** 2016 * A lambda expression. 2017 */ 2018 public static final class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree { 2019 2020 public enum ParameterKind { 2021 IMPLICIT, 2022 EXPLICIT 2023 } 2024 2025 public List<JCVariableDecl> params; 2026 public JCTree body; 2027 public boolean canCompleteNormally = true; 2028 public ParameterKind paramKind; 2029 public boolean wasMethodReference; 2030 2031 public JCLambda(List<JCVariableDecl> params, 2032 JCTree body) { 2033 this.params = params; 2034 this.body = body; 2035 if (params.isEmpty() || 2036 params.head.vartype != null) { 2037 paramKind = ParameterKind.EXPLICIT; 2038 } else { 2039 paramKind = ParameterKind.IMPLICIT; 2040 } 2041 } 2042 @Override 2043 public Tag getTag() { 2044 return LAMBDA; 2045 } 2046 @Override 2047 public void accept(Visitor v) { 2048 v.visitLambda(this); 2049 } 2050 @Override @DefinedBy(Api.COMPILER_TREE) 2051 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2052 return v.visitLambdaExpression(this, d); 2053 } 2054 @DefinedBy(Api.COMPILER_TREE) 2055 public Kind getKind() { 2056 return Kind.LAMBDA_EXPRESSION; 2057 } 2058 @DefinedBy(Api.COMPILER_TREE) 2059 public JCTree getBody() { 2060 return body; 2061 } 2062 @DefinedBy(Api.COMPILER_TREE) 2063 public java.util.List<? extends VariableTree> getParameters() { 2064 return params; 2065 } 2066 @Override 2067 public JCLambda setType(Type type) { 2068 super.setType(type); 2069 return this; 2070 } 2071 @Override @DefinedBy(Api.COMPILER_TREE) 2072 public BodyKind getBodyKind() { 2073 return body.hasTag(BLOCK) ? 2074 BodyKind.STATEMENT : 2075 BodyKind.EXPRESSION; 2076 } 2077 } 2078 2079 /** 2080 * A parenthesized subexpression ( ... ) 2081 */ 2082 public static class JCParens extends JCExpression implements ParenthesizedTree { 2083 public JCExpression expr; 2084 protected JCParens(JCExpression expr) { 2085 this.expr = expr; 2086 } 2087 @Override 2088 public void accept(Visitor v) { v.visitParens(this); } 2089 2090 @DefinedBy(Api.COMPILER_TREE) 2091 public Kind getKind() { return Kind.PARENTHESIZED; } 2092 @DefinedBy(Api.COMPILER_TREE) 2093 public JCExpression getExpression() { return expr; } 2094 @Override @DefinedBy(Api.COMPILER_TREE) 2095 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2096 return v.visitParenthesized(this, d); 2097 } 2098 @Override 2099 public Tag getTag() { 2100 return PARENS; 2101 } 2102 } 2103 2104 /** 2105 * A assignment with "=". 2106 */ 2107 public static class JCAssign extends JCExpression implements AssignmentTree { 2108 public JCExpression lhs; 2109 public JCExpression rhs; 2110 protected JCAssign(JCExpression lhs, JCExpression rhs) { 2111 this.lhs = lhs; 2112 this.rhs = rhs; 2113 } 2114 @Override 2115 public void accept(Visitor v) { v.visitAssign(this); } 2116 2117 @DefinedBy(Api.COMPILER_TREE) 2118 public Kind getKind() { return Kind.ASSIGNMENT; } 2119 @DefinedBy(Api.COMPILER_TREE) 2120 public JCExpression getVariable() { return lhs; } 2121 @DefinedBy(Api.COMPILER_TREE) 2122 public JCExpression getExpression() { return rhs; } 2123 @Override @DefinedBy(Api.COMPILER_TREE) 2124 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2125 return v.visitAssignment(this, d); 2126 } 2127 @Override 2128 public Tag getTag() { 2129 return ASSIGN; 2130 } 2131 } 2132 2133 public abstract static class JCOperatorExpression extends JCExpression { 2134 public enum OperandPos { 2135 LEFT, 2136 RIGHT 2137 } 2138 2139 protected Tag opcode; 2140 public OperatorSymbol operator; 2141 2142 public OperatorSymbol getOperator() { 2143 return operator; 2144 } 2145 2146 @Override 2147 public Tag getTag() { 2148 return opcode; 2149 } 2150 2151 public abstract JCExpression getOperand(OperandPos pos); 2152 } 2153 2154 /** 2155 * An assignment with "+=", "|=" ... 2156 */ 2157 public static class JCAssignOp extends JCOperatorExpression implements CompoundAssignmentTree { 2158 public JCExpression lhs; 2159 public JCExpression rhs; 2160 protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, OperatorSymbol operator) { 2161 this.opcode = opcode; 2162 this.lhs = (JCExpression)lhs; 2163 this.rhs = (JCExpression)rhs; 2164 this.operator = operator; 2165 } 2166 @Override 2167 public void accept(Visitor v) { v.visitAssignop(this); } 2168 2169 @DefinedBy(Api.COMPILER_TREE) 2170 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 2171 @DefinedBy(Api.COMPILER_TREE) 2172 public JCExpression getVariable() { return lhs; } 2173 @DefinedBy(Api.COMPILER_TREE) 2174 public JCExpression getExpression() { return rhs; } 2175 @Override @DefinedBy(Api.COMPILER_TREE) 2176 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2177 return v.visitCompoundAssignment(this, d); 2178 } 2179 @Override 2180 public JCExpression getOperand(OperandPos pos) { 2181 return pos == OperandPos.LEFT ? lhs : rhs; 2182 } 2183 } 2184 2185 /** 2186 * A unary operation. 2187 */ 2188 public static class JCUnary extends JCOperatorExpression implements UnaryTree { 2189 public JCExpression arg; 2190 protected JCUnary(Tag opcode, JCExpression arg) { 2191 this.opcode = opcode; 2192 this.arg = arg; 2193 } 2194 @Override 2195 public void accept(Visitor v) { v.visitUnary(this); } 2196 2197 @DefinedBy(Api.COMPILER_TREE) 2198 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 2199 @DefinedBy(Api.COMPILER_TREE) 2200 public JCExpression getExpression() { return arg; } 2201 @Override @DefinedBy(Api.COMPILER_TREE) 2202 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2203 return v.visitUnary(this, d); 2204 } 2205 public void setTag(Tag tag) { 2206 opcode = tag; 2207 } 2208 @Override 2209 public JCExpression getOperand(OperandPos pos) { 2210 return arg; 2211 } 2212 } 2213 2214 /** 2215 * A binary operation. 2216 */ 2217 public static class JCBinary extends JCOperatorExpression implements BinaryTree { 2218 public JCExpression lhs; 2219 public JCExpression rhs; 2220 protected JCBinary(Tag opcode, 2221 JCExpression lhs, 2222 JCExpression rhs, 2223 OperatorSymbol operator) { 2224 this.opcode = opcode; 2225 this.lhs = lhs; 2226 this.rhs = rhs; 2227 this.operator = operator; 2228 } 2229 @Override 2230 public void accept(Visitor v) { v.visitBinary(this); } 2231 2232 @DefinedBy(Api.COMPILER_TREE) 2233 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 2234 @DefinedBy(Api.COMPILER_TREE) 2235 public JCExpression getLeftOperand() { return lhs; } 2236 @DefinedBy(Api.COMPILER_TREE) 2237 public JCExpression getRightOperand() { return rhs; } 2238 @Override @DefinedBy(Api.COMPILER_TREE) 2239 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2240 return v.visitBinary(this, d); 2241 } 2242 @Override 2243 public JCExpression getOperand(OperandPos pos) { 2244 return pos == OperandPos.LEFT ? lhs : rhs; 2245 } 2246 } 2247 2248 /** 2249 * A type cast. 2250 */ 2251 public static class JCTypeCast extends JCExpression implements TypeCastTree { 2252 public JCTree clazz; 2253 public JCExpression expr; 2254 protected JCTypeCast(JCTree clazz, JCExpression expr) { 2255 this.clazz = clazz; 2256 this.expr = expr; 2257 } 2258 @Override 2259 public void accept(Visitor v) { v.visitTypeCast(this); } 2260 2261 @DefinedBy(Api.COMPILER_TREE) 2262 public Kind getKind() { return Kind.TYPE_CAST; } 2263 @DefinedBy(Api.COMPILER_TREE) 2264 public JCTree getType() { return clazz; } 2265 @DefinedBy(Api.COMPILER_TREE) 2266 public JCExpression getExpression() { return expr; } 2267 @Override @DefinedBy(Api.COMPILER_TREE) 2268 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2269 return v.visitTypeCast(this, d); 2270 } 2271 @Override 2272 public Tag getTag() { 2273 return TYPECAST; 2274 } 2275 } 2276 2277 /** 2278 * A type test. 2279 */ 2280 public static class JCInstanceOf extends JCExpression implements InstanceOfTree { 2281 public JCExpression expr; 2282 public JCTree pattern; 2283 /**{@code true} if this instanceof test should have 2284 * value {@code true} when the {@code expr} is {@code null}.*/ 2285 public boolean allowNull; 2286 public Type erasedExprOriginalType; 2287 2288 protected JCInstanceOf(JCExpression expr, JCTree pattern) { 2289 this.expr = expr; 2290 this.pattern = pattern; 2291 } 2292 @Override 2293 public void accept(Visitor v) { v.visitTypeTest(this); } 2294 2295 @DefinedBy(Api.COMPILER_TREE) 2296 public Kind getKind() { return Kind.INSTANCE_OF; } 2297 @DefinedBy(Api.COMPILER_TREE) 2298 public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; } 2299 2300 @Override @DefinedBy(Api.COMPILER_TREE) 2301 public JCPattern getPattern() { 2302 return pattern instanceof JCPattern jcPattern ? jcPattern : null; 2303 } 2304 2305 @DefinedBy(Api.COMPILER_TREE) 2306 public JCExpression getExpression() { return expr; } 2307 @Override @DefinedBy(Api.COMPILER_TREE) 2308 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2309 return v.visitInstanceOf(this, d); 2310 } 2311 @Override 2312 public Tag getTag() { 2313 return TYPETEST; 2314 } 2315 } 2316 2317 /** 2318 * Pattern matching forms. 2319 */ 2320 public abstract static class JCPattern extends JCTree 2321 implements PatternTree { 2322 } 2323 2324 public static class JCAnyPattern extends JCPattern 2325 implements AnyPatternTree { 2326 2327 protected JCAnyPattern() { 2328 } 2329 2330 @Override 2331 public void accept(Visitor v) { 2332 v.visitAnyPattern(this); 2333 } 2334 2335 @DefinedBy(Api.COMPILER_TREE) 2336 public Kind getKind() { 2337 return Kind.ANY_PATTERN; 2338 } 2339 2340 @Override 2341 @DefinedBy(Api.COMPILER_TREE) 2342 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2343 return v.visitAnyPattern(this, d); 2344 } 2345 2346 @Override 2347 public Tag getTag() { 2348 return ANYPATTERN; 2349 } 2350 } 2351 2352 public static class JCBindingPattern extends JCPattern 2353 implements BindingPatternTree { 2354 public JCVariableDecl var; 2355 2356 protected JCBindingPattern(JCVariableDecl var) { 2357 this.var = var; 2358 } 2359 2360 @Override @DefinedBy(Api.COMPILER_TREE) 2361 public VariableTree getVariable() { 2362 return var; 2363 } 2364 2365 @Override 2366 public void accept(Visitor v) { 2367 v.visitBindingPattern(this); 2368 } 2369 2370 @DefinedBy(Api.COMPILER_TREE) 2371 public Kind getKind() { 2372 return Kind.BINDING_PATTERN; 2373 } 2374 2375 @Override 2376 @DefinedBy(Api.COMPILER_TREE) 2377 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2378 return v.visitBindingPattern(this, d); 2379 } 2380 2381 @Override 2382 public Tag getTag() { 2383 return BINDINGPATTERN; 2384 } 2385 } 2386 2387 public static class JCDefaultCaseLabel extends JCCaseLabel 2388 implements DefaultCaseLabelTree { 2389 2390 protected JCDefaultCaseLabel() { 2391 } 2392 2393 @Override 2394 public void accept(Visitor v) { 2395 v.visitDefaultCaseLabel(this); 2396 } 2397 2398 @DefinedBy(Api.COMPILER_TREE) 2399 public Kind getKind() { 2400 return Kind.DEFAULT_CASE_LABEL; 2401 } 2402 2403 @Override 2404 @DefinedBy(Api.COMPILER_TREE) 2405 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2406 return v.visitDefaultCaseLabel(this, d); 2407 } 2408 2409 @Override 2410 public Tag getTag() { 2411 return DEFAULTCASELABEL; 2412 } 2413 2414 } 2415 2416 public static class JCConstantCaseLabel extends JCCaseLabel 2417 implements ConstantCaseLabelTree { 2418 2419 public JCExpression expr; 2420 2421 protected JCConstantCaseLabel(JCExpression expr) { 2422 this.expr = expr; 2423 } 2424 2425 @Override @DefinedBy(Api.COMPILER_TREE) 2426 public JCExpression getConstantExpression() { 2427 return expr; 2428 } 2429 2430 @Override 2431 public void accept(Visitor v) { 2432 v.visitConstantCaseLabel(this); 2433 } 2434 2435 @DefinedBy(Api.COMPILER_TREE) 2436 public Kind getKind() { 2437 return Kind.CONSTANT_CASE_LABEL; 2438 } 2439 2440 @Override 2441 @DefinedBy(Api.COMPILER_TREE) 2442 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2443 return v.visitConstantCaseLabel(this, d); 2444 } 2445 2446 @Override 2447 public Tag getTag() { 2448 return CONSTANTCASELABEL; 2449 } 2450 2451 } 2452 2453 public static class JCPatternCaseLabel extends JCCaseLabel 2454 implements PatternCaseLabelTree { 2455 2456 public JCPattern pat; 2457 public JCExpression syntheticGuard; 2458 2459 protected JCPatternCaseLabel(JCPattern pat) { 2460 this.pat = pat; 2461 } 2462 2463 @Override @DefinedBy(Api.COMPILER_TREE) 2464 public JCPattern getPattern() { 2465 return pat; 2466 } 2467 2468 @Override 2469 public void accept(Visitor v) { 2470 v.visitPatternCaseLabel(this); 2471 } 2472 2473 @DefinedBy(Api.COMPILER_TREE) 2474 public Kind getKind() { 2475 return Kind.PATTERN_CASE_LABEL; 2476 } 2477 2478 @Override 2479 @DefinedBy(Api.COMPILER_TREE) 2480 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2481 return v.visitPatternCaseLabel(this, d); 2482 } 2483 2484 @Override 2485 public Tag getTag() { 2486 return PATTERNCASELABEL; 2487 } 2488 2489 } 2490 2491 public static class JCRecordPattern extends JCPattern 2492 implements DeconstructionPatternTree { 2493 public JCExpression deconstructor; 2494 public List<JCPattern> nested; 2495 public ClassSymbol record; 2496 public List<Type> fullComponentTypes; 2497 2498 protected JCRecordPattern(JCExpression deconstructor, List<JCPattern> nested) { 2499 this.deconstructor = deconstructor; 2500 this.nested = nested; 2501 } 2502 2503 @DefinedBy(Api.COMPILER_TREE) 2504 public Name getBinding() { 2505 return null; 2506 } 2507 2508 @Override @DefinedBy(Api.COMPILER_TREE) 2509 public ExpressionTree getDeconstructor() { 2510 return deconstructor; 2511 } 2512 2513 @Override @DefinedBy(Api.COMPILER_TREE) 2514 public List<? extends JCPattern> getNestedPatterns() { 2515 return nested; 2516 } 2517 2518 @Override 2519 public void accept(Visitor v) { 2520 v.visitRecordPattern(this); 2521 } 2522 2523 @DefinedBy(Api.COMPILER_TREE) 2524 public Kind getKind() { 2525 return Kind.DECONSTRUCTION_PATTERN; 2526 } 2527 2528 @Override 2529 @DefinedBy(Api.COMPILER_TREE) 2530 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 2531 return v.visitDeconstructionPattern(this, d); 2532 } 2533 2534 @Override 2535 public Tag getTag() { 2536 return RECORDPATTERN; 2537 } 2538 2539 } 2540 2541 /** 2542 * An array selection 2543 */ 2544 public static class JCArrayAccess extends JCExpression implements ArrayAccessTree { 2545 public JCExpression indexed; 2546 public JCExpression index; 2547 protected JCArrayAccess(JCExpression indexed, JCExpression index) { 2548 this.indexed = indexed; 2549 this.index = index; 2550 } 2551 @Override 2552 public void accept(Visitor v) { v.visitIndexed(this); } 2553 2554 @DefinedBy(Api.COMPILER_TREE) 2555 public Kind getKind() { return Kind.ARRAY_ACCESS; } 2556 @DefinedBy(Api.COMPILER_TREE) 2557 public JCExpression getExpression() { return indexed; } 2558 @DefinedBy(Api.COMPILER_TREE) 2559 public JCExpression getIndex() { return index; } 2560 @Override @DefinedBy(Api.COMPILER_TREE) 2561 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2562 return v.visitArrayAccess(this, d); 2563 } 2564 @Override 2565 public Tag getTag() { 2566 return INDEXED; 2567 } 2568 } 2569 2570 /** 2571 * Selects through packages and classes 2572 */ 2573 public static class JCFieldAccess extends JCExpression implements MemberSelectTree { 2574 /** selected Tree hierarchy */ 2575 public JCExpression selected; 2576 /** name of field to select thru */ 2577 public Name name; 2578 /** symbol of the selected class */ 2579 public Symbol sym; 2580 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) { 2581 this.selected = selected; 2582 this.name = name; 2583 this.sym = sym; 2584 } 2585 @Override 2586 public void accept(Visitor v) { v.visitSelect(this); } 2587 2588 @DefinedBy(Api.COMPILER_TREE) 2589 public Kind getKind() { return Kind.MEMBER_SELECT; } 2590 @DefinedBy(Api.COMPILER_TREE) 2591 public JCExpression getExpression() { return selected; } 2592 @Override @DefinedBy(Api.COMPILER_TREE) 2593 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2594 return v.visitMemberSelect(this, d); 2595 } 2596 @DefinedBy(Api.COMPILER_TREE) 2597 public Name getIdentifier() { return name; } 2598 @Override 2599 public Tag getTag() { 2600 return SELECT; 2601 } 2602 } 2603 2604 /** 2605 * Selects a member expression. 2606 */ 2607 public static non-sealed class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree { 2608 2609 public ReferenceMode mode; 2610 public ReferenceKind kind; 2611 public Name name; 2612 public JCExpression expr; 2613 public List<JCExpression> typeargs; 2614 public Symbol sym; 2615 public Type varargsElement; 2616 public PolyKind refPolyKind; 2617 public boolean ownerAccessible; 2618 private OverloadKind overloadKind; 2619 public Type referentType; 2620 2621 public enum OverloadKind { 2622 OVERLOADED, 2623 UNOVERLOADED, 2624 ERROR 2625 } 2626 2627 /** 2628 * Javac-dependent classification for member references, based 2629 * on relevant properties w.r.t. code-generation 2630 */ 2631 public enum ReferenceKind { 2632 /** super # instMethod */ 2633 SUPER(ReferenceMode.INVOKE, false), 2634 /** Type # instMethod */ 2635 UNBOUND(ReferenceMode.INVOKE, true), 2636 /** Type # staticMethod */ 2637 STATIC(ReferenceMode.INVOKE, false), 2638 /** Expr # instMethod */ 2639 BOUND(ReferenceMode.INVOKE, false), 2640 /** Inner # new */ 2641 IMPLICIT_INNER(ReferenceMode.NEW, false), 2642 /** Toplevel # new */ 2643 TOPLEVEL(ReferenceMode.NEW, false), 2644 /** ArrayType # new */ 2645 ARRAY_CTOR(ReferenceMode.NEW, false); 2646 2647 final ReferenceMode mode; 2648 final boolean unbound; 2649 2650 private ReferenceKind(ReferenceMode mode, boolean unbound) { 2651 this.mode = mode; 2652 this.unbound = unbound; 2653 } 2654 2655 public boolean isUnbound() { 2656 return unbound; 2657 } 2658 } 2659 2660 public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) { 2661 this.mode = mode; 2662 this.name = name; 2663 this.expr = expr; 2664 this.typeargs = typeargs; 2665 } 2666 @Override 2667 public void accept(Visitor v) { v.visitReference(this); } 2668 2669 @DefinedBy(Api.COMPILER_TREE) 2670 public Kind getKind() { return Kind.MEMBER_REFERENCE; } 2671 @Override @DefinedBy(Api.COMPILER_TREE) 2672 public ReferenceMode getMode() { return mode; } 2673 @Override @DefinedBy(Api.COMPILER_TREE) 2674 public JCExpression getQualifierExpression() { return expr; } 2675 @Override @DefinedBy(Api.COMPILER_TREE) 2676 public Name getName() { return name; } 2677 @Override @DefinedBy(Api.COMPILER_TREE) 2678 public List<JCExpression> getTypeArguments() { return typeargs; } 2679 2680 @Override @DefinedBy(Api.COMPILER_TREE) 2681 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2682 return v.visitMemberReference(this, d); 2683 } 2684 @Override 2685 public Tag getTag() { 2686 return REFERENCE; 2687 } 2688 public boolean hasKind(ReferenceKind kind) { 2689 return this.kind == kind; 2690 } 2691 2692 /** 2693 * @return the overloadKind 2694 */ 2695 public OverloadKind getOverloadKind() { 2696 return overloadKind; 2697 } 2698 2699 /** 2700 * @param overloadKind the overloadKind to set 2701 */ 2702 public void setOverloadKind(OverloadKind overloadKind) { 2703 this.overloadKind = overloadKind; 2704 } 2705 } 2706 2707 /** 2708 * An identifier 2709 */ 2710 public static class JCIdent extends JCExpression implements IdentifierTree { 2711 /** the name */ 2712 public Name name; 2713 /** the symbol */ 2714 public Symbol sym; 2715 protected JCIdent(Name name, Symbol sym) { 2716 this.name = name; 2717 this.sym = sym; 2718 } 2719 @Override 2720 public void accept(Visitor v) { v.visitIdent(this); } 2721 2722 @DefinedBy(Api.COMPILER_TREE) 2723 public Kind getKind() { return Kind.IDENTIFIER; } 2724 @DefinedBy(Api.COMPILER_TREE) 2725 public Name getName() { return name; } 2726 @Override @DefinedBy(Api.COMPILER_TREE) 2727 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2728 return v.visitIdentifier(this, d); 2729 } 2730 @Override 2731 public Tag getTag() { 2732 return IDENT; 2733 } 2734 } 2735 2736 /** 2737 * A constant value given literally. 2738 */ 2739 public static class JCLiteral extends JCExpression implements LiteralTree { 2740 public TypeTag typetag; 2741 /** value representation */ 2742 public Object value; 2743 protected JCLiteral(TypeTag typetag, Object value) { 2744 this.typetag = typetag; 2745 this.value = value; 2746 } 2747 @Override 2748 public void accept(Visitor v) { v.visitLiteral(this); } 2749 2750 @DefinedBy(Api.COMPILER_TREE) 2751 public Kind getKind() { 2752 return typetag.getKindLiteral(); 2753 } 2754 2755 @DefinedBy(Api.COMPILER_TREE) 2756 public Object getValue() { 2757 switch (typetag) { 2758 case BOOLEAN: 2759 int bi = (Integer) value; 2760 return (bi != 0); 2761 case CHAR: 2762 int ci = (Integer) value; 2763 char c = (char) ci; 2764 if (c != ci) 2765 throw new AssertionError("bad value for char literal"); 2766 return c; 2767 default: 2768 return value; 2769 } 2770 } 2771 @Override @DefinedBy(Api.COMPILER_TREE) 2772 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2773 return v.visitLiteral(this, d); 2774 } 2775 @Override 2776 public JCLiteral setType(Type type) { 2777 super.setType(type); 2778 return this; 2779 } 2780 @Override 2781 public Tag getTag() { 2782 return LITERAL; 2783 } 2784 } 2785 2786 /** 2787 * Identifies a basic type. 2788 * @see TypeTag 2789 */ 2790 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree { 2791 /** the basic type id */ 2792 public TypeTag typetag; 2793 protected JCPrimitiveTypeTree(TypeTag typetag) { 2794 this.typetag = typetag; 2795 } 2796 @Override 2797 public void accept(Visitor v) { v.visitTypeIdent(this); } 2798 2799 @DefinedBy(Api.COMPILER_TREE) 2800 public Kind getKind() { return Kind.PRIMITIVE_TYPE; } 2801 @DefinedBy(Api.COMPILER_TREE) 2802 public TypeKind getPrimitiveTypeKind() { 2803 return typetag.getPrimitiveTypeKind(); 2804 } 2805 2806 @Override @DefinedBy(Api.COMPILER_TREE) 2807 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2808 return v.visitPrimitiveType(this, d); 2809 } 2810 @Override 2811 public Tag getTag() { 2812 return TYPEIDENT; 2813 } 2814 } 2815 2816 /** 2817 * An array type, A[] 2818 */ 2819 public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree { 2820 public JCExpression elemtype; 2821 protected JCArrayTypeTree(JCExpression elemtype) { 2822 this.elemtype = elemtype; 2823 } 2824 @Override 2825 public void accept(Visitor v) { v.visitTypeArray(this); } 2826 2827 @DefinedBy(Api.COMPILER_TREE) 2828 public Kind getKind() { return Kind.ARRAY_TYPE; } 2829 @DefinedBy(Api.COMPILER_TREE) 2830 public JCTree getType() { return elemtype; } 2831 @Override @DefinedBy(Api.COMPILER_TREE) 2832 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2833 return v.visitArrayType(this, d); 2834 } 2835 @Override 2836 public Tag getTag() { 2837 return TYPEARRAY; 2838 } 2839 } 2840 2841 /** 2842 * A parameterized type, {@literal T<...>} 2843 */ 2844 public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree { 2845 public JCExpression clazz; 2846 public List<JCExpression> arguments; 2847 protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) { 2848 this.clazz = clazz; 2849 this.arguments = arguments; 2850 } 2851 @Override 2852 public void accept(Visitor v) { v.visitTypeApply(this); } 2853 2854 @DefinedBy(Api.COMPILER_TREE) 2855 public Kind getKind() { return Kind.PARAMETERIZED_TYPE; } 2856 @DefinedBy(Api.COMPILER_TREE) 2857 public JCTree getType() { return clazz; } 2858 @DefinedBy(Api.COMPILER_TREE) 2859 public List<JCExpression> getTypeArguments() { 2860 return arguments; 2861 } 2862 @Override @DefinedBy(Api.COMPILER_TREE) 2863 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2864 return v.visitParameterizedType(this, d); 2865 } 2866 @Override 2867 public Tag getTag() { 2868 return TYPEAPPLY; 2869 } 2870 } 2871 2872 /** 2873 * A union type, T1 | T2 | ... Tn (used in multicatch statements) 2874 */ 2875 public static class JCTypeUnion extends JCExpression implements UnionTypeTree { 2876 2877 public List<JCExpression> alternatives; 2878 2879 protected JCTypeUnion(List<JCExpression> components) { 2880 this.alternatives = components; 2881 } 2882 @Override 2883 public void accept(Visitor v) { v.visitTypeUnion(this); } 2884 2885 @DefinedBy(Api.COMPILER_TREE) 2886 public Kind getKind() { return Kind.UNION_TYPE; } 2887 2888 @DefinedBy(Api.COMPILER_TREE) 2889 public List<JCExpression> getTypeAlternatives() { 2890 return alternatives; 2891 } 2892 @Override @DefinedBy(Api.COMPILER_TREE) 2893 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2894 return v.visitUnionType(this, d); 2895 } 2896 @Override 2897 public Tag getTag() { 2898 return TYPEUNION; 2899 } 2900 } 2901 2902 /** 2903 * An intersection type, {@code T1 & T2 & ... Tn} (used in cast expressions) 2904 */ 2905 public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree { 2906 2907 public List<JCExpression> bounds; 2908 2909 protected JCTypeIntersection(List<JCExpression> bounds) { 2910 this.bounds = bounds; 2911 } 2912 @Override 2913 public void accept(Visitor v) { v.visitTypeIntersection(this); } 2914 2915 @DefinedBy(Api.COMPILER_TREE) 2916 public Kind getKind() { return Kind.INTERSECTION_TYPE; } 2917 2918 @DefinedBy(Api.COMPILER_TREE) 2919 public List<JCExpression> getBounds() { 2920 return bounds; 2921 } 2922 @Override @DefinedBy(Api.COMPILER_TREE) 2923 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2924 return v.visitIntersectionType(this, d); 2925 } 2926 @Override 2927 public Tag getTag() { 2928 return TYPEINTERSECTION; 2929 } 2930 } 2931 2932 /** 2933 * A formal class parameter. 2934 */ 2935 public static class JCTypeParameter extends JCTree implements TypeParameterTree { 2936 /** name */ 2937 public Name name; 2938 /** bounds */ 2939 public List<JCExpression> bounds; 2940 /** type annotations on type parameter */ 2941 public List<JCAnnotation> annotations; 2942 protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) { 2943 this.name = name; 2944 this.bounds = bounds; 2945 this.annotations = annotations; 2946 } 2947 @Override 2948 public void accept(Visitor v) { v.visitTypeParameter(this); } 2949 2950 @DefinedBy(Api.COMPILER_TREE) 2951 public Kind getKind() { return Kind.TYPE_PARAMETER; } 2952 @DefinedBy(Api.COMPILER_TREE) 2953 public Name getName() { return name; } 2954 @DefinedBy(Api.COMPILER_TREE) 2955 public List<JCExpression> getBounds() { 2956 return bounds; 2957 } 2958 @DefinedBy(Api.COMPILER_TREE) 2959 public List<JCAnnotation> getAnnotations() { 2960 return annotations; 2961 } 2962 @Override @DefinedBy(Api.COMPILER_TREE) 2963 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2964 return v.visitTypeParameter(this, d); 2965 } 2966 @Override 2967 public Tag getTag() { 2968 return TYPEPARAMETER; 2969 } 2970 } 2971 2972 public static class JCWildcard extends JCExpression implements WildcardTree { 2973 public TypeBoundKind kind; 2974 public JCTree inner; 2975 protected JCWildcard(TypeBoundKind kind, JCTree inner) { 2976 this.kind = Assert.checkNonNull(kind); 2977 this.inner = inner; 2978 } 2979 @Override 2980 public void accept(Visitor v) { v.visitWildcard(this); } 2981 2982 @DefinedBy(Api.COMPILER_TREE) 2983 public Kind getKind() { 2984 switch (kind.kind) { 2985 case UNBOUND: 2986 return Kind.UNBOUNDED_WILDCARD; 2987 case EXTENDS: 2988 return Kind.EXTENDS_WILDCARD; 2989 case SUPER: 2990 return Kind.SUPER_WILDCARD; 2991 default: 2992 throw new AssertionError("Unknown wildcard bound " + kind); 2993 } 2994 } 2995 @DefinedBy(Api.COMPILER_TREE) 2996 public JCTree getBound() { return inner; } 2997 @Override @DefinedBy(Api.COMPILER_TREE) 2998 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 2999 return v.visitWildcard(this, d); 3000 } 3001 @Override 3002 public Tag getTag() { 3003 return Tag.WILDCARD; 3004 } 3005 } 3006 3007 public static class TypeBoundKind extends JCTree { 3008 public BoundKind kind; 3009 protected TypeBoundKind(BoundKind kind) { 3010 this.kind = kind; 3011 } 3012 @Override 3013 public void accept(Visitor v) { v.visitTypeBoundKind(this); } 3014 3015 @DefinedBy(Api.COMPILER_TREE) 3016 public Kind getKind() { 3017 throw new AssertionError("TypeBoundKind is not part of a public API"); 3018 } 3019 @Override @DefinedBy(Api.COMPILER_TREE) 3020 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3021 throw new AssertionError("TypeBoundKind is not part of a public API"); 3022 } 3023 @Override 3024 public Tag getTag() { 3025 return TYPEBOUNDKIND; 3026 } 3027 } 3028 3029 public static class JCAnnotation extends JCExpression implements AnnotationTree { 3030 // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION 3031 private Tag tag; 3032 3033 public JCTree annotationType; 3034 public List<JCExpression> args; 3035 public Attribute.Compound attribute; 3036 3037 protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) { 3038 this.tag = tag; 3039 this.annotationType = annotationType; 3040 this.args = args; 3041 } 3042 3043 @Override 3044 public void accept(Visitor v) { v.visitAnnotation(this); } 3045 3046 @DefinedBy(Api.COMPILER_TREE) 3047 public Kind getKind() { return TreeInfo.tagToKind(getTag()); } 3048 3049 @DefinedBy(Api.COMPILER_TREE) 3050 public JCTree getAnnotationType() { return annotationType; } 3051 @DefinedBy(Api.COMPILER_TREE) 3052 public List<JCExpression> getArguments() { 3053 return args; 3054 } 3055 @Override @DefinedBy(Api.COMPILER_TREE) 3056 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3057 return v.visitAnnotation(this, d); 3058 } 3059 @Override 3060 public Tag getTag() { 3061 return tag; 3062 } 3063 } 3064 3065 public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { 3066 public long flags; 3067 public List<JCAnnotation> annotations; 3068 protected JCModifiers(long flags, List<JCAnnotation> annotations) { 3069 this.flags = flags; 3070 this.annotations = annotations; 3071 } 3072 @Override 3073 public void accept(Visitor v) { v.visitModifiers(this); } 3074 3075 @DefinedBy(Api.COMPILER_TREE) 3076 public Kind getKind() { return Kind.MODIFIERS; } 3077 @DefinedBy(Api.COMPILER_TREE) 3078 public Set<Modifier> getFlags() { 3079 return Flags.asModifierSet(flags); 3080 } 3081 @DefinedBy(Api.COMPILER_TREE) 3082 public List<JCAnnotation> getAnnotations() { 3083 return annotations; 3084 } 3085 @Override @DefinedBy(Api.COMPILER_TREE) 3086 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3087 return v.visitModifiers(this, d); 3088 } 3089 @Override 3090 public Tag getTag() { 3091 return MODIFIERS; 3092 } 3093 } 3094 3095 public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree { 3096 // type annotations 3097 public List<JCAnnotation> annotations; 3098 public JCExpression underlyingType; 3099 3100 protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) { 3101 Assert.check(annotations != null && annotations.nonEmpty()); 3102 this.annotations = annotations; 3103 this.underlyingType = underlyingType; 3104 } 3105 @Override 3106 public void accept(Visitor v) { v.visitAnnotatedType(this); } 3107 3108 @DefinedBy(Api.COMPILER_TREE) 3109 public Kind getKind() { return Kind.ANNOTATED_TYPE; } 3110 @DefinedBy(Api.COMPILER_TREE) 3111 public List<JCAnnotation> getAnnotations() { 3112 return annotations; 3113 } 3114 @DefinedBy(Api.COMPILER_TREE) 3115 public JCExpression getUnderlyingType() { 3116 return underlyingType; 3117 } 3118 @Override @DefinedBy(Api.COMPILER_TREE) 3119 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3120 return v.visitAnnotatedType(this, d); 3121 } 3122 @Override 3123 public Tag getTag() { 3124 return ANNOTATED_TYPE; 3125 } 3126 } 3127 3128 public abstract static class JCDirective extends JCTree 3129 implements DirectiveTree { 3130 } 3131 3132 public static class JCModuleDecl extends JCTree implements ModuleTree { 3133 public JCModifiers mods; 3134 public ModuleType type; 3135 private final ModuleKind kind; 3136 public JCExpression qualId; 3137 public List<JCDirective> directives; 3138 public ModuleSymbol sym; 3139 3140 protected JCModuleDecl(JCModifiers mods, ModuleKind kind, 3141 JCExpression qualId, List<JCDirective> directives) { 3142 this.mods = mods; 3143 this.kind = kind; 3144 this.qualId = qualId; 3145 this.directives = directives; 3146 } 3147 3148 @Override 3149 public void accept(Visitor v) { v.visitModuleDef(this); } 3150 3151 @Override @DefinedBy(Api.COMPILER_TREE) 3152 public Kind getKind() { 3153 return Kind.MODULE; 3154 } 3155 3156 @Override @DefinedBy(Api.COMPILER_TREE) 3157 public List<? extends AnnotationTree> getAnnotations() { 3158 return mods.annotations; 3159 } 3160 3161 @Override @DefinedBy(Api.COMPILER_TREE) 3162 public ModuleKind getModuleType() { 3163 return kind; 3164 } 3165 3166 @Override @DefinedBy(Api.COMPILER_TREE) 3167 public JCExpression getName() { 3168 return qualId; 3169 } 3170 3171 @Override @DefinedBy(Api.COMPILER_TREE) 3172 public List<JCDirective> getDirectives() { 3173 return directives; 3174 } 3175 3176 @Override @DefinedBy(Api.COMPILER_TREE) 3177 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3178 return v.visitModule(this, d); 3179 } 3180 3181 @Override 3182 public Tag getTag() { 3183 return MODULEDEF; 3184 } 3185 } 3186 3187 public static class JCExports extends JCDirective 3188 implements ExportsTree { 3189 public JCExpression qualid; 3190 public List<JCExpression> moduleNames; 3191 public ExportsDirective directive; 3192 3193 protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) { 3194 this.qualid = qualId; 3195 this.moduleNames = moduleNames; 3196 } 3197 3198 @Override 3199 public void accept(Visitor v) { v.visitExports(this); } 3200 3201 @Override @DefinedBy(Api.COMPILER_TREE) 3202 public Kind getKind() { 3203 return Kind.EXPORTS; 3204 } 3205 3206 @Override @DefinedBy(Api.COMPILER_TREE) 3207 public JCExpression getPackageName() { 3208 return qualid; 3209 } 3210 3211 @Override @DefinedBy(Api.COMPILER_TREE) 3212 public List<JCExpression> getModuleNames() { 3213 return moduleNames; 3214 } 3215 3216 @Override @DefinedBy(Api.COMPILER_TREE) 3217 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3218 return v.visitExports(this, d); 3219 } 3220 3221 @Override 3222 public Tag getTag() { 3223 return Tag.EXPORTS; 3224 } 3225 } 3226 3227 public static class JCOpens extends JCDirective 3228 implements OpensTree { 3229 public JCExpression qualid; 3230 public List<JCExpression> moduleNames; 3231 public OpensDirective directive; 3232 3233 protected JCOpens(JCExpression qualId, List<JCExpression> moduleNames) { 3234 this.qualid = qualId; 3235 this.moduleNames = moduleNames; 3236 } 3237 3238 @Override 3239 public void accept(Visitor v) { v.visitOpens(this); } 3240 3241 @Override @DefinedBy(Api.COMPILER_TREE) 3242 public Kind getKind() { 3243 return Kind.OPENS; 3244 } 3245 3246 @Override @DefinedBy(Api.COMPILER_TREE) 3247 public JCExpression getPackageName() { 3248 return qualid; 3249 } 3250 3251 @Override @DefinedBy(Api.COMPILER_TREE) 3252 public List<JCExpression> getModuleNames() { 3253 return moduleNames; 3254 } 3255 3256 @Override @DefinedBy(Api.COMPILER_TREE) 3257 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3258 return v.visitOpens(this, d); 3259 } 3260 3261 @Override 3262 public Tag getTag() { 3263 return Tag.OPENS; 3264 } 3265 } 3266 3267 public static class JCProvides extends JCDirective 3268 implements ProvidesTree { 3269 public JCExpression serviceName; 3270 public List<JCExpression> implNames; 3271 3272 protected JCProvides(JCExpression serviceName, List<JCExpression> implNames) { 3273 this.serviceName = serviceName; 3274 this.implNames = implNames; 3275 } 3276 3277 @Override 3278 public void accept(Visitor v) { v.visitProvides(this); } 3279 3280 @Override @DefinedBy(Api.COMPILER_TREE) 3281 public Kind getKind() { 3282 return Kind.PROVIDES; 3283 } 3284 3285 @Override @DefinedBy(Api.COMPILER_TREE) 3286 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3287 return v.visitProvides(this, d); 3288 } 3289 3290 @Override @DefinedBy(Api.COMPILER_TREE) 3291 public JCExpression getServiceName() { 3292 return serviceName; 3293 } 3294 3295 @Override @DefinedBy(Api.COMPILER_TREE) 3296 public List<JCExpression> getImplementationNames() { 3297 return implNames; 3298 } 3299 3300 @Override 3301 public Tag getTag() { 3302 return PROVIDES; 3303 } 3304 } 3305 3306 public static class JCRequires extends JCDirective 3307 implements RequiresTree { 3308 public boolean isTransitive; 3309 public boolean isStaticPhase; 3310 public JCExpression moduleName; 3311 public RequiresDirective directive; 3312 3313 protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) { 3314 this.isTransitive = isTransitive; 3315 this.isStaticPhase = isStaticPhase; 3316 this.moduleName = moduleName; 3317 } 3318 3319 @Override 3320 public void accept(Visitor v) { v.visitRequires(this); } 3321 3322 @Override @DefinedBy(Api.COMPILER_TREE) 3323 public Kind getKind() { 3324 return Kind.REQUIRES; 3325 } 3326 3327 @Override @DefinedBy(Api.COMPILER_TREE) 3328 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3329 return v.visitRequires(this, d); 3330 } 3331 3332 @Override @DefinedBy(Api.COMPILER_TREE) 3333 public boolean isTransitive() { 3334 return isTransitive; 3335 } 3336 3337 @Override @DefinedBy(Api.COMPILER_TREE) 3338 public boolean isStatic() { 3339 return isStaticPhase; 3340 } 3341 3342 @Override @DefinedBy(Api.COMPILER_TREE) 3343 public JCExpression getModuleName() { 3344 return moduleName; 3345 } 3346 3347 @Override 3348 public Tag getTag() { 3349 return REQUIRES; 3350 } 3351 } 3352 3353 public static class JCUses extends JCDirective 3354 implements UsesTree { 3355 public JCExpression qualid; 3356 3357 protected JCUses(JCExpression qualId) { 3358 this.qualid = qualId; 3359 } 3360 3361 @Override 3362 public void accept(Visitor v) { v.visitUses(this); } 3363 3364 @Override @DefinedBy(Api.COMPILER_TREE) 3365 public Kind getKind() { 3366 return Kind.USES; 3367 } 3368 3369 @Override @DefinedBy(Api.COMPILER_TREE) 3370 public JCExpression getServiceName() { 3371 return qualid; 3372 } 3373 3374 @Override @DefinedBy(Api.COMPILER_TREE) 3375 public <R, D> R accept(TreeVisitor<R, D> v, D d) { 3376 return v.visitUses(this, d); 3377 } 3378 3379 @Override 3380 public Tag getTag() { 3381 return USES; 3382 } 3383 } 3384 3385 public static class JCErroneous extends JCExpression 3386 implements ErroneousTree { 3387 public List<? extends JCTree> errs; 3388 protected JCErroneous(List<? extends JCTree> errs) { 3389 this.errs = errs; 3390 } 3391 @Override 3392 public void accept(Visitor v) { v.visitErroneous(this); } 3393 3394 @DefinedBy(Api.COMPILER_TREE) 3395 public Kind getKind() { return Kind.ERRONEOUS; } 3396 3397 @DefinedBy(Api.COMPILER_TREE) 3398 public List<? extends JCTree> getErrorTrees() { 3399 return errs; 3400 } 3401 3402 @Override @DefinedBy(Api.COMPILER_TREE) 3403 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3404 return v.visitErroneous(this, d); 3405 } 3406 @Override 3407 public Tag getTag() { 3408 return ERRONEOUS; 3409 } 3410 } 3411 3412 /** (let int x = 3; in x+2) */ 3413 public static class LetExpr extends JCExpression { 3414 public List<JCStatement> defs; 3415 public JCExpression expr; 3416 /**true if a expr should be run through Gen.genCond:*/ 3417 public boolean needsCond; 3418 protected LetExpr(List<JCStatement> defs, JCExpression expr) { 3419 this.defs = defs; 3420 this.expr = expr; 3421 } 3422 @Override 3423 public void accept(Visitor v) { v.visitLetExpr(this); } 3424 3425 @DefinedBy(Api.COMPILER_TREE) 3426 public Kind getKind() { 3427 throw new AssertionError("LetExpr is not part of a public API"); 3428 } 3429 @Override @DefinedBy(Api.COMPILER_TREE) 3430 public <R,D> R accept(TreeVisitor<R,D> v, D d) { 3431 throw new AssertionError("LetExpr is not part of a public API"); 3432 } 3433 @Override 3434 public Tag getTag() { 3435 return LETEXPR; 3436 } 3437 } 3438 3439 /** An interface for tree factories 3440 */ 3441 public interface Factory { 3442 JCCompilationUnit TopLevel(List<JCTree> defs); 3443 JCPackageDecl PackageDecl(List<JCAnnotation> annotations, 3444 JCExpression pid); 3445 JCImport Import(JCFieldAccess qualid, boolean staticImport); 3446 JCClassDecl ClassDef(JCModifiers mods, 3447 Name name, 3448 List<JCTypeParameter> typarams, 3449 JCExpression extending, 3450 List<JCExpression> implementing, 3451 List<JCTree> defs); 3452 JCMethodDecl MethodDef(JCModifiers mods, 3453 Name name, 3454 JCExpression restype, 3455 List<JCTypeParameter> typarams, 3456 JCVariableDecl recvparam, 3457 List<JCVariableDecl> params, 3458 List<JCExpression> thrown, 3459 JCBlock body, 3460 JCExpression defaultValue); 3461 JCVariableDecl VarDef(JCModifiers mods, 3462 Name name, 3463 JCExpression vartype, 3464 JCExpression init); 3465 JCSkip Skip(); 3466 JCBlock Block(long flags, List<JCStatement> stats); 3467 JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond); 3468 JCWhileLoop WhileLoop(JCExpression cond, JCStatement body); 3469 JCForLoop ForLoop(List<JCStatement> init, 3470 JCExpression cond, 3471 List<JCExpressionStatement> step, 3472 JCStatement body); 3473 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body); 3474 JCLabeledStatement Labelled(Name label, JCStatement body); 3475 JCSwitch Switch(JCExpression selector, List<JCCase> cases); 3476 JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases); 3477 JCCase Case(CaseTree.CaseKind caseKind, List<JCCaseLabel> labels, JCExpression guard, 3478 List<JCStatement> stats, JCTree body); 3479 JCSynchronized Synchronized(JCExpression lock, JCBlock body); 3480 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer); 3481 JCTry Try(List<JCTree> resources, 3482 JCBlock body, 3483 List<JCCatch> catchers, 3484 JCBlock finalizer); 3485 JCCatch Catch(JCVariableDecl param, JCBlock body); 3486 JCConditional Conditional(JCExpression cond, 3487 JCExpression thenpart, 3488 JCExpression elsepart); 3489 JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart); 3490 JCExpressionStatement Exec(JCExpression expr); 3491 JCBreak Break(Name label); 3492 JCYield Yield(JCExpression value); 3493 JCContinue Continue(Name label); 3494 JCReturn Return(JCExpression expr); 3495 JCThrow Throw(JCExpression expr); 3496 JCAssert Assert(JCExpression cond, JCExpression detail); 3497 JCMethodInvocation Apply(List<JCExpression> typeargs, 3498 JCExpression fn, 3499 List<JCExpression> args); 3500 JCNewClass NewClass(JCExpression encl, 3501 List<JCExpression> typeargs, 3502 JCExpression clazz, 3503 List<JCExpression> args, 3504 JCClassDecl def); 3505 JCNewArray NewArray(JCExpression elemtype, 3506 List<JCExpression> dims, 3507 List<JCExpression> elems); 3508 JCParens Parens(JCExpression expr); 3509 JCAssign Assign(JCExpression lhs, JCExpression rhs); 3510 JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs); 3511 JCUnary Unary(Tag opcode, JCExpression arg); 3512 JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs); 3513 JCTypeCast TypeCast(JCTree expr, JCExpression type); 3514 JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); 3515 JCBindingPattern BindingPattern(JCVariableDecl var); 3516 JCArrayAccess Indexed(JCExpression indexed, JCExpression index); 3517 JCFieldAccess Select(JCExpression selected, Name selector); 3518 JCIdent Ident(Name idname); 3519 JCLiteral Literal(TypeTag tag, Object value); 3520 JCPrimitiveTypeTree TypeIdent(TypeTag typetag); 3521 JCArrayTypeTree TypeArray(JCExpression elemtype); 3522 JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments); 3523 JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds); 3524 JCWildcard Wildcard(TypeBoundKind kind, JCTree type); 3525 TypeBoundKind TypeBoundKind(BoundKind kind); 3526 JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args); 3527 JCModifiers Modifiers(long flags, List<JCAnnotation> annotations); 3528 JCErroneous Erroneous(List<? extends JCTree> errs); 3529 JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, JCExpression qualId, List<JCDirective> directives); 3530 JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames); 3531 JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames); 3532 JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames); 3533 JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId); 3534 JCUses Uses(JCExpression qualId); 3535 LetExpr LetExpr(List<JCStatement> defs, JCExpression expr); 3536 } 3537 3538 /** A generic visitor class for trees. 3539 */ 3540 public abstract static class Visitor { 3541 public void visitTopLevel(JCCompilationUnit that) { visitTree(that); } 3542 public void visitPackageDef(JCPackageDecl that) { visitTree(that); } 3543 public void visitImport(JCImport that) { visitTree(that); } 3544 public void visitModuleImport(JCModuleImport that) { visitTree(that); } 3545 public void visitClassDef(JCClassDecl that) { visitTree(that); } 3546 public void visitMethodDef(JCMethodDecl that) { visitTree(that); } 3547 public void visitVarDef(JCVariableDecl that) { visitTree(that); } 3548 public void visitSkip(JCSkip that) { visitTree(that); } 3549 public void visitBlock(JCBlock that) { visitTree(that); } 3550 public void visitDoLoop(JCDoWhileLoop that) { visitTree(that); } 3551 public void visitWhileLoop(JCWhileLoop that) { visitTree(that); } 3552 public void visitForLoop(JCForLoop that) { visitTree(that); } 3553 public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); } 3554 public void visitLabelled(JCLabeledStatement that) { visitTree(that); } 3555 public void visitSwitch(JCSwitch that) { visitTree(that); } 3556 public void visitCase(JCCase that) { visitTree(that); } 3557 public void visitSwitchExpression(JCSwitchExpression that) { visitTree(that); } 3558 public void visitSynchronized(JCSynchronized that) { visitTree(that); } 3559 public void visitTry(JCTry that) { visitTree(that); } 3560 public void visitCatch(JCCatch that) { visitTree(that); } 3561 public void visitConditional(JCConditional that) { visitTree(that); } 3562 public void visitIf(JCIf that) { visitTree(that); } 3563 public void visitExec(JCExpressionStatement that) { visitTree(that); } 3564 public void visitBreak(JCBreak that) { visitTree(that); } 3565 public void visitYield(JCYield that) { visitTree(that); } 3566 public void visitContinue(JCContinue that) { visitTree(that); } 3567 public void visitReturn(JCReturn that) { visitTree(that); } 3568 public void visitThrow(JCThrow that) { visitTree(that); } 3569 public void visitAssert(JCAssert that) { visitTree(that); } 3570 public void visitApply(JCMethodInvocation that) { visitTree(that); } 3571 public void visitNewClass(JCNewClass that) { visitTree(that); } 3572 public void visitNewArray(JCNewArray that) { visitTree(that); } 3573 public void visitLambda(JCLambda that) { visitTree(that); } 3574 public void visitParens(JCParens that) { visitTree(that); } 3575 public void visitAssign(JCAssign that) { visitTree(that); } 3576 public void visitAssignop(JCAssignOp that) { visitTree(that); } 3577 public void visitUnary(JCUnary that) { visitTree(that); } 3578 public void visitBinary(JCBinary that) { visitTree(that); } 3579 public void visitTypeCast(JCTypeCast that) { visitTree(that); } 3580 public void visitTypeTest(JCInstanceOf that) { visitTree(that); } 3581 public void visitAnyPattern(JCAnyPattern that) { visitTree(that); } 3582 public void visitBindingPattern(JCBindingPattern that) { visitTree(that); } 3583 public void visitDefaultCaseLabel(JCDefaultCaseLabel that) { visitTree(that); } 3584 public void visitConstantCaseLabel(JCConstantCaseLabel that) { visitTree(that); } 3585 public void visitPatternCaseLabel(JCPatternCaseLabel that) { visitTree(that); } 3586 public void visitRecordPattern(JCRecordPattern that) { visitTree(that); } 3587 public void visitIndexed(JCArrayAccess that) { visitTree(that); } 3588 public void visitSelect(JCFieldAccess that) { visitTree(that); } 3589 public void visitReference(JCMemberReference that) { visitTree(that); } 3590 public void visitIdent(JCIdent that) { visitTree(that); } 3591 public void visitLiteral(JCLiteral that) { visitTree(that); } 3592 public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); } 3593 public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); } 3594 public void visitTypeApply(JCTypeApply that) { visitTree(that); } 3595 public void visitTypeUnion(JCTypeUnion that) { visitTree(that); } 3596 public void visitTypeIntersection(JCTypeIntersection that) { visitTree(that); } 3597 public void visitTypeParameter(JCTypeParameter that) { visitTree(that); } 3598 public void visitWildcard(JCWildcard that) { visitTree(that); } 3599 public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); } 3600 public void visitAnnotation(JCAnnotation that) { visitTree(that); } 3601 public void visitModifiers(JCModifiers that) { visitTree(that); } 3602 public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); } 3603 public void visitErroneous(JCErroneous that) { visitTree(that); } 3604 public void visitModuleDef(JCModuleDecl that) { visitTree(that); } 3605 public void visitExports(JCExports that) { visitTree(that); } 3606 public void visitOpens(JCOpens that) { visitTree(that); } 3607 public void visitProvides(JCProvides that) { visitTree(that); } 3608 public void visitRequires(JCRequires that) { visitTree(that); } 3609 public void visitUses(JCUses that) { visitTree(that); } 3610 public void visitLetExpr(LetExpr that) { visitTree(that); } 3611 3612 public void visitTree(JCTree that) { Assert.error(); } 3613 } 3614 3615 }