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