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