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