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