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