Mon, 10 Dec 2012 16:21:26 +0000
8003967: detect and remove all mutable implicit static enum fields in langtools
Reviewed-by: jjg
1 /*
2 * Copyright (c) 1999, 2012, 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 */
26 package com.sun.tools.javac.tree;
28 import java.io.IOException;
29 import java.io.StringWriter;
30 import java.util.*;
32 import javax.lang.model.element.Modifier;
33 import javax.lang.model.type.TypeKind;
34 import javax.tools.JavaFileObject;
36 import com.sun.source.tree.*;
37 import com.sun.source.tree.LambdaExpressionTree.BodyKind;
38 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
39 import com.sun.tools.javac.code.*;
40 import com.sun.tools.javac.code.Scope.*;
41 import com.sun.tools.javac.code.Symbol.*;
42 import com.sun.tools.javac.util.*;
43 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
44 import com.sun.tools.javac.util.List;
45 import static com.sun.tools.javac.code.BoundKind.*;
46 import static com.sun.tools.javac.tree.JCTree.Tag.*;
48 /**
49 * Root class for abstract syntax tree nodes. It provides definitions
50 * for specific tree nodes as subclasses nested inside.
51 *
52 * <p>Each subclass is highly standardized. It generally contains
53 * only tree fields for the syntactic subcomponents of the node. Some
54 * classes that represent identifier uses or definitions also define a
55 * Symbol field that denotes the represented identifier. Classes for
56 * non-local jumps also carry the jump target as a field. The root
57 * class Tree itself defines fields for the tree's type and position.
58 * No other fields are kept in a tree node; instead parameters are
59 * passed to methods accessing the node.
60 *
61 * <p>Except for the methods defined by com.sun.source, the only
62 * method defined in subclasses is `visit' which applies a given
63 * visitor to the tree. The actual tree processing is done by visitor
64 * classes in other packages. The abstract class Visitor, as well as
65 * an Factory interface for trees, are defined as inner classes in
66 * Tree.
67 *
68 * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
69 * classes should, by convention, start with JC (javac).
70 *
71 * <p><b>This is NOT part of any supported API.
72 * If you write code that depends on this, you do so at your own risk.
73 * This code and its internal interfaces are subject to change or
74 * deletion without notice.</b>
75 *
76 * @see TreeMaker
77 * @see TreeInfo
78 * @see TreeTranslator
79 * @see Pretty
80 */
81 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
83 /* Tree tag values, identifying kinds of trees */
84 public enum Tag {
85 /** For methods that return an invalid tag if a given condition is not met
86 */
87 NO_TAG,
89 /** Toplevel nodes, of type TopLevel, representing entire source files.
90 */
91 TOPLEVEL,
93 /** Import clauses, of type Import.
94 */
95 IMPORT,
97 /** Class definitions, of type ClassDef.
98 */
99 CLASSDEF,
101 /** Method definitions, of type MethodDef.
102 */
103 METHODDEF,
105 /** Variable definitions, of type VarDef.
106 */
107 VARDEF,
109 /** The no-op statement ";", of type Skip
110 */
111 SKIP,
113 /** Blocks, of type Block.
114 */
115 BLOCK,
117 /** Do-while loops, of type DoLoop.
118 */
119 DOLOOP,
121 /** While-loops, of type WhileLoop.
122 */
123 WHILELOOP,
125 /** For-loops, of type ForLoop.
126 */
127 FORLOOP,
129 /** Foreach-loops, of type ForeachLoop.
130 */
131 FOREACHLOOP,
133 /** Labelled statements, of type Labelled.
134 */
135 LABELLED,
137 /** Switch statements, of type Switch.
138 */
139 SWITCH,
141 /** Case parts in switch statements, of type Case.
142 */
143 CASE,
145 /** Synchronized statements, of type Synchonized.
146 */
147 SYNCHRONIZED,
149 /** Try statements, of type Try.
150 */
151 TRY,
153 /** Catch clauses in try statements, of type Catch.
154 */
155 CATCH,
157 /** Conditional expressions, of type Conditional.
158 */
159 CONDEXPR,
161 /** Conditional statements, of type If.
162 */
163 IF,
165 /** Expression statements, of type Exec.
166 */
167 EXEC,
169 /** Break statements, of type Break.
170 */
171 BREAK,
173 /** Continue statements, of type Continue.
174 */
175 CONTINUE,
177 /** Return statements, of type Return.
178 */
179 RETURN,
181 /** Throw statements, of type Throw.
182 */
183 THROW,
185 /** Assert statements, of type Assert.
186 */
187 ASSERT,
189 /** Method invocation expressions, of type Apply.
190 */
191 APPLY,
193 /** Class instance creation expressions, of type NewClass.
194 */
195 NEWCLASS,
197 /** Array creation expressions, of type NewArray.
198 */
199 NEWARRAY,
201 /** Lambda expression, of type Lambda.
202 */
203 LAMBDA,
205 /** Parenthesized subexpressions, of type Parens.
206 */
207 PARENS,
209 /** Assignment expressions, of type Assign.
210 */
211 ASSIGN,
213 /** Type cast expressions, of type TypeCast.
214 */
215 TYPECAST,
217 /** Type test expressions, of type TypeTest.
218 */
219 TYPETEST,
221 /** Indexed array expressions, of type Indexed.
222 */
223 INDEXED,
225 /** Selections, of type Select.
226 */
227 SELECT,
229 /** Member references, of type Reference.
230 */
231 REFERENCE,
233 /** Simple identifiers, of type Ident.
234 */
235 IDENT,
237 /** Literals, of type Literal.
238 */
239 LITERAL,
241 /** Basic type identifiers, of type TypeIdent.
242 */
243 TYPEIDENT,
245 /** Array types, of type TypeArray.
246 */
247 TYPEARRAY,
249 /** Parameterized types, of type TypeApply.
250 */
251 TYPEAPPLY,
253 /** Union types, of type TypeUnion
254 */
255 TYPEUNION,
257 /** Intersection types, of type TypeIntersection
258 */
259 TYPEINTERSECTION,
261 /** Formal type parameters, of type TypeParameter.
262 */
263 TYPEPARAMETER,
265 /** Type argument.
266 */
267 WILDCARD,
269 /** Bound kind: extends, super, exact, or unbound
270 */
271 TYPEBOUNDKIND,
273 /** metadata: Annotation.
274 */
275 ANNOTATION,
277 /** metadata: Modifiers
278 */
279 MODIFIERS,
281 ANNOTATED_TYPE,
283 /** Error trees, of type Erroneous.
284 */
285 ERRONEOUS,
287 /** Unary operators, of type Unary.
288 */
289 POS, // +
290 NEG, // -
291 NOT, // !
292 COMPL, // ~
293 PREINC, // ++ _
294 PREDEC, // -- _
295 POSTINC, // _ ++
296 POSTDEC, // _ --
298 /** unary operator for null reference checks, only used internally.
299 */
300 NULLCHK,
302 /** Binary operators, of type Binary.
303 */
304 OR, // ||
305 AND, // &&
306 BITOR, // |
307 BITXOR, // ^
308 BITAND, // &
309 EQ, // ==
310 NE, // !=
311 LT, // <
312 GT, // >
313 LE, // <=
314 GE, // >=
315 SL, // <<
316 SR, // >>
317 USR, // >>>
318 PLUS, // +
319 MINUS, // -
320 MUL, // *
321 DIV, // /
322 MOD, // %
324 /** Assignment operators, of type Assignop.
325 */
326 BITOR_ASG(BITOR), // |=
327 BITXOR_ASG(BITXOR), // ^=
328 BITAND_ASG(BITAND), // &=
330 SL_ASG(SL), // <<=
331 SR_ASG(SR), // >>=
332 USR_ASG(USR), // >>>=
333 PLUS_ASG(PLUS), // +=
334 MINUS_ASG(MINUS), // -=
335 MUL_ASG(MUL), // *=
336 DIV_ASG(DIV), // /=
337 MOD_ASG(MOD), // %=
339 /** A synthetic let expression, of type LetExpr.
340 */
341 LETEXPR; // ala scheme
343 private final Tag noAssignTag;
345 private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
347 private Tag(Tag noAssignTag) {
348 this.noAssignTag = noAssignTag;
349 }
351 private Tag() {
352 this(null);
353 }
355 public static int getNumberOfOperators() {
356 return numberOfOperators;
357 }
359 public Tag noAssignOp() {
360 if (noAssignTag != null)
361 return noAssignTag;
362 throw new AssertionError("noAssignOp() method is not available for non assignment tags");
363 }
365 public boolean isPostUnaryOp() {
366 return (this == POSTINC || this == POSTDEC);
367 }
369 public boolean isIncOrDecUnaryOp() {
370 return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
371 }
373 public boolean isAssignop() {
374 return noAssignTag != null;
375 }
377 public int operatorIndex() {
378 return (this.ordinal() - POS.ordinal());
379 }
380 }
382 /* The (encoded) position in the source file. @see util.Position.
383 */
384 public int pos;
386 /* The type of this node.
387 */
388 public Type type;
390 /* The tag of this node -- one of the constants declared above.
391 */
392 public abstract Tag getTag();
394 /* Returns true if the tag of this node is equals to tag.
395 */
396 public boolean hasTag(Tag tag) {
397 return tag == getTag();
398 }
400 /** Convert a tree to a pretty-printed string. */
401 @Override
402 public String toString() {
403 StringWriter s = new StringWriter();
404 try {
405 new Pretty(s, false).printExpr(this);
406 }
407 catch (IOException e) {
408 // should never happen, because StringWriter is defined
409 // never to throw any IOExceptions
410 throw new AssertionError(e);
411 }
412 return s.toString();
413 }
415 /** Set position field and return this tree.
416 */
417 public JCTree setPos(int pos) {
418 this.pos = pos;
419 return this;
420 }
422 /** Set type field and return this tree.
423 */
424 public JCTree setType(Type type) {
425 this.type = type;
426 return this;
427 }
429 /** Visit this tree with a given visitor.
430 */
431 public abstract void accept(Visitor v);
433 public abstract <R,D> R accept(TreeVisitor<R,D> v, D d);
435 /** Return a shallow copy of this tree.
436 */
437 @Override
438 public Object clone() {
439 try {
440 return super.clone();
441 } catch(CloneNotSupportedException e) {
442 throw new RuntimeException(e);
443 }
444 }
446 /** Get a default position for this tree node.
447 */
448 public DiagnosticPosition pos() {
449 return this;
450 }
452 // for default DiagnosticPosition
453 public JCTree getTree() {
454 return this;
455 }
457 // for default DiagnosticPosition
458 public int getStartPosition() {
459 return TreeInfo.getStartPos(this);
460 }
462 // for default DiagnosticPosition
463 public int getPreferredPosition() {
464 return pos;
465 }
467 // for default DiagnosticPosition
468 public int getEndPosition(EndPosTable endPosTable) {
469 return TreeInfo.getEndPos(this, endPosTable);
470 }
472 /**
473 * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure.
474 */
475 public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
476 public List<JCAnnotation> packageAnnotations;
477 /** The tree representing the package clause. */
478 public JCExpression pid;
479 /** All definitions in this file (ClassDef, Import, and Skip) */
480 public List<JCTree> defs;
481 /* The source file name. */
482 public JavaFileObject sourcefile;
483 /** The package to which this compilation unit belongs. */
484 public PackageSymbol packge;
485 /** A scope for all named imports. */
486 public ImportScope namedImportScope;
487 /** A scope for all import-on-demands. */
488 public StarImportScope starImportScope;
489 /** Line starting positions, defined only if option -g is set. */
490 public Position.LineMap lineMap = null;
491 /** A table that stores all documentation comments indexed by the tree
492 * nodes they refer to. defined only if option -s is set. */
493 public DocCommentTable docComments = null;
494 /* An object encapsulating ending positions of source ranges indexed by
495 * the tree nodes they belong to. Defined only if option -Xjcov is set. */
496 public EndPosTable endPositions = null;
497 protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
498 JCExpression pid,
499 List<JCTree> defs,
500 JavaFileObject sourcefile,
501 PackageSymbol packge,
502 ImportScope namedImportScope,
503 StarImportScope starImportScope) {
504 this.packageAnnotations = packageAnnotations;
505 this.pid = pid;
506 this.defs = defs;
507 this.sourcefile = sourcefile;
508 this.packge = packge;
509 this.namedImportScope = namedImportScope;
510 this.starImportScope = starImportScope;
511 }
512 @Override
513 public void accept(Visitor v) { v.visitTopLevel(this); }
515 public Kind getKind() { return Kind.COMPILATION_UNIT; }
516 public List<JCAnnotation> getPackageAnnotations() {
517 return packageAnnotations;
518 }
519 public List<JCImport> getImports() {
520 ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
521 for (JCTree tree : defs) {
522 if (tree.hasTag(IMPORT))
523 imports.append((JCImport)tree);
524 else if (!tree.hasTag(SKIP))
525 break;
526 }
527 return imports.toList();
528 }
529 public JCExpression getPackageName() { return pid; }
530 public JavaFileObject getSourceFile() {
531 return sourcefile;
532 }
533 public Position.LineMap getLineMap() {
534 return lineMap;
535 }
536 public List<JCTree> getTypeDecls() {
537 List<JCTree> typeDefs;
538 for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail)
539 if (!typeDefs.head.hasTag(IMPORT))
540 break;
541 return typeDefs;
542 }
543 @Override
544 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
545 return v.visitCompilationUnit(this, d);
546 }
548 @Override
549 public Tag getTag() {
550 return TOPLEVEL;
551 }
552 }
554 /**
555 * An import clause.
556 */
557 public static class JCImport extends JCTree implements ImportTree {
558 public boolean staticImport;
559 /** The imported class(es). */
560 public JCTree qualid;
561 protected JCImport(JCTree qualid, boolean importStatic) {
562 this.qualid = qualid;
563 this.staticImport = importStatic;
564 }
565 @Override
566 public void accept(Visitor v) { v.visitImport(this); }
568 public boolean isStatic() { return staticImport; }
569 public JCTree getQualifiedIdentifier() { return qualid; }
571 public Kind getKind() { return Kind.IMPORT; }
572 @Override
573 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
574 return v.visitImport(this, d);
575 }
577 @Override
578 public Tag getTag() {
579 return IMPORT;
580 }
581 }
583 public static abstract class JCStatement extends JCTree implements StatementTree {
584 @Override
585 public JCStatement setType(Type type) {
586 super.setType(type);
587 return this;
588 }
589 @Override
590 public JCStatement setPos(int pos) {
591 super.setPos(pos);
592 return this;
593 }
594 }
596 public static abstract class JCExpression extends JCTree implements ExpressionTree {
597 @Override
598 public JCExpression setType(Type type) {
599 super.setType(type);
600 return this;
601 }
602 @Override
603 public JCExpression setPos(int pos) {
604 super.setPos(pos);
605 return this;
606 }
607 }
609 /**
610 * A class definition.
611 */
612 public static class JCClassDecl extends JCStatement implements ClassTree {
613 /** the modifiers */
614 public JCModifiers mods;
615 /** the name of the class */
616 public Name name;
617 /** formal class parameters */
618 public List<JCTypeParameter> typarams;
619 /** the classes this class extends */
620 public JCExpression extending;
621 /** the interfaces implemented by this class */
622 public List<JCExpression> implementing;
623 /** all variables and methods defined in this class */
624 public List<JCTree> defs;
625 /** the symbol */
626 public ClassSymbol sym;
627 protected JCClassDecl(JCModifiers mods,
628 Name name,
629 List<JCTypeParameter> typarams,
630 JCExpression extending,
631 List<JCExpression> implementing,
632 List<JCTree> defs,
633 ClassSymbol sym)
634 {
635 this.mods = mods;
636 this.name = name;
637 this.typarams = typarams;
638 this.extending = extending;
639 this.implementing = implementing;
640 this.defs = defs;
641 this.sym = sym;
642 }
643 @Override
644 public void accept(Visitor v) { v.visitClassDef(this); }
646 public Kind getKind() {
647 if ((mods.flags & Flags.ANNOTATION) != 0)
648 return Kind.ANNOTATION_TYPE;
649 else if ((mods.flags & Flags.INTERFACE) != 0)
650 return Kind.INTERFACE;
651 else if ((mods.flags & Flags.ENUM) != 0)
652 return Kind.ENUM;
653 else
654 return Kind.CLASS;
655 }
657 public JCModifiers getModifiers() { return mods; }
658 public Name getSimpleName() { return name; }
659 public List<JCTypeParameter> getTypeParameters() {
660 return typarams;
661 }
662 public JCTree getExtendsClause() { return extending; }
663 public List<JCExpression> getImplementsClause() {
664 return implementing;
665 }
666 public List<JCTree> getMembers() {
667 return defs;
668 }
669 @Override
670 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
671 return v.visitClass(this, d);
672 }
674 @Override
675 public Tag getTag() {
676 return CLASSDEF;
677 }
678 }
680 /**
681 * A method definition.
682 */
683 public static class JCMethodDecl extends JCTree implements MethodTree {
684 /** method modifiers */
685 public JCModifiers mods;
686 /** method name */
687 public Name name;
688 /** type of method return value */
689 public JCExpression restype;
690 /** type parameters */
691 public List<JCTypeParameter> typarams;
692 /** value parameters */
693 public List<JCVariableDecl> params;
694 /** exceptions thrown by this method */
695 public List<JCExpression> thrown;
696 /** statements in the method */
697 public JCBlock body;
698 /** default value, for annotation types */
699 public JCExpression defaultValue;
700 /** method symbol */
701 public MethodSymbol sym;
702 protected JCMethodDecl(JCModifiers mods,
703 Name name,
704 JCExpression restype,
705 List<JCTypeParameter> typarams,
706 List<JCVariableDecl> params,
707 List<JCExpression> thrown,
708 JCBlock body,
709 JCExpression defaultValue,
710 MethodSymbol sym)
711 {
712 this.mods = mods;
713 this.name = name;
714 this.restype = restype;
715 this.typarams = typarams;
716 this.params = params;
717 this.thrown = thrown;
718 this.body = body;
719 this.defaultValue = defaultValue;
720 this.sym = sym;
721 }
722 @Override
723 public void accept(Visitor v) { v.visitMethodDef(this); }
725 public Kind getKind() { return Kind.METHOD; }
726 public JCModifiers getModifiers() { return mods; }
727 public Name getName() { return name; }
728 public JCTree getReturnType() { return restype; }
729 public List<JCTypeParameter> getTypeParameters() {
730 return typarams;
731 }
732 public List<JCVariableDecl> getParameters() {
733 return params;
734 }
735 public List<JCExpression> getThrows() {
736 return thrown;
737 }
738 public JCBlock getBody() { return body; }
739 public JCTree getDefaultValue() { // for annotation types
740 return defaultValue;
741 }
742 @Override
743 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
744 return v.visitMethod(this, d);
745 }
747 @Override
748 public Tag getTag() {
749 return METHODDEF;
750 }
751 }
753 /**
754 * A variable definition.
755 */
756 public static class JCVariableDecl extends JCStatement implements VariableTree {
757 /** variable modifiers */
758 public JCModifiers mods;
759 /** variable name */
760 public Name name;
761 /** type of the variable */
762 public JCExpression vartype;
763 /** variable's initial value */
764 public JCExpression init;
765 /** symbol */
766 public VarSymbol sym;
767 protected JCVariableDecl(JCModifiers mods,
768 Name name,
769 JCExpression vartype,
770 JCExpression init,
771 VarSymbol sym) {
772 this.mods = mods;
773 this.name = name;
774 this.vartype = vartype;
775 this.init = init;
776 this.sym = sym;
777 }
778 @Override
779 public void accept(Visitor v) { v.visitVarDef(this); }
781 public Kind getKind() { return Kind.VARIABLE; }
782 public JCModifiers getModifiers() { return mods; }
783 public Name getName() { return name; }
784 public JCTree getType() { return vartype; }
785 public JCExpression getInitializer() {
786 return init;
787 }
788 @Override
789 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
790 return v.visitVariable(this, d);
791 }
793 @Override
794 public Tag getTag() {
795 return VARDEF;
796 }
797 }
799 /**
800 * A no-op statement ";".
801 */
802 public static class JCSkip extends JCStatement implements EmptyStatementTree {
803 protected JCSkip() {
804 }
805 @Override
806 public void accept(Visitor v) { v.visitSkip(this); }
808 public Kind getKind() { return Kind.EMPTY_STATEMENT; }
809 @Override
810 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
811 return v.visitEmptyStatement(this, d);
812 }
814 @Override
815 public Tag getTag() {
816 return SKIP;
817 }
818 }
820 /**
821 * A statement block.
822 */
823 public static class JCBlock extends JCStatement implements BlockTree {
824 /** flags */
825 public long flags;
826 /** statements */
827 public List<JCStatement> stats;
828 /** Position of closing brace, optional. */
829 public int endpos = Position.NOPOS;
830 protected JCBlock(long flags, List<JCStatement> stats) {
831 this.stats = stats;
832 this.flags = flags;
833 }
834 @Override
835 public void accept(Visitor v) { v.visitBlock(this); }
837 public Kind getKind() { return Kind.BLOCK; }
838 public List<JCStatement> getStatements() {
839 return stats;
840 }
841 public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
842 @Override
843 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
844 return v.visitBlock(this, d);
845 }
847 @Override
848 public Tag getTag() {
849 return BLOCK;
850 }
851 }
853 /**
854 * A do loop
855 */
856 public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
857 public JCStatement body;
858 public JCExpression cond;
859 protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
860 this.body = body;
861 this.cond = cond;
862 }
863 @Override
864 public void accept(Visitor v) { v.visitDoLoop(this); }
866 public Kind getKind() { return Kind.DO_WHILE_LOOP; }
867 public JCExpression getCondition() { return cond; }
868 public JCStatement getStatement() { return body; }
869 @Override
870 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
871 return v.visitDoWhileLoop(this, d);
872 }
874 @Override
875 public Tag getTag() {
876 return DOLOOP;
877 }
878 }
880 /**
881 * A while loop
882 */
883 public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
884 public JCExpression cond;
885 public JCStatement body;
886 protected JCWhileLoop(JCExpression cond, JCStatement body) {
887 this.cond = cond;
888 this.body = body;
889 }
890 @Override
891 public void accept(Visitor v) { v.visitWhileLoop(this); }
893 public Kind getKind() { return Kind.WHILE_LOOP; }
894 public JCExpression getCondition() { return cond; }
895 public JCStatement getStatement() { return body; }
896 @Override
897 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
898 return v.visitWhileLoop(this, d);
899 }
901 @Override
902 public Tag getTag() {
903 return WHILELOOP;
904 }
905 }
907 /**
908 * A for loop.
909 */
910 public static class JCForLoop extends JCStatement implements ForLoopTree {
911 public List<JCStatement> init;
912 public JCExpression cond;
913 public List<JCExpressionStatement> step;
914 public JCStatement body;
915 protected JCForLoop(List<JCStatement> init,
916 JCExpression cond,
917 List<JCExpressionStatement> update,
918 JCStatement body)
919 {
920 this.init = init;
921 this.cond = cond;
922 this.step = update;
923 this.body = body;
924 }
925 @Override
926 public void accept(Visitor v) { v.visitForLoop(this); }
928 public Kind getKind() { return Kind.FOR_LOOP; }
929 public JCExpression getCondition() { return cond; }
930 public JCStatement getStatement() { return body; }
931 public List<JCStatement> getInitializer() {
932 return init;
933 }
934 public List<JCExpressionStatement> getUpdate() {
935 return step;
936 }
937 @Override
938 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
939 return v.visitForLoop(this, d);
940 }
942 @Override
943 public Tag getTag() {
944 return FORLOOP;
945 }
946 }
948 /**
949 * The enhanced for loop.
950 */
951 public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
952 public JCVariableDecl var;
953 public JCExpression expr;
954 public JCStatement body;
955 protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
956 this.var = var;
957 this.expr = expr;
958 this.body = body;
959 }
960 @Override
961 public void accept(Visitor v) { v.visitForeachLoop(this); }
963 public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
964 public JCVariableDecl getVariable() { return var; }
965 public JCExpression getExpression() { return expr; }
966 public JCStatement getStatement() { return body; }
967 @Override
968 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
969 return v.visitEnhancedForLoop(this, d);
970 }
971 @Override
972 public Tag getTag() {
973 return FOREACHLOOP;
974 }
975 }
977 /**
978 * A labelled expression or statement.
979 */
980 public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
981 public Name label;
982 public JCStatement body;
983 protected JCLabeledStatement(Name label, JCStatement body) {
984 this.label = label;
985 this.body = body;
986 }
987 @Override
988 public void accept(Visitor v) { v.visitLabelled(this); }
989 public Kind getKind() { return Kind.LABELED_STATEMENT; }
990 public Name getLabel() { return label; }
991 public JCStatement getStatement() { return body; }
992 @Override
993 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
994 return v.visitLabeledStatement(this, d);
995 }
996 @Override
997 public Tag getTag() {
998 return LABELLED;
999 }
1000 }
1002 /**
1003 * A "switch ( ) { }" construction.
1004 */
1005 public static class JCSwitch extends JCStatement implements SwitchTree {
1006 public JCExpression selector;
1007 public List<JCCase> cases;
1008 protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1009 this.selector = selector;
1010 this.cases = cases;
1011 }
1012 @Override
1013 public void accept(Visitor v) { v.visitSwitch(this); }
1015 public Kind getKind() { return Kind.SWITCH; }
1016 public JCExpression getExpression() { return selector; }
1017 public List<JCCase> getCases() { return cases; }
1018 @Override
1019 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1020 return v.visitSwitch(this, d);
1021 }
1022 @Override
1023 public Tag getTag() {
1024 return SWITCH;
1025 }
1026 }
1028 /**
1029 * A "case :" of a switch.
1030 */
1031 public static class JCCase extends JCStatement implements CaseTree {
1032 public JCExpression pat;
1033 public List<JCStatement> stats;
1034 protected JCCase(JCExpression pat, List<JCStatement> stats) {
1035 this.pat = pat;
1036 this.stats = stats;
1037 }
1038 @Override
1039 public void accept(Visitor v) { v.visitCase(this); }
1041 public Kind getKind() { return Kind.CASE; }
1042 public JCExpression getExpression() { return pat; }
1043 public List<JCStatement> getStatements() { return stats; }
1044 @Override
1045 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1046 return v.visitCase(this, d);
1047 }
1048 @Override
1049 public Tag getTag() {
1050 return CASE;
1051 }
1052 }
1054 /**
1055 * A synchronized block.
1056 */
1057 public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1058 public JCExpression lock;
1059 public JCBlock body;
1060 protected JCSynchronized(JCExpression lock, JCBlock body) {
1061 this.lock = lock;
1062 this.body = body;
1063 }
1064 @Override
1065 public void accept(Visitor v) { v.visitSynchronized(this); }
1067 public Kind getKind() { return Kind.SYNCHRONIZED; }
1068 public JCExpression getExpression() { return lock; }
1069 public JCBlock getBlock() { return body; }
1070 @Override
1071 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1072 return v.visitSynchronized(this, d);
1073 }
1074 @Override
1075 public Tag getTag() {
1076 return SYNCHRONIZED;
1077 }
1078 }
1080 /**
1081 * A "try { } catch ( ) { } finally { }" block.
1082 */
1083 public static class JCTry extends JCStatement implements TryTree {
1084 public JCBlock body;
1085 public List<JCCatch> catchers;
1086 public JCBlock finalizer;
1087 public List<JCTree> resources;
1088 public boolean finallyCanCompleteNormally;
1089 protected JCTry(List<JCTree> resources,
1090 JCBlock body,
1091 List<JCCatch> catchers,
1092 JCBlock finalizer) {
1093 this.body = body;
1094 this.catchers = catchers;
1095 this.finalizer = finalizer;
1096 this.resources = resources;
1097 }
1098 @Override
1099 public void accept(Visitor v) { v.visitTry(this); }
1101 public Kind getKind() { return Kind.TRY; }
1102 public JCBlock getBlock() { return body; }
1103 public List<JCCatch> getCatches() {
1104 return catchers;
1105 }
1106 public JCBlock getFinallyBlock() { return finalizer; }
1107 @Override
1108 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1109 return v.visitTry(this, d);
1110 }
1111 @Override
1112 public List<? extends JCTree> getResources() {
1113 return resources;
1114 }
1115 @Override
1116 public Tag getTag() {
1117 return TRY;
1118 }
1119 }
1121 /**
1122 * A catch block.
1123 */
1124 public static class JCCatch extends JCTree implements CatchTree {
1125 public JCVariableDecl param;
1126 public JCBlock body;
1127 protected JCCatch(JCVariableDecl param, JCBlock body) {
1128 this.param = param;
1129 this.body = body;
1130 }
1131 @Override
1132 public void accept(Visitor v) { v.visitCatch(this); }
1134 public Kind getKind() { return Kind.CATCH; }
1135 public JCVariableDecl getParameter() { return param; }
1136 public JCBlock getBlock() { return body; }
1137 @Override
1138 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1139 return v.visitCatch(this, d);
1140 }
1141 @Override
1142 public Tag getTag() {
1143 return CATCH;
1144 }
1145 }
1147 /**
1148 * A ( ) ? ( ) : ( ) conditional expression
1149 */
1150 public static class JCConditional extends JCExpression implements ConditionalExpressionTree {
1151 public JCExpression cond;
1152 public JCExpression truepart;
1153 public JCExpression falsepart;
1154 protected JCConditional(JCExpression cond,
1155 JCExpression truepart,
1156 JCExpression falsepart)
1157 {
1158 this.cond = cond;
1159 this.truepart = truepart;
1160 this.falsepart = falsepart;
1161 }
1162 @Override
1163 public void accept(Visitor v) { v.visitConditional(this); }
1165 public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1166 public JCExpression getCondition() { return cond; }
1167 public JCExpression getTrueExpression() { return truepart; }
1168 public JCExpression getFalseExpression() { return falsepart; }
1169 @Override
1170 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1171 return v.visitConditionalExpression(this, d);
1172 }
1173 @Override
1174 public Tag getTag() {
1175 return CONDEXPR;
1176 }
1177 }
1179 /**
1180 * An "if ( ) { } else { }" block
1181 */
1182 public static class JCIf extends JCStatement implements IfTree {
1183 public JCExpression cond;
1184 public JCStatement thenpart;
1185 public JCStatement elsepart;
1186 protected JCIf(JCExpression cond,
1187 JCStatement thenpart,
1188 JCStatement elsepart)
1189 {
1190 this.cond = cond;
1191 this.thenpart = thenpart;
1192 this.elsepart = elsepart;
1193 }
1194 @Override
1195 public void accept(Visitor v) { v.visitIf(this); }
1197 public Kind getKind() { return Kind.IF; }
1198 public JCExpression getCondition() { return cond; }
1199 public JCStatement getThenStatement() { return thenpart; }
1200 public JCStatement getElseStatement() { return elsepart; }
1201 @Override
1202 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1203 return v.visitIf(this, d);
1204 }
1205 @Override
1206 public Tag getTag() {
1207 return IF;
1208 }
1209 }
1211 /**
1212 * an expression statement
1213 */
1214 public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1215 /** expression structure */
1216 public JCExpression expr;
1217 protected JCExpressionStatement(JCExpression expr)
1218 {
1219 this.expr = expr;
1220 }
1221 @Override
1222 public void accept(Visitor v) { v.visitExec(this); }
1224 public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1225 public JCExpression getExpression() { return expr; }
1226 @Override
1227 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1228 return v.visitExpressionStatement(this, d);
1229 }
1230 @Override
1231 public Tag getTag() {
1232 return EXEC;
1233 }
1235 /** Convert a expression-statement tree to a pretty-printed string. */
1236 @Override
1237 public String toString() {
1238 StringWriter s = new StringWriter();
1239 try {
1240 new Pretty(s, false).printStat(this);
1241 }
1242 catch (IOException e) {
1243 // should never happen, because StringWriter is defined
1244 // never to throw any IOExceptions
1245 throw new AssertionError(e);
1246 }
1247 return s.toString();
1248 }
1249 }
1251 /**
1252 * A break from a loop or switch.
1253 */
1254 public static class JCBreak extends JCStatement implements BreakTree {
1255 public Name label;
1256 public JCTree target;
1257 protected JCBreak(Name label, JCTree target) {
1258 this.label = label;
1259 this.target = target;
1260 }
1261 @Override
1262 public void accept(Visitor v) { v.visitBreak(this); }
1264 public Kind getKind() { return Kind.BREAK; }
1265 public Name getLabel() { return label; }
1266 @Override
1267 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1268 return v.visitBreak(this, d);
1269 }
1270 @Override
1271 public Tag getTag() {
1272 return BREAK;
1273 }
1274 }
1276 /**
1277 * A continue of a loop.
1278 */
1279 public static class JCContinue extends JCStatement implements ContinueTree {
1280 public Name label;
1281 public JCTree target;
1282 protected JCContinue(Name label, JCTree target) {
1283 this.label = label;
1284 this.target = target;
1285 }
1286 @Override
1287 public void accept(Visitor v) { v.visitContinue(this); }
1289 public Kind getKind() { return Kind.CONTINUE; }
1290 public Name getLabel() { return label; }
1291 @Override
1292 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1293 return v.visitContinue(this, d);
1294 }
1295 @Override
1296 public Tag getTag() {
1297 return CONTINUE;
1298 }
1299 }
1301 /**
1302 * A return statement.
1303 */
1304 public static class JCReturn extends JCStatement implements ReturnTree {
1305 public JCExpression expr;
1306 protected JCReturn(JCExpression expr) {
1307 this.expr = expr;
1308 }
1309 @Override
1310 public void accept(Visitor v) { v.visitReturn(this); }
1312 public Kind getKind() { return Kind.RETURN; }
1313 public JCExpression getExpression() { return expr; }
1314 @Override
1315 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1316 return v.visitReturn(this, d);
1317 }
1318 @Override
1319 public Tag getTag() {
1320 return RETURN;
1321 }
1322 }
1324 /**
1325 * A throw statement.
1326 */
1327 public static class JCThrow extends JCStatement implements ThrowTree {
1328 public JCExpression expr;
1329 protected JCThrow(JCTree expr) {
1330 this.expr = (JCExpression)expr;
1331 }
1332 @Override
1333 public void accept(Visitor v) { v.visitThrow(this); }
1335 public Kind getKind() { return Kind.THROW; }
1336 public JCExpression getExpression() { return expr; }
1337 @Override
1338 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1339 return v.visitThrow(this, d);
1340 }
1341 @Override
1342 public Tag getTag() {
1343 return THROW;
1344 }
1345 }
1347 /**
1348 * An assert statement.
1349 */
1350 public static class JCAssert extends JCStatement implements AssertTree {
1351 public JCExpression cond;
1352 public JCExpression detail;
1353 protected JCAssert(JCExpression cond, JCExpression detail) {
1354 this.cond = cond;
1355 this.detail = detail;
1356 }
1357 @Override
1358 public void accept(Visitor v) { v.visitAssert(this); }
1360 public Kind getKind() { return Kind.ASSERT; }
1361 public JCExpression getCondition() { return cond; }
1362 public JCExpression getDetail() { return detail; }
1363 @Override
1364 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1365 return v.visitAssert(this, d);
1366 }
1367 @Override
1368 public Tag getTag() {
1369 return ASSERT;
1370 }
1371 }
1373 /**
1374 * A method invocation
1375 */
1376 public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree {
1377 public List<JCExpression> typeargs;
1378 public JCExpression meth;
1379 public List<JCExpression> args;
1380 public Type varargsElement;
1381 protected JCMethodInvocation(List<JCExpression> typeargs,
1382 JCExpression meth,
1383 List<JCExpression> args)
1384 {
1385 this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
1386 : typeargs;
1387 this.meth = meth;
1388 this.args = args;
1389 }
1390 @Override
1391 public void accept(Visitor v) { v.visitApply(this); }
1393 public Kind getKind() { return Kind.METHOD_INVOCATION; }
1394 public List<JCExpression> getTypeArguments() {
1395 return typeargs;
1396 }
1397 public JCExpression getMethodSelect() { return meth; }
1398 public List<JCExpression> getArguments() {
1399 return args;
1400 }
1401 @Override
1402 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1403 return v.visitMethodInvocation(this, d);
1404 }
1405 @Override
1406 public JCMethodInvocation setType(Type type) {
1407 super.setType(type);
1408 return this;
1409 }
1410 @Override
1411 public Tag getTag() {
1412 return(APPLY);
1413 }
1414 }
1416 /**
1417 * A new(...) operation.
1418 */
1419 public static class JCNewClass extends JCExpression implements NewClassTree {
1420 public JCExpression encl;
1421 public List<JCExpression> typeargs;
1422 public JCExpression clazz;
1423 public List<JCExpression> args;
1424 public JCClassDecl def;
1425 public Symbol constructor;
1426 public Type varargsElement;
1427 public Type constructorType;
1428 protected JCNewClass(JCExpression encl,
1429 List<JCExpression> typeargs,
1430 JCExpression clazz,
1431 List<JCExpression> args,
1432 JCClassDecl def)
1433 {
1434 this.encl = encl;
1435 this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
1436 : typeargs;
1437 this.clazz = clazz;
1438 this.args = args;
1439 this.def = def;
1440 }
1441 @Override
1442 public void accept(Visitor v) { v.visitNewClass(this); }
1444 public Kind getKind() { return Kind.NEW_CLASS; }
1445 public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1446 return encl;
1447 }
1448 public List<JCExpression> getTypeArguments() {
1449 return typeargs;
1450 }
1451 public JCExpression getIdentifier() { return clazz; }
1452 public List<JCExpression> getArguments() {
1453 return args;
1454 }
1455 public JCClassDecl getClassBody() { return def; }
1456 @Override
1457 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1458 return v.visitNewClass(this, d);
1459 }
1460 @Override
1461 public Tag getTag() {
1462 return NEWCLASS;
1463 }
1464 }
1466 /**
1467 * A new[...] operation.
1468 */
1469 public static class JCNewArray extends JCExpression implements NewArrayTree {
1470 public JCExpression elemtype;
1471 public List<JCExpression> dims;
1472 public List<JCExpression> elems;
1473 protected JCNewArray(JCExpression elemtype,
1474 List<JCExpression> dims,
1475 List<JCExpression> elems)
1476 {
1477 this.elemtype = elemtype;
1478 this.dims = dims;
1479 this.elems = elems;
1480 }
1481 @Override
1482 public void accept(Visitor v) { v.visitNewArray(this); }
1484 public Kind getKind() { return Kind.NEW_ARRAY; }
1485 public JCExpression getType() { return elemtype; }
1486 public List<JCExpression> getDimensions() {
1487 return dims;
1488 }
1489 public List<JCExpression> getInitializers() {
1490 return elems;
1491 }
1492 @Override
1493 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1494 return v.visitNewArray(this, d);
1495 }
1496 @Override
1497 public Tag getTag() {
1498 return NEWARRAY;
1499 }
1500 }
1502 /**
1503 * A lambda expression.
1504 */
1505 public static class JCLambda extends JCExpression implements LambdaExpressionTree {
1507 public List<JCVariableDecl> params;
1508 public JCTree body;
1509 public Type targetType;
1510 public boolean canCompleteNormally = true;
1511 public List<Type> inferredThrownTypes;
1513 public JCLambda(List<JCVariableDecl> params,
1514 JCTree body) {
1515 this.params = params;
1516 this.body = body;
1517 }
1518 @Override
1519 public Tag getTag() {
1520 return LAMBDA;
1521 }
1522 @Override
1523 public void accept(Visitor v) {
1524 v.visitLambda(this);
1525 }
1526 @Override
1527 public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1528 return v.visitLambdaExpression(this, d);
1529 }
1530 public Kind getKind() {
1531 return Kind.LAMBDA_EXPRESSION;
1532 }
1533 public JCTree getBody() {
1534 return body;
1535 }
1536 public java.util.List<? extends VariableTree> getParameters() {
1537 return params;
1538 }
1539 @Override
1540 public JCLambda setType(Type type) {
1541 super.setType(type);
1542 return this;
1543 }
1544 @Override
1545 public BodyKind getBodyKind() {
1546 return body.hasTag(BLOCK) ?
1547 BodyKind.STATEMENT :
1548 BodyKind.EXPRESSION;
1549 }
1550 }
1552 /**
1553 * A parenthesized subexpression ( ... )
1554 */
1555 public static class JCParens extends JCExpression implements ParenthesizedTree {
1556 public JCExpression expr;
1557 protected JCParens(JCExpression expr) {
1558 this.expr = expr;
1559 }
1560 @Override
1561 public void accept(Visitor v) { v.visitParens(this); }
1563 public Kind getKind() { return Kind.PARENTHESIZED; }
1564 public JCExpression getExpression() { return expr; }
1565 @Override
1566 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1567 return v.visitParenthesized(this, d);
1568 }
1569 @Override
1570 public Tag getTag() {
1571 return PARENS;
1572 }
1573 }
1575 /**
1576 * A assignment with "=".
1577 */
1578 public static class JCAssign extends JCExpression implements AssignmentTree {
1579 public JCExpression lhs;
1580 public JCExpression rhs;
1581 protected JCAssign(JCExpression lhs, JCExpression rhs) {
1582 this.lhs = lhs;
1583 this.rhs = rhs;
1584 }
1585 @Override
1586 public void accept(Visitor v) { v.visitAssign(this); }
1588 public Kind getKind() { return Kind.ASSIGNMENT; }
1589 public JCExpression getVariable() { return lhs; }
1590 public JCExpression getExpression() { return rhs; }
1591 @Override
1592 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1593 return v.visitAssignment(this, d);
1594 }
1595 @Override
1596 public Tag getTag() {
1597 return ASSIGN;
1598 }
1599 }
1601 /**
1602 * An assignment with "+=", "|=" ...
1603 */
1604 public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree {
1605 private Tag opcode;
1606 public JCExpression lhs;
1607 public JCExpression rhs;
1608 public Symbol operator;
1609 protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) {
1610 this.opcode = opcode;
1611 this.lhs = (JCExpression)lhs;
1612 this.rhs = (JCExpression)rhs;
1613 this.operator = operator;
1614 }
1615 @Override
1616 public void accept(Visitor v) { v.visitAssignop(this); }
1618 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1619 public JCExpression getVariable() { return lhs; }
1620 public JCExpression getExpression() { return rhs; }
1621 public Symbol getOperator() {
1622 return operator;
1623 }
1624 @Override
1625 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1626 return v.visitCompoundAssignment(this, d);
1627 }
1628 @Override
1629 public Tag getTag() {
1630 return opcode;
1631 }
1632 }
1634 /**
1635 * A unary operation.
1636 */
1637 public static class JCUnary extends JCExpression implements UnaryTree {
1638 private Tag opcode;
1639 public JCExpression arg;
1640 public Symbol operator;
1641 protected JCUnary(Tag opcode, JCExpression arg) {
1642 this.opcode = opcode;
1643 this.arg = arg;
1644 }
1645 @Override
1646 public void accept(Visitor v) { v.visitUnary(this); }
1648 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1649 public JCExpression getExpression() { return arg; }
1650 public Symbol getOperator() {
1651 return operator;
1652 }
1653 @Override
1654 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1655 return v.visitUnary(this, d);
1656 }
1657 @Override
1658 public Tag getTag() {
1659 return opcode;
1660 }
1662 public void setTag(Tag tag) {
1663 opcode = tag;
1664 }
1665 }
1667 /**
1668 * A binary operation.
1669 */
1670 public static class JCBinary extends JCExpression implements BinaryTree {
1671 private Tag opcode;
1672 public JCExpression lhs;
1673 public JCExpression rhs;
1674 public Symbol operator;
1675 protected JCBinary(Tag opcode,
1676 JCExpression lhs,
1677 JCExpression rhs,
1678 Symbol operator) {
1679 this.opcode = opcode;
1680 this.lhs = lhs;
1681 this.rhs = rhs;
1682 this.operator = operator;
1683 }
1684 @Override
1685 public void accept(Visitor v) { v.visitBinary(this); }
1687 public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
1688 public JCExpression getLeftOperand() { return lhs; }
1689 public JCExpression getRightOperand() { return rhs; }
1690 public Symbol getOperator() {
1691 return operator;
1692 }
1693 @Override
1694 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1695 return v.visitBinary(this, d);
1696 }
1697 @Override
1698 public Tag getTag() {
1699 return opcode;
1700 }
1701 }
1703 /**
1704 * A type cast.
1705 */
1706 public static class JCTypeCast extends JCExpression implements TypeCastTree {
1707 public JCTree clazz;
1708 public JCExpression expr;
1709 protected JCTypeCast(JCTree clazz, JCExpression expr) {
1710 this.clazz = clazz;
1711 this.expr = expr;
1712 }
1713 @Override
1714 public void accept(Visitor v) { v.visitTypeCast(this); }
1716 public Kind getKind() { return Kind.TYPE_CAST; }
1717 public JCTree getType() { return clazz; }
1718 public JCExpression getExpression() { return expr; }
1719 @Override
1720 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1721 return v.visitTypeCast(this, d);
1722 }
1723 @Override
1724 public Tag getTag() {
1725 return TYPECAST;
1726 }
1727 }
1729 /**
1730 * A type test.
1731 */
1732 public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
1733 public JCExpression expr;
1734 public JCTree clazz;
1735 protected JCInstanceOf(JCExpression expr, JCTree clazz) {
1736 this.expr = expr;
1737 this.clazz = clazz;
1738 }
1739 @Override
1740 public void accept(Visitor v) { v.visitTypeTest(this); }
1742 public Kind getKind() { return Kind.INSTANCE_OF; }
1743 public JCTree getType() { return clazz; }
1744 public JCExpression getExpression() { return expr; }
1745 @Override
1746 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1747 return v.visitInstanceOf(this, d);
1748 }
1749 @Override
1750 public Tag getTag() {
1751 return TYPETEST;
1752 }
1753 }
1755 /**
1756 * An array selection
1757 */
1758 public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
1759 public JCExpression indexed;
1760 public JCExpression index;
1761 protected JCArrayAccess(JCExpression indexed, JCExpression index) {
1762 this.indexed = indexed;
1763 this.index = index;
1764 }
1765 @Override
1766 public void accept(Visitor v) { v.visitIndexed(this); }
1768 public Kind getKind() { return Kind.ARRAY_ACCESS; }
1769 public JCExpression getExpression() { return indexed; }
1770 public JCExpression getIndex() { return index; }
1771 @Override
1772 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1773 return v.visitArrayAccess(this, d);
1774 }
1775 @Override
1776 public Tag getTag() {
1777 return INDEXED;
1778 }
1779 }
1781 /**
1782 * Selects through packages and classes
1783 */
1784 public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
1785 /** selected Tree hierarchy */
1786 public JCExpression selected;
1787 /** name of field to select thru */
1788 public Name name;
1789 /** symbol of the selected class */
1790 public Symbol sym;
1791 protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
1792 this.selected = selected;
1793 this.name = name;
1794 this.sym = sym;
1795 }
1796 @Override
1797 public void accept(Visitor v) { v.visitSelect(this); }
1799 public Kind getKind() { return Kind.MEMBER_SELECT; }
1800 public JCExpression getExpression() { return selected; }
1801 @Override
1802 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1803 return v.visitMemberSelect(this, d);
1804 }
1805 public Name getIdentifier() { return name; }
1806 @Override
1807 public Tag getTag() {
1808 return SELECT;
1809 }
1810 }
1812 /**
1813 * Selects a member expression.
1814 */
1815 public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
1816 public ReferenceMode mode;
1817 public ReferenceKind kind;
1818 public Name name;
1819 public JCExpression expr;
1820 public List<JCExpression> typeargs;
1821 public Type targetType;
1822 public Symbol sym;
1823 public Type varargsElement;
1825 /**
1826 * Javac-dependent classification for member references, based
1827 * on relevant properties w.r.t. code-generation
1828 */
1829 public enum ReferenceKind {
1830 /** super # instMethod */
1831 SUPER(ReferenceMode.INVOKE, false),
1832 /** Type # instMethod */
1833 UNBOUND(ReferenceMode.INVOKE, true),
1834 /** Type # staticMethod */
1835 STATIC(ReferenceMode.INVOKE, false),
1836 /** Expr # instMethod */
1837 BOUND(ReferenceMode.INVOKE, false),
1838 /** Inner # new */
1839 IMPLICIT_INNER(ReferenceMode.NEW, false),
1840 /** Toplevel # new */
1841 TOPLEVEL(ReferenceMode.NEW, false);
1843 final ReferenceMode mode;
1844 final boolean unbound;
1846 private ReferenceKind(ReferenceMode mode, boolean unbound) {
1847 this.mode = mode;
1848 this.unbound = unbound;
1849 }
1851 public boolean isUnbound() {
1852 return unbound;
1853 }
1854 }
1856 protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
1857 this.mode = mode;
1858 this.name = name;
1859 this.expr = expr;
1860 this.typeargs = typeargs;
1861 }
1862 @Override
1863 public void accept(Visitor v) { v.visitReference(this); }
1865 public Kind getKind() { return Kind.MEMBER_REFERENCE; }
1866 @Override
1867 public ReferenceMode getMode() { return mode; }
1868 @Override
1869 public JCExpression getQualifierExpression() { return expr; }
1870 @Override
1871 public Name getName() { return name; }
1872 @Override
1873 public List<JCExpression> getTypeArguments() { return typeargs; }
1875 @Override
1876 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1877 return v.visitMemberReference(this, d);
1878 }
1879 @Override
1880 public Tag getTag() {
1881 return REFERENCE;
1882 }
1883 public boolean hasKind(ReferenceKind kind) {
1884 return this.kind == kind;
1885 }
1886 }
1888 /**
1889 * An identifier
1890 */
1891 public static class JCIdent extends JCExpression implements IdentifierTree {
1892 /** the name */
1893 public Name name;
1894 /** the symbol */
1895 public Symbol sym;
1896 protected JCIdent(Name name, Symbol sym) {
1897 this.name = name;
1898 this.sym = sym;
1899 }
1900 @Override
1901 public void accept(Visitor v) { v.visitIdent(this); }
1903 public Kind getKind() { return Kind.IDENTIFIER; }
1904 public Name getName() { return name; }
1905 @Override
1906 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1907 return v.visitIdentifier(this, d);
1908 }
1909 @Override
1910 public Tag getTag() {
1911 return IDENT;
1912 }
1913 }
1915 /**
1916 * A constant value given literally.
1917 */
1918 public static class JCLiteral extends JCExpression implements LiteralTree {
1919 public TypeTag typetag;
1920 /** value representation */
1921 public Object value;
1922 protected JCLiteral(TypeTag typetag, Object value) {
1923 this.typetag = typetag;
1924 this.value = value;
1925 }
1926 @Override
1927 public void accept(Visitor v) { v.visitLiteral(this); }
1929 public Kind getKind() {
1930 return typetag.getKindLiteral();
1931 }
1933 public Object getValue() {
1934 switch (typetag) {
1935 case BOOLEAN:
1936 int bi = (Integer) value;
1937 return (bi != 0);
1938 case CHAR:
1939 int ci = (Integer) value;
1940 char c = (char) ci;
1941 if (c != ci)
1942 throw new AssertionError("bad value for char literal");
1943 return c;
1944 default:
1945 return value;
1946 }
1947 }
1948 @Override
1949 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1950 return v.visitLiteral(this, d);
1951 }
1952 @Override
1953 public JCLiteral setType(Type type) {
1954 super.setType(type);
1955 return this;
1956 }
1957 @Override
1958 public Tag getTag() {
1959 return LITERAL;
1960 }
1961 }
1963 /**
1964 * Identifies a basic type.
1965 * @see TypeTag
1966 */
1967 public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
1968 /** the basic type id */
1969 public TypeTag typetag;
1970 protected JCPrimitiveTypeTree(TypeTag typetag) {
1971 this.typetag = typetag;
1972 }
1973 @Override
1974 public void accept(Visitor v) { v.visitTypeIdent(this); }
1976 public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
1977 public TypeKind getPrimitiveTypeKind() {
1978 return typetag.getPrimitiveTypeKind();
1979 }
1981 @Override
1982 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1983 return v.visitPrimitiveType(this, d);
1984 }
1985 @Override
1986 public Tag getTag() {
1987 return TYPEIDENT;
1988 }
1989 }
1991 /**
1992 * An array type, A[]
1993 */
1994 public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
1995 public JCExpression elemtype;
1996 protected JCArrayTypeTree(JCExpression elemtype) {
1997 this.elemtype = elemtype;
1998 }
1999 @Override
2000 public void accept(Visitor v) { v.visitTypeArray(this); }
2002 public Kind getKind() { return Kind.ARRAY_TYPE; }
2003 public JCTree getType() { return elemtype; }
2004 @Override
2005 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2006 return v.visitArrayType(this, d);
2007 }
2008 @Override
2009 public Tag getTag() {
2010 return TYPEARRAY;
2011 }
2012 }
2014 /**
2015 * A parameterized type, {@literal T<...>}
2016 */
2017 public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2018 public JCExpression clazz;
2019 public List<JCExpression> arguments;
2020 protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2021 this.clazz = clazz;
2022 this.arguments = arguments;
2023 }
2024 @Override
2025 public void accept(Visitor v) { v.visitTypeApply(this); }
2027 public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2028 public JCTree getType() { return clazz; }
2029 public List<JCExpression> getTypeArguments() {
2030 return arguments;
2031 }
2032 @Override
2033 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2034 return v.visitParameterizedType(this, d);
2035 }
2036 @Override
2037 public Tag getTag() {
2038 return TYPEAPPLY;
2039 }
2040 }
2042 /**
2043 * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2044 */
2045 public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2047 public List<JCExpression> alternatives;
2049 protected JCTypeUnion(List<JCExpression> components) {
2050 this.alternatives = components;
2051 }
2052 @Override
2053 public void accept(Visitor v) { v.visitTypeUnion(this); }
2055 public Kind getKind() { return Kind.UNION_TYPE; }
2057 public List<JCExpression> getTypeAlternatives() {
2058 return alternatives;
2059 }
2060 @Override
2061 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2062 return v.visitUnionType(this, d);
2063 }
2064 @Override
2065 public Tag getTag() {
2066 return TYPEUNION;
2067 }
2068 }
2070 /**
2071 * An intersection type, T1 & T2 & ... Tn (used in cast expressions)
2072 */
2073 public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
2075 public List<JCExpression> bounds;
2077 protected JCTypeIntersection(List<JCExpression> bounds) {
2078 this.bounds = bounds;
2079 }
2080 @Override
2081 public void accept(Visitor v) { v.visitTypeIntersection(this); }
2083 public Kind getKind() { return Kind.INTERSECTION_TYPE; }
2085 public List<JCExpression> getBounds() {
2086 return bounds;
2087 }
2088 @Override
2089 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2090 return v.visitIntersectionType(this, d);
2091 }
2092 @Override
2093 public Tag getTag() {
2094 return TYPEINTERSECTION;
2095 }
2096 }
2098 /**
2099 * A formal class parameter.
2100 */
2101 public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2102 /** name */
2103 public Name name;
2104 /** bounds */
2105 public List<JCExpression> bounds;
2106 protected JCTypeParameter(Name name, List<JCExpression> bounds) {
2107 this.name = name;
2108 this.bounds = bounds;
2109 }
2110 @Override
2111 public void accept(Visitor v) { v.visitTypeParameter(this); }
2113 public Kind getKind() { return Kind.TYPE_PARAMETER; }
2114 public Name getName() { return name; }
2115 public List<JCExpression> getBounds() {
2116 return bounds;
2117 }
2118 @Override
2119 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2120 return v.visitTypeParameter(this, d);
2121 }
2122 @Override
2123 public Tag getTag() {
2124 return TYPEPARAMETER;
2125 }
2126 }
2128 public static class JCWildcard extends JCExpression implements WildcardTree {
2129 public TypeBoundKind kind;
2130 public JCTree inner;
2131 protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2132 kind.getClass(); // null-check
2133 this.kind = kind;
2134 this.inner = inner;
2135 }
2136 @Override
2137 public void accept(Visitor v) { v.visitWildcard(this); }
2139 public Kind getKind() {
2140 switch (kind.kind) {
2141 case UNBOUND:
2142 return Kind.UNBOUNDED_WILDCARD;
2143 case EXTENDS:
2144 return Kind.EXTENDS_WILDCARD;
2145 case SUPER:
2146 return Kind.SUPER_WILDCARD;
2147 default:
2148 throw new AssertionError("Unknown wildcard bound " + kind);
2149 }
2150 }
2151 public JCTree getBound() { return inner; }
2152 @Override
2153 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2154 return v.visitWildcard(this, d);
2155 }
2156 @Override
2157 public Tag getTag() {
2158 return Tag.WILDCARD;
2159 }
2160 }
2162 public static class TypeBoundKind extends JCTree {
2163 public BoundKind kind;
2164 protected TypeBoundKind(BoundKind kind) {
2165 this.kind = kind;
2166 }
2167 @Override
2168 public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2170 public Kind getKind() {
2171 throw new AssertionError("TypeBoundKind is not part of a public API");
2172 }
2173 @Override
2174 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2175 throw new AssertionError("TypeBoundKind is not part of a public API");
2176 }
2177 @Override
2178 public Tag getTag() {
2179 return TYPEBOUNDKIND;
2180 }
2181 }
2183 public static class JCAnnotation extends JCExpression implements AnnotationTree {
2184 public JCTree annotationType;
2185 public List<JCExpression> args;
2186 protected JCAnnotation(JCTree annotationType, List<JCExpression> args) {
2187 this.annotationType = annotationType;
2188 this.args = args;
2189 }
2190 @Override
2191 public void accept(Visitor v) { v.visitAnnotation(this); }
2193 public Kind getKind() { return Kind.ANNOTATION; }
2194 public JCTree getAnnotationType() { return annotationType; }
2195 public List<JCExpression> getArguments() {
2196 return args;
2197 }
2198 @Override
2199 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2200 return v.visitAnnotation(this, d);
2201 }
2202 @Override
2203 public Tag getTag() {
2204 return ANNOTATION;
2205 }
2206 }
2208 public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
2209 public long flags;
2210 public List<JCAnnotation> annotations;
2211 protected JCModifiers(long flags, List<JCAnnotation> annotations) {
2212 this.flags = flags;
2213 this.annotations = annotations;
2214 }
2215 @Override
2216 public void accept(Visitor v) { v.visitModifiers(this); }
2218 public Kind getKind() { return Kind.MODIFIERS; }
2219 public Set<Modifier> getFlags() {
2220 return Flags.asModifierSet(flags);
2221 }
2222 public List<JCAnnotation> getAnnotations() {
2223 return annotations;
2224 }
2225 @Override
2226 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2227 return v.visitModifiers(this, d);
2228 }
2229 @Override
2230 public Tag getTag() {
2231 return MODIFIERS;
2232 }
2233 }
2235 public static class JCErroneous extends JCExpression
2236 implements com.sun.source.tree.ErroneousTree {
2237 public List<? extends JCTree> errs;
2238 protected JCErroneous(List<? extends JCTree> errs) {
2239 this.errs = errs;
2240 }
2241 @Override
2242 public void accept(Visitor v) { v.visitErroneous(this); }
2244 public Kind getKind() { return Kind.ERRONEOUS; }
2246 public List<? extends JCTree> getErrorTrees() {
2247 return errs;
2248 }
2250 @Override
2251 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2252 return v.visitErroneous(this, d);
2253 }
2254 @Override
2255 public Tag getTag() {
2256 return ERRONEOUS;
2257 }
2258 }
2260 /** (let int x = 3; in x+2) */
2261 public static class LetExpr extends JCExpression {
2262 public List<JCVariableDecl> defs;
2263 public JCTree expr;
2264 protected LetExpr(List<JCVariableDecl> defs, JCTree expr) {
2265 this.defs = defs;
2266 this.expr = expr;
2267 }
2268 @Override
2269 public void accept(Visitor v) { v.visitLetExpr(this); }
2271 public Kind getKind() {
2272 throw new AssertionError("LetExpr is not part of a public API");
2273 }
2274 @Override
2275 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2276 throw new AssertionError("LetExpr is not part of a public API");
2277 }
2278 @Override
2279 public Tag getTag() {
2280 return LETEXPR;
2281 }
2282 }
2284 /** An interface for tree factories
2285 */
2286 public interface Factory {
2287 JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
2288 JCExpression pid,
2289 List<JCTree> defs);
2290 JCImport Import(JCTree qualid, boolean staticImport);
2291 JCClassDecl ClassDef(JCModifiers mods,
2292 Name name,
2293 List<JCTypeParameter> typarams,
2294 JCExpression extending,
2295 List<JCExpression> implementing,
2296 List<JCTree> defs);
2297 JCMethodDecl MethodDef(JCModifiers mods,
2298 Name name,
2299 JCExpression restype,
2300 List<JCTypeParameter> typarams,
2301 List<JCVariableDecl> params,
2302 List<JCExpression> thrown,
2303 JCBlock body,
2304 JCExpression defaultValue);
2305 JCVariableDecl VarDef(JCModifiers mods,
2306 Name name,
2307 JCExpression vartype,
2308 JCExpression init);
2309 JCSkip Skip();
2310 JCBlock Block(long flags, List<JCStatement> stats);
2311 JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
2312 JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
2313 JCForLoop ForLoop(List<JCStatement> init,
2314 JCExpression cond,
2315 List<JCExpressionStatement> step,
2316 JCStatement body);
2317 JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
2318 JCLabeledStatement Labelled(Name label, JCStatement body);
2319 JCSwitch Switch(JCExpression selector, List<JCCase> cases);
2320 JCCase Case(JCExpression pat, List<JCStatement> stats);
2321 JCSynchronized Synchronized(JCExpression lock, JCBlock body);
2322 JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
2323 JCTry Try(List<JCTree> resources,
2324 JCBlock body,
2325 List<JCCatch> catchers,
2326 JCBlock finalizer);
2327 JCCatch Catch(JCVariableDecl param, JCBlock body);
2328 JCConditional Conditional(JCExpression cond,
2329 JCExpression thenpart,
2330 JCExpression elsepart);
2331 JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
2332 JCExpressionStatement Exec(JCExpression expr);
2333 JCBreak Break(Name label);
2334 JCContinue Continue(Name label);
2335 JCReturn Return(JCExpression expr);
2336 JCThrow Throw(JCTree expr);
2337 JCAssert Assert(JCExpression cond, JCExpression detail);
2338 JCMethodInvocation Apply(List<JCExpression> typeargs,
2339 JCExpression fn,
2340 List<JCExpression> args);
2341 JCNewClass NewClass(JCExpression encl,
2342 List<JCExpression> typeargs,
2343 JCExpression clazz,
2344 List<JCExpression> args,
2345 JCClassDecl def);
2346 JCNewArray NewArray(JCExpression elemtype,
2347 List<JCExpression> dims,
2348 List<JCExpression> elems);
2349 JCParens Parens(JCExpression expr);
2350 JCAssign Assign(JCExpression lhs, JCExpression rhs);
2351 JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
2352 JCUnary Unary(Tag opcode, JCExpression arg);
2353 JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
2354 JCTypeCast TypeCast(JCTree expr, JCExpression type);
2355 JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
2356 JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
2357 JCFieldAccess Select(JCExpression selected, Name selector);
2358 JCIdent Ident(Name idname);
2359 JCLiteral Literal(TypeTag tag, Object value);
2360 JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
2361 JCArrayTypeTree TypeArray(JCExpression elemtype);
2362 JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
2363 JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
2364 JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
2365 TypeBoundKind TypeBoundKind(BoundKind kind);
2366 JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
2367 JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
2368 JCErroneous Erroneous(List<? extends JCTree> errs);
2369 LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr);
2370 }
2372 /** A generic visitor class for trees.
2373 */
2374 public static abstract class Visitor {
2375 public void visitTopLevel(JCCompilationUnit that) { visitTree(that); }
2376 public void visitImport(JCImport that) { visitTree(that); }
2377 public void visitClassDef(JCClassDecl that) { visitTree(that); }
2378 public void visitMethodDef(JCMethodDecl that) { visitTree(that); }
2379 public void visitVarDef(JCVariableDecl that) { visitTree(that); }
2380 public void visitSkip(JCSkip that) { visitTree(that); }
2381 public void visitBlock(JCBlock that) { visitTree(that); }
2382 public void visitDoLoop(JCDoWhileLoop that) { visitTree(that); }
2383 public void visitWhileLoop(JCWhileLoop that) { visitTree(that); }
2384 public void visitForLoop(JCForLoop that) { visitTree(that); }
2385 public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
2386 public void visitLabelled(JCLabeledStatement that) { visitTree(that); }
2387 public void visitSwitch(JCSwitch that) { visitTree(that); }
2388 public void visitCase(JCCase that) { visitTree(that); }
2389 public void visitSynchronized(JCSynchronized that) { visitTree(that); }
2390 public void visitTry(JCTry that) { visitTree(that); }
2391 public void visitCatch(JCCatch that) { visitTree(that); }
2392 public void visitConditional(JCConditional that) { visitTree(that); }
2393 public void visitIf(JCIf that) { visitTree(that); }
2394 public void visitExec(JCExpressionStatement that) { visitTree(that); }
2395 public void visitBreak(JCBreak that) { visitTree(that); }
2396 public void visitContinue(JCContinue that) { visitTree(that); }
2397 public void visitReturn(JCReturn that) { visitTree(that); }
2398 public void visitThrow(JCThrow that) { visitTree(that); }
2399 public void visitAssert(JCAssert that) { visitTree(that); }
2400 public void visitApply(JCMethodInvocation that) { visitTree(that); }
2401 public void visitNewClass(JCNewClass that) { visitTree(that); }
2402 public void visitNewArray(JCNewArray that) { visitTree(that); }
2403 public void visitLambda(JCLambda that) { visitTree(that); }
2404 public void visitParens(JCParens that) { visitTree(that); }
2405 public void visitAssign(JCAssign that) { visitTree(that); }
2406 public void visitAssignop(JCAssignOp that) { visitTree(that); }
2407 public void visitUnary(JCUnary that) { visitTree(that); }
2408 public void visitBinary(JCBinary that) { visitTree(that); }
2409 public void visitTypeCast(JCTypeCast that) { visitTree(that); }
2410 public void visitTypeTest(JCInstanceOf that) { visitTree(that); }
2411 public void visitIndexed(JCArrayAccess that) { visitTree(that); }
2412 public void visitSelect(JCFieldAccess that) { visitTree(that); }
2413 public void visitReference(JCMemberReference that) { visitTree(that); }
2414 public void visitIdent(JCIdent that) { visitTree(that); }
2415 public void visitLiteral(JCLiteral that) { visitTree(that); }
2416 public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
2417 public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); }
2418 public void visitTypeApply(JCTypeApply that) { visitTree(that); }
2419 public void visitTypeUnion(JCTypeUnion that) { visitTree(that); }
2420 public void visitTypeIntersection(JCTypeIntersection that) { visitTree(that); }
2421 public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
2422 public void visitWildcard(JCWildcard that) { visitTree(that); }
2423 public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); }
2424 public void visitAnnotation(JCAnnotation that) { visitTree(that); }
2425 public void visitModifiers(JCModifiers that) { visitTree(that); }
2426 public void visitErroneous(JCErroneous that) { visitTree(that); }
2427 public void visitLetExpr(LetExpr that) { visitTree(that); }
2429 public void visitTree(JCTree that) { Assert.error(); }
2430 }
2432 }