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