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