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